diff --git a/examples/all-clusters-app/esp32/sdkconfig_m5stack.defaults b/examples/all-clusters-app/esp32/sdkconfig_m5stack.defaults index 287262d17e57cc..8c30112f96d500 100644 --- a/examples/all-clusters-app/esp32/sdkconfig_m5stack.defaults +++ b/examples/all-clusters-app/esp32/sdkconfig_m5stack.defaults @@ -73,3 +73,9 @@ CONFIG_BUILD_CHIP_TESTS=y # Move functions from IRAM to flash CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y + +# Reduce the event loggin buffer to reduce the DRAM usage +# TODO: remove this once the underlying issue is fixed +CONFIG_EVENT_LOGGING_CRIT_BUFFER_SIZE=512 +CONFIG_EVENT_LOGGING_INFO_BUFFER_SIZE=512 +CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE=512 diff --git a/examples/all-clusters-app/esp32/sdkconfig_m5stack_rpc.defaults b/examples/all-clusters-app/esp32/sdkconfig_m5stack_rpc.defaults index 3f1168ecb907ec..f7aba926a4df67 100644 --- a/examples/all-clusters-app/esp32/sdkconfig_m5stack_rpc.defaults +++ b/examples/all-clusters-app/esp32/sdkconfig_m5stack_rpc.defaults @@ -78,9 +78,6 @@ CONFIG_BUILD_CHIP_TESTS=y # Move functions from IRAM to flash CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y -# to avoid dram overflow, reduce the critical loggin buffer to 1K -CONFIG_EVENT_LOGGING_CRIT_BUFFER_SIZE=1024 - CONFIG_DIAG_USE_EXTERNAL_LOG_WRAP=y # Memory Optimizations @@ -88,3 +85,9 @@ CONFIG_NIMBLE_MAX_CONNECTIONS=1 CONFIG_BTDM_CTRL_BLE_MAX_CONN=1 CONFIG_BT_NIMBLE_ROLE_CENTRAL=n CONFIG_BT_NIMBLE_ROLE_OBSERVER=n + +# Reduce the event loggin buffer to reduce the DRAM overflow +# TODO: remove this once the underlying issue is fixed +CONFIG_EVENT_LOGGING_CRIT_BUFFER_SIZE=512 +CONFIG_EVENT_LOGGING_INFO_BUFFER_SIZE=512 +CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE=512 diff --git a/examples/lock-app/lock-common/lock-app.matter b/examples/lock-app/lock-common/lock-app.matter index 5ee4744f901fde..143d3c67f19031 100644 --- a/examples/lock-app/lock-common/lock-app.matter +++ b/examples/lock-app/lock-common/lock-app.matter @@ -3079,11 +3079,20 @@ endpoint 1 { ram attribute wrongCodeEntryLimit default = 3; ram attribute userCodeTemporaryDisableTime default = 10; ram attribute requirePINforRemoteOperation default = 0; + callback attribute aliroReaderVerificationKey; + callback attribute aliroReaderGroupIdentifier; + callback attribute aliroReaderGroupSubIdentifier; + callback attribute aliroExpeditedTransactionSupportedProtocolVersions; + callback attribute aliroGroupResolvingKey; + callback attribute aliroSupportedBLEUWBProtocolVersions; + callback attribute aliroBLEAdvertisingVersion; + callback attribute numberOfAliroCredentialIssuerKeysSupported; + callback attribute numberOfAliroEndpointKeysSupported; callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute eventList; callback attribute attributeList; - ram attribute featureMap default = 0x1DB3; + ram attribute featureMap default = 0x7DB3; ram attribute clusterRevision default = 7; handle command LockDoor; @@ -3111,6 +3120,8 @@ endpoint 1 { handle command GetCredentialStatusResponse; handle command ClearCredential; handle command UnboltDoor; + handle command SetAliroReaderConfig; + handle command ClearAliroReaderConfig; } } diff --git a/examples/lock-app/lock-common/lock-app.zap b/examples/lock-app/lock-common/lock-app.zap index 8e25d9248c1429..30fe0db47c2fa8 100644 --- a/examples/lock-app/lock-common/lock-app.zap +++ b/examples/lock-app/lock-common/lock-app.zap @@ -5851,6 +5851,22 @@ "source": "client", "isIncoming": 1, "isEnabled": 1 + }, + { + "name": "SetAliroReaderConfig", + "code": 40, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "ClearAliroReaderConfig", + "code": 41, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 } ], "attributes": [ @@ -6270,6 +6286,150 @@ "maxInterval": 65534, "reportableChange": 0 }, + { + "name": "AliroReaderVerificationKey", + "code": 128, + "mfgCode": null, + "side": "server", + "type": "octet_string", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AliroReaderGroupIdentifier", + "code": 129, + "mfgCode": null, + "side": "server", + "type": "octet_string", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AliroReaderGroupSubIdentifier", + "code": 130, + "mfgCode": null, + "side": "server", + "type": "octet_string", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AliroExpeditedTransactionSupportedProtocolVersions", + "code": 131, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AliroGroupResolvingKey", + "code": 132, + "mfgCode": null, + "side": "server", + "type": "octet_string", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AliroSupportedBLEUWBProtocolVersions", + "code": 133, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AliroBLEAdvertisingVersion", + "code": 134, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "NumberOfAliroCredentialIssuerKeysSupported", + "code": 135, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "NumberOfAliroEndpointKeysSupported", + "code": 136, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "GeneratedCommandList", "code": 65528, @@ -6344,7 +6504,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x1DB3", + "defaultValue": "0x7DB3", "reportable": 1, "minInterval": 1, "maxInterval": 65534, diff --git a/src/app/tests/suites/certification/PICS.yaml b/src/app/tests/suites/certification/PICS.yaml index 836e71e3964e40..8a3e1fce94326f 100644 --- a/src/app/tests/suites/certification/PICS.yaml +++ b/src/app/tests/suites/certification/PICS.yaml @@ -2738,6 +2738,46 @@ PICS: - label: "Does the DUT(server) support the ExpiringUserTimeOut attribute?" id: DRLK.S.A0035 + - label: + "Does the DUT(server) support the AliroReaderVerificationKey attribute" + id: DRLK.S.A0080 + + - label: + "Does the DUT(server) support the AliroReaderGroupIdentifier attribute" + id: DRLK.S.A0081 + + - label: + "Does the DUT(server) support the AliroReaderGroupSubIdentifier + attribute" + id: DRLK.S.A0082 + + - label: + "Does the DUT(server) support the + AliroExpeditedTransactionSupportedProtocolVersions attribute" + id: DRLK.S.A0083 + + - label: "Does the DUT(server) support the AliroGroupResolvingKey attribute" + id: DRLK.S.A0084 + + - label: + "Does the DUT(server) support the AliroSupportedBLEUWBProtocolVersions + attribute" + id: DRLK.S.A0085 + + - label: + "Does the DUT(server) support the AliroBLEAdvertisingVersion attribute" + id: DRLK.S.A0086 + + - label: + "Does the DUT(server) support the + NumberOfAliroCredentialIssuerKeysSupported attribute" + id: DRLK.S.A0087 + + - label: + "Does the DUT(server) support the NumberOfAliroEndpointKeysSupported + attribute" + id: DRLK.S.A0088 + # #Server ReadOnly attribute # @@ -2869,6 +2909,12 @@ PICS: - label: "Does the DUT(server) support the Unbolt Door command?" id: DRLK.S.C27.Rsp + - label: "Does the DUT(server) support the SetAliroReaderConfig command?" + id: DRLK.S.C28.Rsp + + - label: "Does the DUT(server) support the ClearAliroReaderConfig command?" + id: DRLK.S.C29.Rsp + # # server / commandsGenerated # @@ -2970,6 +3016,14 @@ PICS: - label: "Does the DUT(server) support the Lock supports unbolting feature?" id: DRLK.S.F0c + - label: "Does the DUT(server) support AliroProvisioning feature?" + id: DRLK.S.F0d + + - label: + "Does the DUT(server) support Bluetooth LE + UWB Access Control Flow + feature?" + id: DRLK.S.F0e + # # server / manually # diff --git a/src/app/tests/suites/certification/Test_TC_DRLK_2_1.yaml b/src/app/tests/suites/certification/Test_TC_DRLK_2_1.yaml index e84b1ebdbc8459..519ffa8780f673 100755 --- a/src/app/tests/suites/certification/Test_TC_DRLK_2_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_DRLK_2_1.yaml @@ -1551,8 +1551,18 @@ tests: response: value: NumberOfCredentialsSupportedPerUserValue - - label: "Cleanup the created user" - PICS: DRLK.S.F00 && DRLK.S.F07 + - label: "Step 36: TH sends ClearCredential Command to DUT" + PICS: DRLK.S.F00 && DRLK.S.F07 && DRLK.S.C26.Rsp + command: "ClearCredential" + timedInteractionTimeoutMs: 1000 + arguments: + values: + - name: "Credential" + value: { CredentialType: 1, CredentialIndex: 1 } + + - label: + "Step 37: TH sends ClearUser Command to DUT with the UserIndex as 1" + PICS: DRLK.S.F07 && DRLK.S.C1d.Rsp command: "ClearUser" timedInteractionTimeoutMs: 1000 arguments: @@ -1560,11 +1570,277 @@ tests: - name: "UserIndex" value: 1 - - label: "Clean the created credential" - PICS: DRLK.S.F00 && DRLK.S.F07 && DRLK.S.C26.Rsp - command: "ClearCredential" - timedInteractionTimeoutMs: 1000 + - label: "Step 38a: TH reads AliroReaderVerificationKey attribute from DUT" + PICS: DRLK.S.F0d && DRLK.S.A0080 + command: "readAttribute" + attribute: "AliroReaderVerificationKey" + response: + saveAs: verificationkey + constraints: + type: octet_string + minLength: 65 + maxLength: 65 + + - label: + "Step 38b: TH writes AliroReaderVerificationKey attribute as an octstr + value of length 65 which is different from verificationkey" + PICS: DRLK.S.F0d && DRLK.S.A0080 + command: "writeAttribute" + attribute: "AliroReaderVerificationKey" arguments: - values: - - name: "Credential" - value: { CredentialType: 1, CredentialIndex: 1 } + value: "047a4c992d753924cdf3779a3c84fec2debaa6f0b3084450878acc7ddcce7856ae57b1ebbe2561015103dd7474c2a183675378ec55f1e465ac3436bf3dd5ca54d4" + response: + error: UNSUPPORTED_WRITE + + - label: "Step 38c: TH reads AliroReaderVerificationKey attribute from DUT" + + PICS: DRLK.S.F0d && DRLK.S.A0080 + command: "readAttribute" + attribute: "AliroReaderVerificationKey" + response: + value: verificationkey + + - label: "Step 39a: TH reads AliroReaderGroupIdentifier attribute from DUT" + PICS: DRLK.S.F0d && DRLK.S.A0081 + command: "readAttribute" + attribute: "AliroReaderGroupIdentifier" + response: + saveAs: aliroreadergrpidentifier + constraints: + type: octet_string + minLength: 16 + maxLength: 16 + + - label: + "Step 39b: TH writes AliroReaderGroupIdentifier attribute as octstr + value of length 16 which is different from aliroreadergrpidentifier" + PICS: DRLK.S.F0d && DRLK.S.A0081 + command: "writeAttribute" + attribute: "AliroReaderVerificationKey" + arguments: + value: "047a4c992d753924" + response: + error: UNSUPPORTED_WRITE + + - label: "Step 39c: TH reads AliroReaderGroupIdentifier attribute from DUT" + PICS: DRLK.S.F0d && DRLK.S.A0081 + command: "readAttribute" + attribute: "AliroReaderGroupIdentifier" + response: + value: aliroreadergrpidentifier + - label: + "Step 40a: TH reads AliroReaderGroupSubIdentifier attribute from DUT" + PICS: DRLK.S.F0d && DRLK.S.A0082 + command: "readAttribute" + attribute: "AliroReaderGroupSubIdentifier" + response: + saveAs: aliroreadergrpsubidentifier + constraints: + type: octet_string + minLength: 16 + maxLength: 16 + + - label: + "Step 40b: TH writes AliroReaderGroupSubIdentifier attribute as octstr + value of length 16 which is different from aliroreadergrpsubidentifier" + PICS: DRLK.S.F0d && DRLK.S.A0082 + command: "writeAttribute" + attribute: "AliroReaderGroupSubIdentifier" + arguments: + value: "047a4c992d75368" + response: + error: UNSUPPORTED_WRITE + + - label: "Step 40c: TH reads AliroReaderGroupIdentifier attribute from DUT" + PICS: DRLK.S.F0d && DRLK.S.A0082 + command: "readAttribute" + attribute: "AliroReaderGroupSubIdentifier" + response: + value: aliroreadergrpsubidentifier + + - label: + "Step 41a: TH reads AliroExpeditedTransactionSupportedProtocolVersions + attribute from DUT" + PICS: DRLK.S.F0d && DRLK.S.A0083 + command: "readAttribute" + attribute: "AliroExpeditedTransactionSupportedProtocolVersions" + response: + saveAs: aliroprotocolversion + constraints: + type: list + maxLength: 16 + + - label: + "Step 41b: TH writes + AliroExpeditedTransactionSupportedProtocolVersions attribute as list + which is different from aliroprotocolversion" + PICS: DRLK.S.F0d && DRLK.S.A0083 + command: "writeAttribute" + attribute: "AliroExpeditedTransactionSupportedProtocolVersions" + arguments: + value: ["\x01", "\x02"] + response: + error: UNSUPPORTED_WRITE + + - label: + "Step 41c: TH reads AliroExpeditedTransactionSupportedProtocolVersions + attribute from DUT" + PICS: DRLK.S.F0d && DRLK.S.A0083 + command: "readAttribute" + attribute: "AliroExpeditedTransactionSupportedProtocolVersions" + response: + value: aliroprotocolversion + + - label: "Step 42a: TH reads AliroGroupResolvingKey attribute from DUT" + PICS: DRLK.S.F0d && DRLK.S.A0084 + command: "readAttribute" + attribute: "AliroGroupResolvingKey" + response: + saveAs: alirogrpresolvingkey + constraints: + type: octet_string + minLength: 16 + maxLength: 16 + + - label: + "Step 42b: TH writes AliroGroupResolvingKey attribute as octstr value + of length 16 which is different from alirogrpresolvingkey" + PICS: DRLK.S.F0d && DRLK.S.A0084 + command: "writeAttribute" + attribute: "AliroGroupResolvingKey" + arguments: + value: "047a4c992d75368" + response: + error: UNSUPPORTED_WRITE + + - label: "Step 42c: TH reads AliroGroupResolvingKey attribute from DUT" + PICS: DRLK.S.F0d && DRLK.S.A0084 + command: "readAttribute" + attribute: "AliroGroupResolvingKey" + response: + value: alirogrpresolvingkey + + - label: + "Step 43a: TH reads AliroSupportedBLEUWBProtocolVersions attribute + from DUT" + PICS: DRLK.S.F0d && DRLK.S.A0085 + command: "readAttribute" + attribute: "AliroSupportedBLEUWBProtocolVersions" + response: + saveAs: alirobleuwbprotocolversion + constraints: + type: list + maxLength: 16 + + - label: + "Step 43b: TH writes AliroSupportedBLEUWBProtocolVersions attribute as + list which is different from alirobleuwbprotocolversion" + PICS: DRLK.S.F0d && DRLK.S.A0085 + command: "writeAttribute" + attribute: "AliroSupportedBLEUWBProtocolVersions" + arguments: + value: ["\x01", "\x02"] + response: + error: UNSUPPORTED_WRITE + + - label: "Step 43c: TH reads AliroGroupResolvingKey attribute from DUT" + PICS: DRLK.S.F0d && DRLK.S.A0085 + command: "readAttribute" + attribute: "AliroSupportedBLEUWBProtocolVersions" + response: + value: alirobleuwbprotocolversion + + - label: "Step 44a: TH reads AliroBLEAdvertisingVersion attribute from DUT" + PICS: DRLK.S.F0d && DRLK.S.A0086 + command: "readAttribute" + attribute: "AliroBLEAdvertisingVersion" + response: + saveAs: alirobleadvversion + constraints: + type: int8u + minValue: 0 + maxValue: 255 + + - label: + "Step 44b: TH writes AliroBLEAdvertisingVersion attribute as any value + different from alirobleadvversion" + PICS: DRLK.S.F0d && DRLK.S.A0086 + command: "writeAttribute" + attribute: "AliroBLEAdvertisingVersion" + arguments: + value: 85 + response: + error: UNSUPPORTED_WRITE + + - label: "Step 44c: TH reads AliroBLEAdvertisingVersion attribute from DUT" + PICS: DRLK.S.F0d && DRLK.S.A0086 + command: "readAttribute" + attribute: "AliroBLEAdvertisingVersion" + response: + value: alirobleadvversion + + - label: + "Step 45a: TH reads NumberOfAliroCredentialIssuerKeysSupported + attribute from DUT" + PICS: DRLK.S.F0d && DRLK.S.A0087 + command: "readAttribute" + attribute: "NumberOfAliroCredentialIssuerKeysSupported" + response: + saveAs: alirokeysupported + constraints: + type: int16u + minValue: 0 + maxValue: 65534 + + - label: + "Step 45b: TH writes NumberOfAliroCredentialIssuerKeysSupported + attribute as any value different from alirokeysupported" + PICS: DRLK.S.F0d && DRLK.S.A0087 + command: "writeAttribute" + attribute: "NumberOfAliroCredentialIssuerKeysSupported" + arguments: + value: 30 + response: + error: UNSUPPORTED_WRITE + + - label: + "Step 45c: TH reads NumberOfAliroCredentialIssuerKeysSupported + attribute from DUT" + PICS: DRLK.S.F0d && DRLK.S.A0087 + command: "readAttribute" + attribute: "NumberOfAliroCredentialIssuerKeysSupported" + response: + value: alirokeysupported + + - label: + "Step 46a: TH reads NumberOfAliroEndpointKeysSupported attribute from + DUT" + PICS: DRLK.S.F0d && DRLK.S.A0088 + command: "readAttribute" + attribute: "NumberOfAliroEndpointKeysSupported" + response: + saveAs: aliroepkeysupported + constraints: + type: int16u + minValue: 0 + maxValue: 65534 + + - label: + "Step 46b: TH writes NumberOfAliroEndpointKeysSupported attribute as + any value different from aliroepkeysupported" + PICS: DRLK.S.F0d && DRLK.S.A0088 + command: "writeAttribute" + attribute: "NumberOfAliroEndpointKeysSupported" + arguments: + value: 1000 + response: + error: UNSUPPORTED_WRITE + + - label: + "Step 46c: TH reads NumberOfAliroEndpointKeysSupported attribute from + DUT" + PICS: DRLK.S.F0d && DRLK.S.A0088 + command: "readAttribute" + attribute: "NumberOfAliroEndpointKeysSupported" + response: + value: aliroepkeysupported diff --git a/src/app/tests/suites/certification/Test_TC_DRLK_2_9.yaml b/src/app/tests/suites/certification/Test_TC_DRLK_2_9.yaml index 0c10f9fa7ba058..0c0a372b175d7e 100644 --- a/src/app/tests/suites/certification/Test_TC_DRLK_2_9.yaml +++ b/src/app/tests/suites/certification/Test_TC_DRLK_2_9.yaml @@ -431,7 +431,7 @@ tests: - label: "Step 14: TH sends Clear Credential Command to DUT with the following fields: a)CredentialType as 8(Invalid value) b)CredentialIndex as 2" - PICS: DRLK.S.F08 && DRLK.S.C26.Rsp + PICS: DRLK.S.F08 && DRLK.S.C26.Rsp && !DRLK.S.F0d command: "ClearCredential" timedInteractionTimeoutMs: 10000 arguments: @@ -441,6 +441,19 @@ tests: response: error: INVALID_COMMAND + - label: + "Step 14: TH sends Clear Credential Command to DUT with the following + fields: a)CredentialType as 9(Invalid value) b)CredentialIndex as 2" + PICS: DRLK.S.F08 && DRLK.S.C26.Rsp && DRLK.S.F0d + command: "ClearCredential" + timedInteractionTimeoutMs: 10000 + arguments: + values: + - name: "Credential" + value: { CredentialType: 9, CredentialIndex: 2 } + response: + error: INVALID_COMMAND + - label: "Cleanup the first created user" command: "ClearUser" timedInteractionTimeoutMs: 10000 diff --git a/src/app/tests/suites/certification/ci-pics-values b/src/app/tests/suites/certification/ci-pics-values index fe5ffcdab753b1..a8601fbd27d3ef 100644 --- a/src/app/tests/suites/certification/ci-pics-values +++ b/src/app/tests/suites/certification/ci-pics-values @@ -1519,11 +1519,21 @@ DRLK.S.A0031=1 DRLK.S.A0032=1 DRLK.S.A0033=1 DRLK.S.A0035=0 +DRLK.S.A0080=1 +DRLK.S.A0081=1 +DRLK.S.A0082=1 +DRLK.S.A0083=1 +DRLK.S.A0084=1 +DRLK.S.A0085=1 +DRLK.S.A0086=1 +DRLK.S.A0087=1 +DRLK.S.A0088=1 #ReadOnly attributes DRLK.S.A0028.ReadOnly=1 DRLK.S.A002c.ReadOnly=1 + #write attributes DRLK.S.M.SimulateNotFullyLocked=1 DRLK.S.M.DetectLockJammed=1 @@ -1564,6 +1574,8 @@ DRLK.S.F08=1 DRLK.S.F0a=1 DRLK.S.F0b=1 DRLK.S.F0c=1 +DRLK.S.F0d=1 +DRLK.S.F0e=1 # Server Commands DRLK.S.C00.Rsp=1 @@ -1585,6 +1597,8 @@ DRLK.S.C22.Rsp=1 DRLK.S.C24.Rsp=1 DRLK.S.C26.Rsp=1 DRLK.S.C27.Rsp=1 +DRLK.S.C28.Rsp=1 +DRLK.S.C29.Rsp=1 DRLK.S.C0c.Tx=1 DRLK.S.C0f.Tx=1 DRLK.S.C12.Tx=1 diff --git a/src/app/zap-templates/zcl/zcl-with-test-extensions.json b/src/app/zap-templates/zcl/zcl-with-test-extensions.json index 44de496f06f544..d826188bbfd700 100644 --- a/src/app/zap-templates/zcl/zcl-with-test-extensions.json +++ b/src/app/zap-templates/zcl/zcl-with-test-extensions.json @@ -211,6 +211,15 @@ "CurrentMode", "FeatureMap" ], + "Door Lock": [ + "AliroReaderVerificationKey", + "AliroReaderGroupIdentifier", + "AliroReaderGroupSubIdentifier", + "AliroGroupResolvingKey", + "AliroBLEAdvertisingVersion", + "NumberOfAliroCredentialIssuerKeysSupported", + "NumberOfAliroEndpointKeysSupported" + ], "Energy EVSE": [ "State", "SupplyState", diff --git a/src/app/zap-templates/zcl/zcl.json b/src/app/zap-templates/zcl/zcl.json index a72b44ee03084a..a5d48c88b540a0 100644 --- a/src/app/zap-templates/zcl/zcl.json +++ b/src/app/zap-templates/zcl/zcl.json @@ -209,6 +209,15 @@ "CurrentMode", "FeatureMap" ], + "Door Lock": [ + "AliroReaderVerificationKey", + "AliroReaderGroupIdentifier", + "AliroReaderGroupSubIdentifier", + "AliroGroupResolvingKey", + "AliroBLEAdvertisingVersion", + "NumberOfAliroCredentialIssuerKeysSupported", + "NumberOfAliroEndpointKeysSupported" + ], "Energy EVSE": [ "State", "SupplyState", diff --git a/src/controller/python/BUILD.gn b/src/controller/python/BUILD.gn index 57822f9ff34602..58d9cb1f7c4622 100644 --- a/src/controller/python/BUILD.gn +++ b/src/controller/python/BUILD.gn @@ -179,7 +179,9 @@ chip_python_wheel_action("chip-core") { "chip/commissioning/commissioning_flow_blocks.py", "chip/commissioning/pase.py", "chip/configuration/__init__.py", + "chip/credentials/__init__.py", "chip/credentials/cert.py", + "chip/crypto/__init__.py", "chip/crypto/fabric.py", "chip/crypto/p256keypair.py", "chip/discovery/__init__.py", diff --git a/src/controller/python/chip/ChipDeviceCtrl.py b/src/controller/python/chip/ChipDeviceCtrl.py index 91c83e8954fa37..5989a42977aafc 100644 --- a/src/controller/python/chip/ChipDeviceCtrl.py +++ b/src/controller/python/chip/ChipDeviceCtrl.py @@ -40,10 +40,10 @@ import threading import typing from ctypes import (CDLL, CFUNCTYPE, POINTER, Structure, byref, c_bool, c_char, c_char_p, c_int, c_int32, c_size_t, c_uint8, - c_uint16, c_uint32, c_uint64, c_void_p, create_string_buffer, pointer, py_object, resize, string_at) + c_uint16, c_uint32, c_uint64, c_void_p, cast, create_string_buffer, pointer, py_object, resize, string_at) from dataclasses import dataclass -import dacite +import dacite # type: ignore from . import FabricAdmin from . import clusters as Clusters @@ -104,10 +104,10 @@ class CommissioningParameters: @dataclass class NOCChain: - nocBytes: bytes - icacBytes: bytes - rcacBytes: bytes - ipkBytes: bytes + nocBytes: typing.Optional[bytes] + icacBytes: typing.Optional[bytes] + rcacBytes: typing.Optional[bytes] + ipkBytes: typing.Optional[bytes] adminSubject: int @@ -170,7 +170,7 @@ def __eq__(self, other): _OnCheckInCompleteFunct = CFUNCTYPE(None, ScopedNodeId) _OnCheckInCompleteWaitListLock = threading.Lock() -_OnCheckInCompleteWaitList = dict() +_OnCheckInCompleteWaitList: typing.Dict[ScopedNodeId, set] = dict() @_OnCheckInCompleteFunct @@ -183,7 +183,7 @@ def _OnCheckInComplete(scopedNodeId: ScopedNodeId): callback(scopedNodeId) -def RegisterOnActiveCallback(scopedNodeId: ScopedNodeId, callback: typing.Callable[None, [ScopedNodeId]]): +def RegisterOnActiveCallback(scopedNodeId: ScopedNodeId, callback: typing.Callable[[ScopedNodeId], None]): ''' Registers a callback when the device with given (fabric index, node id) becomes active. Does nothing if the callback is already registered. @@ -194,7 +194,7 @@ def RegisterOnActiveCallback(scopedNodeId: ScopedNodeId, callback: typing.Callab _OnCheckInCompleteWaitList[scopedNodeId] = waitList -def UnregisterOnActiveCallback(scopedNodeId: ScopedNodeId, callback: typing.Callable[None, [ScopedNodeId]]): +def UnregisterOnActiveCallback(scopedNodeId: ScopedNodeId, callback: typing.Callable[[ScopedNodeId], None]): ''' Unregisters a callback when the device with given (fabric index, node id) becomes active. Does nothing if the callback has not been registered. @@ -218,7 +218,7 @@ def OnCheckInCallback(nodeid): RegisterOnActiveCallback(scopedNodeId, OnCheckInCallback) try: - asyncio.wait_for(future, timeout=timeoutSeconds) + await asyncio.wait_for(future, timeout=timeoutSeconds) finally: UnregisterOnActiveCallback(scopedNodeId, OnCheckInCallback) @@ -273,7 +273,7 @@ class CommissioningContext(CallbackContext): This context also resets commissioning related device controller state. """ - def __init__(self, devCtrl: ChipDeviceController, lock: asyncio.Lock) -> None: + def __init__(self, devCtrl: ChipDeviceControllerBase, lock: asyncio.Lock) -> None: super().__init__(lock) self._devCtrl = devCtrl @@ -434,12 +434,12 @@ def closeTCPConnectionWithPeer(self): class ChipDeviceControllerBase(): - activeList = set() + activeList: typing.Set = set() def __init__(self, name: str = ''): self.devCtrl = None self._ChipStack = builtins.chipStack - self._dmLib = None + self._dmLib: typing.Any = None self._InitLib() @@ -484,8 +484,8 @@ def HandleCommissioningComplete(nodeId: int, err: PyChipError): def HandleFabricCheck(nodeId): self._fabricCheckNodeId = nodeId - def HandleOpenWindowComplete(nodeid: int, setupPinCode: int, setupManualCode: str, - setupQRCode: str, err: PyChipError) -> None: + def HandleOpenWindowComplete(nodeid: int, setupPinCode: int, setupManualCode: bytes, + setupQRCode: bytes, err: PyChipError) -> None: if err.is_success: LOGGER.info("Open Commissioning Window complete setting nodeid {} pincode to {}".format(nodeid, setupPinCode)) commissioningParameters = CommissioningParameters( @@ -576,10 +576,6 @@ def _finish_init(self): def _enablePairingCompleteCallback(self, value: bool): self._dmLib.pychip_ScriptDevicePairingDelegate_SetExpectingPairingComplete(self.pairingDelegate, value) - @property - def fabricAdmin(self) -> FabricAdmin.FabricAdmin: - return self._fabricAdmin - @property def nodeId(self) -> int: return self._nodeId @@ -618,7 +614,7 @@ def Shutdown(self): ChipDeviceController.activeList.remove(self) self._isActive = False - def ShutdownAll(): + def ShutdownAll(self): ''' Shut down all active controllers and reclaim any used resources. ''' # @@ -947,7 +943,7 @@ def GetClusterHandler(self): return self._Cluster - async def FindOrEstablishPASESession(self, setupCode: str, nodeid: int, timeoutMs: int = None) -> typing.Optional[DeviceProxyWrapper]: + async def FindOrEstablishPASESession(self, setupCode: str, nodeid: int, timeoutMs: typing.Optional[int] = None) -> typing.Optional[DeviceProxyWrapper]: ''' Returns CommissioneeDeviceProxy if we can find or establish a PASE connection to the specified device''' self.CheckIsActive() returnDevice = c_void_p(None) @@ -963,7 +959,9 @@ async def FindOrEstablishPASESession(self, setupCode: str, nodeid: int, timeoutM if res.is_success: return DeviceProxyWrapper(returnDevice, DeviceProxyWrapper.DeviceProxyType.COMMISSIONEE, self._dmLib) - def GetConnectedDeviceSync(self, nodeid, allowPASE=True, timeoutMs: int = None, payloadCapability: int = TransportPayloadCapability.MRP_PAYLOAD): + return None + + def GetConnectedDeviceSync(self, nodeid, allowPASE=True, timeoutMs: typing.Optional[int] = None, payloadCapability: int = TransportPayloadCapability.MRP_PAYLOAD): ''' Gets an OperationalDeviceProxy or CommissioneeDeviceProxy for the specified Node. nodeId: Target's Node ID @@ -976,7 +974,7 @@ def GetConnectedDeviceSync(self, nodeid, allowPASE=True, timeoutMs: int = None, self.CheckIsActive() returnDevice = c_void_p(None) - returnErr = None + returnErr: typing.Any = None deviceAvailableCV = threading.Condition() if allowPASE: @@ -1032,7 +1030,7 @@ async def WaitForActive(self, nodeid, *, timeoutSeconds=30.0, stayActiveDuration await WaitForCheckIn(ScopedNodeId(nodeid, self._fabricIndex), timeoutSeconds=timeoutSeconds) return await self.SendCommand(nodeid, 0, Clusters.IcdManagement.Commands.StayActiveRequest(stayActiveDuration=stayActiveDurationMs)) - async def GetConnectedDevice(self, nodeid, allowPASE: bool = True, timeoutMs: int = None, + async def GetConnectedDevice(self, nodeid, allowPASE: bool = True, timeoutMs: typing.Optional[int] = None, payloadCapability: int = TransportPayloadCapability.MRP_PAYLOAD): ''' Gets an OperationalDeviceProxy or CommissioneeDeviceProxy for the specified Node. @@ -1180,9 +1178,9 @@ async def TestOnlySendCommandTimedRequestFlagWithNoTimedInvoke(self, nodeid: int return await future async def SendCommand(self, nodeid: int, endpoint: int, payload: ClusterObjects.ClusterCommand, responseType=None, - timedRequestTimeoutMs: typing.Union[None, int] = None, - interactionTimeoutMs: typing.Union[None, int] = None, busyWaitMs: typing.Union[None, int] = None, - suppressResponse: typing.Union[None, bool] = None, + timedRequestTimeoutMs: typing.Optional[int] = None, + interactionTimeoutMs: typing.Optional[int] = None, busyWaitMs: typing.Optional[int] = None, + suppressResponse: typing.Optional[bool] = None, payloadCapability: int = TransportPayloadCapability.MRP_PAYLOAD): ''' Send a cluster-object encapsulated command to a node and get returned a future that can be awaited upon to receive @@ -1255,7 +1253,7 @@ async def SendBatchCommands(self, nodeid: int, commands: typing.List[ClusterComm res.raise_on_error() return await future - def SendGroupCommand(self, groupid: int, payload: ClusterObjects.ClusterCommand, busyWaitMs: typing.Union[None, int] = None): + def SendGroupCommand(self, groupid: int, payload: ClusterObjects.ClusterCommand, busyWaitMs: typing.Optional[int] = None): ''' Send a group cluster-object encapsulated command to a group_id and get returned a future that can be awaited upon to get confirmation command was sent. @@ -1274,8 +1272,8 @@ def SendGroupCommand(self, groupid: int, payload: ClusterObjects.ClusterCommand, async def WriteAttribute(self, nodeid: int, attributes: typing.List[typing.Tuple[int, ClusterObjects.ClusterAttributeDescriptor]], - timedRequestTimeoutMs: typing.Union[None, int] = None, - interactionTimeoutMs: typing.Union[None, int] = None, busyWaitMs: typing.Union[None, int] = None, + timedRequestTimeoutMs: typing.Optional[int] = None, + interactionTimeoutMs: typing.Optional[int] = None, busyWaitMs: typing.Optional[int] = None, payloadCapability: int = TransportPayloadCapability.MRP_PAYLOAD): ''' Write a list of attributes on a target node. @@ -1315,7 +1313,7 @@ async def WriteAttribute(self, nodeid: int, return await future def WriteGroupAttribute( - self, groupid: int, attributes: typing.List[typing.Tuple[ClusterObjects.ClusterAttributeDescriptor, int]], busyWaitMs: typing.Union[None, int] = None): + self, groupid: int, attributes: typing.List[typing.Tuple[ClusterObjects.ClusterAttributeDescriptor, int]], busyWaitMs: typing.Optional[int] = None): ''' Write a list of attributes on a target group. @@ -1429,7 +1427,7 @@ def _parseEventPathTuple(self, pathTuple: typing.Union[ else: raise ValueError("Unsupported Attribute Path") - async def Read(self, nodeid: int, attributes: typing.List[typing.Union[ + async def Read(self, nodeid: int, attributes: typing.Optional[typing.List[typing.Union[ None, # Empty tuple, all wildcard typing.Tuple[int], # Endpoint # Wildcard endpoint, Cluster id present @@ -1440,9 +1438,9 @@ async def Read(self, nodeid: int, attributes: typing.List[typing.Union[ typing.Tuple[int, typing.Type[ClusterObjects.Cluster]], # Concrete path typing.Tuple[int, typing.Type[ClusterObjects.ClusterAttributeDescriptor]] - ]] = None, - dataVersionFilters: typing.List[typing.Tuple[int, typing.Type[ClusterObjects.Cluster], int]] = None, events: typing.List[ - typing.Union[ + ]]] = None, + dataVersionFilters: typing.Optional[typing.List[typing.Tuple[int, typing.Type[ClusterObjects.Cluster], int]]] = None, events: typing.Optional[typing.List[ + typing.Union[ None, # Empty tuple, all wildcard typing.Tuple[str, int], # all wildcard with urgency set typing.Tuple[int, int], # Endpoint, @@ -1454,9 +1452,9 @@ async def Read(self, nodeid: int, attributes: typing.List[typing.Union[ typing.Tuple[int, typing.Type[ClusterObjects.Cluster], int], # Concrete path typing.Tuple[int, typing.Type[ClusterObjects.ClusterEvent], int] - ]] = None, + ]]] = None, eventNumberFilter: typing.Optional[int] = None, - returnClusterObject: bool = False, reportInterval: typing.Tuple[int, int] = None, + returnClusterObject: bool = False, reportInterval: typing.Optional[typing.Tuple[int, int]] = None, fabricFiltered: bool = True, keepSubscriptions: bool = False, autoResubscribe: bool = True, payloadCapability: int = TransportPayloadCapability.MRP_PAYLOAD): ''' @@ -1535,7 +1533,7 @@ async def Read(self, nodeid: int, attributes: typing.List[typing.Union[ keepSubscriptions=keepSubscriptions, autoResubscribe=autoResubscribe).raise_on_error() return await future - async def ReadAttribute(self, nodeid: int, attributes: typing.List[typing.Union[ + async def ReadAttribute(self, nodeid: int, attributes: typing.Optional[typing.List[typing.Union[ None, # Empty tuple, all wildcard typing.Tuple[int], # Endpoint # Wildcard endpoint, Cluster id present @@ -1546,9 +1544,9 @@ async def ReadAttribute(self, nodeid: int, attributes: typing.List[typing.Union[ typing.Tuple[int, typing.Type[ClusterObjects.Cluster]], # Concrete path typing.Tuple[int, typing.Type[ClusterObjects.ClusterAttributeDescriptor]] - ]], dataVersionFilters: typing.List[typing.Tuple[int, typing.Type[ClusterObjects.Cluster], int]] = None, + ]]], dataVersionFilters: typing.Optional[typing.List[typing.Tuple[int, typing.Type[ClusterObjects.Cluster], int]]] = None, returnClusterObject: bool = False, - reportInterval: typing.Tuple[int, int] = None, + reportInterval: typing.Optional[typing.Tuple[int, int]] = None, fabricFiltered: bool = True, keepSubscriptions: bool = False, autoResubscribe: bool = True, payloadCapability: int = TransportPayloadCapability.MRP_PAYLOAD): ''' @@ -1631,7 +1629,7 @@ async def ReadEvent(self, nodeid: int, events: typing.List[typing.Union[ typing.Tuple[int, typing.Type[ClusterObjects.ClusterEvent], int] ]], eventNumberFilter: typing.Optional[int] = None, fabricFiltered: bool = True, - reportInterval: typing.Tuple[int, int] = None, + reportInterval: typing.Optional[typing.Tuple[int, int]] = None, keepSubscriptions: bool = False, autoResubscribe: bool = True, payloadCapability: int = TransportPayloadCapability.MRP_PAYLOAD): @@ -1936,7 +1934,7 @@ class ChipDeviceController(ChipDeviceControllerBase): ''' def __init__(self, opCredsContext: ctypes.c_void_p, fabricId: int, nodeId: int, adminVendorId: int, catTags: typing.List[int] = [ - ], paaTrustStorePath: str = "", useTestCommissioner: bool = False, fabricAdmin: FabricAdmin = None, name: str = None, keypair: p256keypair.P256Keypair = None): + ], paaTrustStorePath: str = "", useTestCommissioner: bool = False, fabricAdmin: typing.Optional[FabricAdmin.FabricAdmin] = None, name: str = '', keypair: typing.Optional[p256keypair.P256Keypair] = None): super().__init__( name or f"caIndex({fabricAdmin.caIndex:x})/fabricId(0x{fabricId:016X})/nodeId(0x{nodeId:016X})" @@ -1956,8 +1954,8 @@ def __init__(self, opCredsContext: ctypes.c_void_p, fabricId: int, nodeId: int, # TODO(erjiaqing@): Figure out how to control enableServerInteractions for a single device controller (node) self._externalKeyPair = keypair self._ChipStack.Call( - lambda: self._dmLib.pychip_OpCreds_AllocateController(c_void_p( - opCredsContext), pointer(devCtrl), pointer(pairingDelegate), fabricId, nodeId, adminVendorId, c_char_p(None if len(paaTrustStorePath) == 0 else str.encode(paaTrustStorePath)), useTestCommissioner, self._ChipStack.enableServerInteractions, c_catTags, len(catTags), None if keypair is None else keypair.native_object) + lambda: self._dmLib.pychip_OpCreds_AllocateController(cast( + opCredsContext, c_void_p), pointer(devCtrl), pointer(pairingDelegate), fabricId, nodeId, adminVendorId, c_char_p(None if len(paaTrustStorePath) == 0 else str.encode(paaTrustStorePath)), useTestCommissioner, self._ChipStack.enableServerInteractions, c_catTags, len(catTags), None if keypair is None else keypair.native_object) ).raise_on_error() self._fabricAdmin = fabricAdmin @@ -1977,7 +1975,7 @@ def caIndex(self) -> int: return self._caIndex @property - def fabricAdmin(self) -> FabricAdmin: + def fabricAdmin(self) -> FabricAdmin.FabricAdmin: return self._fabricAdmin async def Commission(self, nodeid) -> int: @@ -2218,7 +2216,7 @@ class BareChipDeviceController(ChipDeviceControllerBase): ''' def __init__(self, operationalKey: p256keypair.P256Keypair, noc: bytes, - icac: typing.Union[bytes, None], rcac: bytes, ipk: typing.Union[bytes, None], adminVendorId: int, name: str = None): + icac: typing.Union[bytes, None], rcac: bytes, ipk: typing.Union[bytes, None], adminVendorId: int, name: typing.Optional[str] = None): '''Creates a controller without AutoCommissioner. The allocated controller uses the noc, icac, rcac and ipk instead of the default, @@ -2246,7 +2244,7 @@ def __init__(self, operationalKey: p256keypair.P256Keypair, noc: bytes, self._ChipStack.Call( lambda: self._dmLib.pychip_OpCreds_AllocateControllerForPythonCommissioningFLow( - c_void_p(devCtrl), c_void_p(pairingDelegate), nativeKey, noc, len(noc), icac, len(icac) if icac else 0, rcac, len(rcac), ipk, len(ipk) if ipk else 0, adminVendorId, self._ChipStack.enableServerInteractions) + cast(devCtrl, c_void_p), cast(pairingDelegate, c_void_p), nativeKey, noc, len(noc), icac, len(icac) if icac else 0, rcac, len(rcac), ipk, len(ipk) if ipk else 0, adminVendorId, self._ChipStack.enableServerInteractions) ).raise_on_error() self._set_dev_ctrl(devCtrl, pairingDelegate) diff --git a/src/controller/python/chip/clusters/Attribute.py b/src/controller/python/chip/clusters/Attribute.py index 06e893aa963be4..84124814238969 100644 --- a/src/controller/python/chip/clusters/Attribute.py +++ b/src/controller/python/chip/clusters/Attribute.py @@ -27,16 +27,16 @@ from ctypes import CFUNCTYPE, POINTER, c_size_t, c_uint8, c_uint16, c_uint32, c_uint64, c_void_p, cast, py_object from dataclasses import dataclass, field from enum import Enum, unique -from typing import Any, Callable, Dict, List, Optional, Tuple, Union +from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union import chip import chip.exceptions import chip.interaction_model import chip.tlv -import construct +import construct # type: ignore from chip.interaction_model import PyWriteAttributeData from chip.native import ErrorSDKPart, PyChipError -from rich.pretty import pprint +from rich.pretty import pprint # type: ignore from .ClusterObjects import Cluster, ClusterAttributeDescriptor, ClusterEvent @@ -58,9 +58,9 @@ class EventPriority(Enum): @dataclass(frozen=True) class AttributePath: - EndpointId: int = None - ClusterId: int = None - AttributeId: int = None + EndpointId: Optional[int] = None + ClusterId: Optional[int] = None + AttributeId: Optional[int] = None @staticmethod def from_cluster(EndpointId: int, Cluster: Cluster) -> AttributePath: @@ -80,12 +80,12 @@ def __str__(self) -> str: @dataclass(frozen=True) class DataVersionFilter: - EndpointId: int = None - ClusterId: int = None - DataVersion: int = None + EndpointId: Optional[int] = None + ClusterId: Optional[int] = None + DataVersion: Optional[int] = None @staticmethod - def from_cluster(EndpointId: int, Cluster: Cluster, DataVersion: int = None) -> AttributePath: + def from_cluster(EndpointId: int, Cluster: Cluster, DataVersion: int) -> DataVersionFilter: if Cluster is None: raise ValueError("Cluster cannot be None") return DataVersionFilter(EndpointId=EndpointId, ClusterId=Cluster.id, DataVersion=DataVersion) @@ -99,70 +99,67 @@ class TypedAttributePath: ''' Encapsulates an attribute path that has strongly typed references to cluster and attribute cluster object types. These types serve as keys into the attribute cache. ''' - ClusterType: Cluster = None - AttributeType: ClusterAttributeDescriptor = None - AttributeName: str = None - Path: AttributePath = None - - def __init__(self, ClusterType: Cluster = None, AttributeType: ClusterAttributeDescriptor = None, - Path: AttributePath = None): - ''' Only one of either ClusterType and AttributeType OR Path may be provided. - ''' - - # - # First, let's populate ClusterType and AttributeType. If it's already provided, - # we can continue onwards to deriving the label. Otherwise, we'll need to - # walk the attribute index to find the right type information. - # - if (ClusterType is not None and AttributeType is not None): - self.ClusterType = ClusterType - self.AttributeType = AttributeType - else: - if (Path is None): - raise ValueError("Path should have a valid value") - + ClusterType: Optional[Cluster] = None + AttributeType: Optional[ClusterAttributeDescriptor] = None + AttributeName: Optional[str] = None + Path: Optional[AttributePath] = None + ClusterId: Optional[int] = None + AttributeId: Optional[int] = None + + def __post_init__(self): + '''Only one of either ClusterType and AttributeType OR Path may be provided.''' + + if (self.ClusterType is not None and self.AttributeType is not None) and self.Path is not None: + raise ValueError("Only one of either ClusterType and AttributeType OR Path may be provided.") + if (self.ClusterType is None or self.AttributeType is None) and self.Path is None: + raise ValueError("Either ClusterType and AttributeType OR Path must be provided.") + + # if ClusterType and AttributeType were provided we can continue onwards to deriving the label. + # Otherwise, we'll need to walk the attribute index to find the right type information. + + # If Path is provided, derive ClusterType and AttributeType from it + if self.Path is not None: for cluster, attribute in _AttributeIndex: attributeType = _AttributeIndex[(cluster, attribute)][0] clusterType = _AttributeIndex[(cluster, attribute)][1] - if (clusterType.id == Path.ClusterId and attributeType.attribute_id == Path.AttributeId): + if clusterType.id == self.Path.ClusterId and attributeType.attribute_id == self.Path.AttributeId: self.ClusterType = clusterType self.AttributeType = attributeType break - if (self.ClusterType is None or self.AttributeType is None): - raise KeyError(f"No Schema found for Attribute {Path}") + if self.ClusterType is None or self.AttributeType is None: + raise KeyError(f"No Schema found for Attribute {self.Path}") # Next, let's figure out the label. for c_field in self.ClusterType.descriptor.Fields: - if (c_field.Tag != self.AttributeType.attribute_id): + if c_field.Tag != self.AttributeType.attribute_id: continue self.AttributeName = c_field.Label - if (self.AttributeName is None): - raise KeyError(f"Unable to resolve name for Attribute {Path}") + if self.AttributeName is None: + raise KeyError(f"Unable to resolve name for Attribute {self.Path}") - self.Path = Path self.ClusterId = self.ClusterType.id self.AttributeId = self.AttributeType.attribute_id @dataclass(frozen=True) class EventPath: - EndpointId: int = None - ClusterId: int = None - EventId: int = None - Urgent: int = None + EndpointId: Optional[int] = None + ClusterId: Optional[int] = None + EventId: Optional[int] = None + Urgent: Optional[int] = None @staticmethod - def from_cluster(EndpointId: int, Cluster: Cluster, EventId: int = None, Urgent: int = None) -> "EventPath": + def from_cluster(EndpointId: int, Cluster: Cluster, EventId: Optional[int] = None, Urgent: Optional[int] = None) -> "EventPath": if Cluster is None: raise ValueError("Cluster cannot be None") return EventPath(EndpointId=EndpointId, ClusterId=Cluster.id, EventId=EventId, Urgent=Urgent) @staticmethod - def from_event(EndpointId: int, Event: ClusterEvent, Urgent: int = None) -> "EventPath": + def from_event(EndpointId: int, Event: ClusterEvent, Urgent: Optional[int] = None) -> "EventPath": if Event is None: raise ValueError("Event cannot be None") return EventPath(EndpointId=EndpointId, ClusterId=Event.cluster_id, EventId=Event.event_id, Urgent=Urgent) @@ -173,23 +170,13 @@ def __str__(self) -> str: @dataclass class EventHeader: - EndpointId: int = None - ClusterId: int = None - EventId: int = None - EventNumber: int = None - Priority: EventPriority = None - Timestamp: int = None - TimestampType: EventTimestampType = None - - def __init__(self, EndpointId: int = None, ClusterId: int = None, - EventId: int = None, EventNumber=None, Priority=None, Timestamp=None, TimestampType=None): - self.EndpointId = EndpointId - self.ClusterId = ClusterId - self.EventId = EventId - self.EventNumber = EventNumber - self.Priority = Priority - self.Timestamp = Timestamp - self.TimestampType = TimestampType + EndpointId: Optional[int] = None + ClusterId: Optional[int] = None + EventId: Optional[int] = None + EventNumber: Optional[int] = None + Priority: Optional[EventPriority] = None + Timestamp: Optional[int] = None + TimestampType: Optional[EventTimestampType] = None def __str__(self) -> str: return (f"{self.EndpointId}/{self.ClusterId}/{self.EventId}/" @@ -247,7 +234,7 @@ class ValueDecodeFailure: ''' TLVValue: Any = None - Reason: Exception = None + Reason: Optional[Exception] = None @dataclass @@ -431,15 +418,16 @@ def handle_attribute_view(endpointId, clusterId, attributeId, attributeType): class SubscriptionTransaction: def __init__(self, transaction: AsyncReadTransaction, subscriptionId, devCtrl): - self._onResubscriptionAttemptedCb = DefaultResubscriptionAttemptedCallback - self._onAttributeChangeCb = DefaultAttributeChangeCallback - self._onEventChangeCb = DefaultEventChangeCallback - self._onErrorCb = DefaultErrorCallback + self._onResubscriptionAttemptedCb: Callable[[SubscriptionTransaction, + int, int], None] = DefaultResubscriptionAttemptedCallback + self._onAttributeChangeCb: Callable[[TypedAttributePath, SubscriptionTransaction], None] = DefaultAttributeChangeCallback + self._onEventChangeCb: Callable[[EventReadResult, SubscriptionTransaction], None] = DefaultEventChangeCallback + self._onErrorCb: Callable[[int, SubscriptionTransaction], None] = DefaultErrorCallback self._readTransaction = transaction self._subscriptionId = subscriptionId self._devCtrl = devCtrl self._isDone = False - self._onResubscriptionSucceededCb = None + self._onResubscriptionSucceededCb: Optional[Callable[[SubscriptionTransaction], None]] = None self._onResubscriptionSucceededCb_isAsync = False self._onResubscriptionAttemptedCb_isAsync = False @@ -647,10 +635,10 @@ def __init__(self, future: Future, eventLoop, devCtrl, returnClusterObject: bool self._event_loop = eventLoop self._future = future self._subscription_handler = None - self._events = [] + self._events: List[EventReadResult] = [] self._devCtrl = devCtrl self._cache = AttributeCache(returnClusterObject=returnClusterObject) - self._changedPathSet = set() + self._changedPathSet: Set[AttributePath] = set() self._pReadClient = None self._pReadCallback = None self._resultError: Optional[PyChipError] = None @@ -809,7 +797,7 @@ class AsyncWriteTransaction: def __init__(self, future: Future, eventLoop): self._event_loop = eventLoop self._future = future - self._resultData = [] + self._resultData: List[AttributeWriteResult] = [] self._resultError: Optional[PyChipError] = None def handleResponse(self, path: AttributePath, status: int): @@ -1014,9 +1002,9 @@ def WriteGroupAttributes(groupId: int, devCtrl: c_void_p, attributes: List[Attri def Read(future: Future, eventLoop, device, devCtrl, - attributes: List[AttributePath] = None, dataVersionFilters: List[DataVersionFilter] = None, - events: List[EventPath] = None, eventNumberFilter: Optional[int] = None, returnClusterObject: bool = True, - subscriptionParameters: SubscriptionParameters = None, + attributes: Optional[List[AttributePath]] = None, dataVersionFilters: Optional[List[DataVersionFilter]] = None, + events: Optional[List[EventPath]] = None, eventNumberFilter: Optional[int] = None, returnClusterObject: bool = True, + subscriptionParameters: Optional[SubscriptionParameters] = None, fabricFiltered: bool = True, keepSubscriptions: bool = False, autoResubscribe: bool = True) -> PyChipError: if (not attributes) and dataVersionFilters: raise ValueError( @@ -1132,9 +1120,9 @@ def Read(future: Future, eventLoop, device, devCtrl, def ReadAttributes(future: Future, eventLoop, device, devCtrl, - attributes: List[AttributePath], dataVersionFilters: List[DataVersionFilter] = None, + attributes: List[AttributePath], dataVersionFilters: Optional[List[DataVersionFilter]] = None, returnClusterObject: bool = True, - subscriptionParameters: SubscriptionParameters = None, fabricFiltered: bool = True) -> int: + subscriptionParameters: Optional[SubscriptionParameters] = None, fabricFiltered: bool = True) -> int: return Read(future=future, eventLoop=eventLoop, device=device, devCtrl=devCtrl, attributes=attributes, dataVersionFilters=dataVersionFilters, events=None, returnClusterObject=returnClusterObject, @@ -1143,7 +1131,7 @@ def ReadAttributes(future: Future, eventLoop, device, devCtrl, def ReadEvents(future: Future, eventLoop, device, devCtrl, events: List[EventPath], eventNumberFilter=None, returnClusterObject: bool = True, - subscriptionParameters: SubscriptionParameters = None, fabricFiltered: bool = True) -> int: + subscriptionParameters: Optional[SubscriptionParameters] = None, fabricFiltered: bool = True) -> int: return Read(future=future, eventLoop=eventLoop, device=device, devCtrl=devCtrl, attributes=None, dataVersionFilters=None, events=events, eventNumberFilter=eventNumberFilter, returnClusterObject=returnClusterObject, diff --git a/src/controller/python/chip/clusters/CHIPClusters.py b/src/controller/python/chip/clusters/CHIPClusters.py index cc0b5aaa65a4b2..5ab0ac895b659b 100644 --- a/src/controller/python/chip/clusters/CHIPClusters.py +++ b/src/controller/python/chip/clusters/CHIPClusters.py @@ -15549,7 +15549,7 @@ def __init__(self, chipstack): def GetClusterInfoById(self, cluster_id: int): data = ChipClusters._CLUSTER_ID_DICT.get(cluster_id, None) if not data: - raise exceptions.UnknownCluster(cluster_id) + raise exceptions.UnknownCluster(f"Cluster ID: {cluster_id}") return data def ListClusterInfo(self): diff --git a/src/controller/python/chip/clusters/ClusterObjects.py b/src/controller/python/chip/clusters/ClusterObjects.py index bf07544af9e888..ddafe87bf2c89d 100644 --- a/src/controller/python/chip/clusters/ClusterObjects.py +++ b/src/controller/python/chip/clusters/ClusterObjects.py @@ -22,7 +22,7 @@ from chip import ChipUtility, tlv from chip.clusters.Types import Nullable, NullValue -from dacite import from_dict +from dacite import from_dict # type: ignore def GetUnionUnderlyingType(typeToCheck, matchingType=None): @@ -52,8 +52,8 @@ def GetUnionUnderlyingType(typeToCheck, matchingType=None): @dataclass class ClusterObjectFieldDescriptor: Label: str = '' - Tag: int = None - Type: type = None + Tag: typing.Optional[int] = None + Type: type = type(None) def _PutSingleElementToTLV(self, tag, val, elementType, writer: tlv.TLVWriter, debugPath: str = '?'): if issubclass(elementType, ClusterObject): @@ -113,13 +113,13 @@ def PutFieldToTLV(self, tag, val, writer: tlv.TLVWriter, debugPath: str = '?'): class ClusterObjectDescriptor: Fields: List[ClusterObjectFieldDescriptor] - def GetFieldByTag(self, tag: int) -> ClusterObjectFieldDescriptor: + def GetFieldByTag(self, tag: int) -> typing.Optional[ClusterObjectFieldDescriptor]: for _field in self.Fields: if _field.Tag == tag: return _field return None - def GetFieldByLabel(self, label: str) -> ClusterObjectFieldDescriptor: + def GetFieldByLabel(self, label: str) -> typing.Optional[ClusterObjectFieldDescriptor]: for _field in self.Fields: if _field.Label == label: return _field @@ -140,7 +140,7 @@ def _ConvertNonArray(self, debugPath: str, elementType, value: Any) -> Any: return elementType.descriptor.TagDictToLabelDict(debugPath, value) def TagDictToLabelDict(self, debugPath: str, tlvData: Dict[int, Any]) -> Dict[str, Any]: - ret = {} + ret: typing.Dict[Any, Any] = {} for tag, value in tlvData.items(): descriptor = self.GetFieldByTag(tag) if not descriptor: @@ -156,7 +156,7 @@ def TagDictToLabelDict(self, debugPath: str, tlvData: Dict[int, Any]) -> Dict[st realType = GetUnionUnderlyingType(descriptor.Type) if (realType is None): raise ValueError( - f"Field {debugPath}.{self.Label} has no valid underlying data model type") + f"Field {debugPath}.{descriptor.Label} has no valid underlying data model type") valueType = realType else: @@ -175,7 +175,7 @@ def TagDictToLabelDict(self, debugPath: str, tlvData: Dict[int, Any]) -> Dict[st def TLVToDict(self, tlvBuf: bytes) -> Dict[str, Any]: tlvData = tlv.TLVReader(tlvBuf).get().get('Any', {}) - return self.TagDictToLabelDict([], tlvData) + return self.TagDictToLabelDict('', tlvData) def DictToTLVWithWriter(self, debugPath: str, tag, data: Mapping, writer: tlv.TLVWriter): writer.startStructure(tag) @@ -209,11 +209,11 @@ def descriptor(cls): # The below dictionaries will be filled dynamically # and are used for quick lookup/mapping from cluster/attribute id to the correct class -ALL_CLUSTERS = {} -ALL_ATTRIBUTES = {} +ALL_CLUSTERS: typing.Dict = {} +ALL_ATTRIBUTES: typing.Dict = {} # These need to be separate because there can be overlap in command ids for commands and responses. -ALL_ACCEPTED_COMMANDS = {} -ALL_GENERATED_COMMANDS = {} +ALL_ACCEPTED_COMMANDS: typing.Dict = {} +ALL_GENERATED_COMMANDS: typing.Dict = {} class ClusterCommand(ClusterObject): diff --git a/src/controller/python/chip/clusters/enum.py b/src/controller/python/chip/clusters/enum.py index ce545ebe88e727..73c41e6386cf1a 100644 --- a/src/controller/python/chip/clusters/enum.py +++ b/src/controller/python/chip/clusters/enum.py @@ -17,7 +17,7 @@ from threading import Lock -from aenum import IntEnum, extend_enum +from aenum import IntEnum, extend_enum # type: ignore # Flag on whether we should map unknown enum values to kUnknownEnumValue. _map_missing_enum_to_unknown_enum_value = True diff --git a/src/controller/python/chip/credentials/__init__.py b/src/controller/python/chip/credentials/__init__.py new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/src/controller/python/chip/crypto/__init__.py b/src/controller/python/chip/crypto/__init__.py new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/src/controller/python/chip/crypto/p256keypair.py b/src/controller/python/chip/crypto/p256keypair.py index 3267601b3b3e0f..30198eabee44ff 100644 --- a/src/controller/python/chip/crypto/p256keypair.py +++ b/src/controller/python/chip/crypto/p256keypair.py @@ -17,10 +17,21 @@ import abc import hashlib -from ctypes import CFUNCTYPE, POINTER, c_bool, c_char, c_size_t, c_uint8, c_uint32, c_void_p, memmove, py_object, string_at +from ctypes import (CFUNCTYPE, POINTER, _Pointer, c_bool, c_char, c_size_t, c_uint8, c_uint32, c_void_p, cast, memmove, py_object, + string_at) +from typing import TYPE_CHECKING from chip import native -from ecdsa import ECDH, NIST256p, SigningKey +from ecdsa import ECDH, NIST256p, SigningKey # type: ignore + +# WORKAROUND: Create a subscriptable pointer type (with square brackets) to ensure compliance of type hinting with ctypes +if not TYPE_CHECKING: + class pointer_fix: + @classmethod + def __class_getitem__(cls, item): + return POINTER(item) + _Pointer = pointer_fix + _pychip_P256Keypair_ECDSA_sign_msg_func = CFUNCTYPE( c_bool, py_object, POINTER(c_uint8), c_size_t, POINTER(c_uint8), POINTER(c_size_t)) @@ -31,18 +42,18 @@ @ _pychip_P256Keypair_ECDSA_sign_msg_func -def _pychip_ECDSA_sign_msg(self_: 'P256Keypair', message_buf: POINTER(c_uint8), message_size: int, signature_buf: POINTER(c_uint8), signature_buf_size: POINTER(c_size_t)) -> bool: +def _pychip_ECDSA_sign_msg(self_: 'P256Keypair', message_buf: _Pointer[c_uint8], message_size: int, signature_buf: _Pointer[c_uint8], signature_buf_size: _Pointer[c_size_t]) -> bool: res = self_.ECDSA_sign_msg(string_at(message_buf, message_size)[:]) memmove(signature_buf, res, len(res)) - signature_buf_size.content = len(res) + signature_buf_size.contents.value = len(res) return True @ _pychip_P256Keypair_ECDH_derive_secret_func -def _pychip_ECDH_derive_secret(self_: 'P256Keypair', remote_pubkey: POINTER(c_uint8), out_secret_buf: POINTER(c_uint8), out_secret_buf_size: POINTER(c_uint32)) -> bool: +def _pychip_ECDH_derive_secret(self_: 'P256Keypair', remote_pubkey: _Pointer[c_uint8], out_secret_buf: _Pointer[c_uint8], out_secret_buf_size: _Pointer[c_uint32]) -> bool: res = self_.ECDH_derive_secret(string_at(remote_pubkey, P256_PUBLIC_KEY_LENGTH)[:]) memmove(out_secret_buf, res, len(res)) - out_secret_buf_size.content = len(res) + out_secret_buf_size.contents.value = len(res) return True @@ -95,7 +106,8 @@ def UpdatePublicKey(self) -> None: generates a new keypair. ''' handle = native.GetLibraryHandle() - handle.pychip_P256Keypair_UpdatePubkey(c_void_p(self.native_object), self.public_key, len(self.public_key)).raise_on_error() + handle.pychip_P256Keypair_UpdatePubkey(cast(self._native_obj, c_void_p), + self.public_key, len(self.public_key)).raise_on_error() @abc.abstractproperty def public_key(self) -> bytes: diff --git a/src/controller/python/chip/interaction_model/delegate.py b/src/controller/python/chip/interaction_model/delegate.py index 4741e5f2f74482..201abe4bc7b5f9 100644 --- a/src/controller/python/chip/interaction_model/delegate.py +++ b/src/controller/python/chip/interaction_model/delegate.py @@ -16,14 +16,14 @@ import ctypes import threading -import typing from ctypes import CFUNCTYPE, POINTER, c_uint8, c_uint32, c_uint64, c_void_p from dataclasses import dataclass +from typing import Any, Dict, Optional import chip.exceptions import chip.native import chip.tlv -from construct import Int8ul, Int16ul, Int32ul, Int64ul, Struct +from construct import Int8ul, Int16ul, Int32ul, Int64ul, Struct # type: ignore # The type should match CommandStatus in interaction_model/Delegate.h # CommandStatus should not contain padding @@ -101,14 +101,14 @@ class EventPath: class AttributeReadResult: path: AttributePath status: int - value: 'typing.Any' + value: 'Any' dataVersion: int @dataclass class EventReadResult: path: EventPath - value: 'typing.Any' + value: 'Any' @dataclass @@ -119,12 +119,12 @@ class AttributeWriteResult: @dataclass class SessionParameters: - sessionIdleInterval: typing.Optional[int] - sessionActiveInterval: typing.Optional[int] - sessionActiveThreshold: typing.Optional[int] - dataModelRevision: typing.Optional[int] - interactionModelRevision: typing.Optional[int] - specficiationVersion: typing.Optional[int] + sessionIdleInterval: Optional[int] + sessionActiveInterval: Optional[int] + sessionActiveThreshold: Optional[int] + dataModelRevision: Optional[int] + interactionModelRevision: Optional[int] + specficiationVersion: Optional[int] maxPathsPerInvoke: int @@ -244,15 +244,15 @@ class TestOnlyPyOnDoneInfo(ctypes.Structure): _OnCommandResponseFunct = CFUNCTYPE(None, c_uint64, c_uint32) _OnWriteResponseStatusFunct = CFUNCTYPE(None, c_void_p, c_uint32) -_commandStatusDict = dict() -_commandIndexStatusDict = dict() +_commandStatusDict: Dict[int, Any] = dict() +_commandIndexStatusDict: Dict[int, Any] = dict() _commandStatusLock = threading.RLock() _commandStatusCV = threading.Condition(_commandStatusLock) -_attributeDict = dict() +_attributeDict: Dict[int, Any] = dict() _attributeDictLock = threading.RLock() -_writeStatusDict = dict() +_writeStatusDict: Dict[int, Any] = dict() _writeStatusDictLock = threading.RLock() # A placeholder commandHandle, will be removed once we decouple CommandSender with CHIPClusters diff --git a/src/controller/python/chip/native/__init__.py b/src/controller/python/chip/native/__init__.py index 9ee94c61ddaa7f..518339017b587c 100644 --- a/src/controller/python/chip/native/__init__.py +++ b/src/controller/python/chip/native/__init__.py @@ -23,7 +23,7 @@ from dataclasses import dataclass import chip.exceptions -import construct +import construct # type: ignore class Library(enum.Enum): @@ -84,7 +84,9 @@ class PyChipError(ctypes.Structure): def raise_on_error(self) -> None: if self.code != 0: - raise self.to_exception() + exception = self.to_exception() + if exception is not None: # Ensure exception is not None to avoid mypy error and only raise valid exceptions + raise exception @property def is_success(self) -> bool: @@ -103,20 +105,21 @@ def value(self) -> int: return (self.code) & 0xFFFFFF @property - def sdk_part(self) -> ErrorSDKPart: + def sdk_part(self) -> typing.Optional[ErrorSDKPart]: if not self.is_sdk_error: return None return ErrorSDKPart((self.code >> 8) & 0x07) @property - def sdk_code(self) -> int: + def sdk_code(self) -> typing.Optional[int]: if not self.is_sdk_error: return None return self.code & 0xFF - def to_exception(self) -> typing.Union[None, chip.exceptions.ChipStackError]: + def to_exception(self) -> typing.Optional[chip.exceptions.ChipStackError]: if not self.is_success: return chip.exceptions.ChipStackError.from_chip_error(self) + return None def __str__(self): buf = ctypes.create_string_buffer(256) @@ -204,14 +207,14 @@ def Set(self, methodName: str, resultType, argumentTypes: list): @dataclass class _Handle: - dll: ctypes.CDLL = None + dll: ctypes.CDLL initialized: bool = False _nativeLibraryHandles: typing.Dict[Library, _Handle] = {} -def _GetLibraryHandle(lib: Library, expectAlreadyInitialized: bool) -> ctypes.CDLL: +def _GetLibraryHandle(lib: Library, expectAlreadyInitialized: bool) -> _Handle: """Get a memoized _Handle to the chip native code dll.""" global _nativeLibraryHandles @@ -236,7 +239,7 @@ def _GetLibraryHandle(lib: Library, expectAlreadyInitialized: bool) -> ctypes.CD return handle -def Init(bluetoothAdapter: int = None): +def Init(bluetoothAdapter: typing.Optional[int] = None): CommonStackParams = construct.Struct( "BluetoothAdapterId" / construct.Int32ul, ) diff --git a/src/controller/python/chip/tlv/tlvlist.py b/src/controller/python/chip/tlv/tlvlist.py index a9afaa3e2bb26e..ffeb324968c50c 100644 --- a/src/controller/python/chip/tlv/tlvlist.py +++ b/src/controller/python/chip/tlv/tlvlist.py @@ -169,7 +169,7 @@ def __rich_repr__(self): def __iter__(self) -> """TLVList.Iterator""": return TLVList.Iterator(iter(self._data)) - def __eq__(self, rhs: "TLVList") -> bool: + def __eq__(self, rhs: object) -> bool: if not isinstance(rhs, TLVList): return False return self._data == rhs._data diff --git a/src/controller/python/templates/python-CHIPClusters-py.zapt b/src/controller/python/templates/python-CHIPClusters-py.zapt index 06af555401f199..284cd650a0a772 100644 --- a/src/controller/python/templates/python-CHIPClusters-py.zapt +++ b/src/controller/python/templates/python-CHIPClusters-py.zapt @@ -70,7 +70,7 @@ class ChipClusters: def GetClusterInfoById(self, cluster_id: int): data = ChipClusters._CLUSTER_ID_DICT.get(cluster_id, None) if not data: - raise exceptions.UnknownCluster(cluster_id) + raise exceptions.UnknownCluster(f"Cluster ID: {cluster_id}") return data def ListClusterInfo(self): diff --git a/src/darwin/Framework/CHIPTests/MTRClusterNamesTests.m b/src/darwin/Framework/CHIPTests/MTRClusterNamesTests.m new file mode 100644 index 00000000000000..a609e191ef9775 --- /dev/null +++ b/src/darwin/Framework/CHIPTests/MTRClusterNamesTests.m @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2024 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. + */ + +#import +#import + +@interface MTRClusterNamesTests : XCTestCase + +@end + +@implementation MTRClusterNamesTests + +- (void)testClusterNames +{ + XCTAssertEqualObjects(MTRClusterNameForID(MTRClusterIDTypeOnOffID), @"OnOff"); + XCTAssertEqualObjects(MTRClusterNameForID(0x0101), @"DoorLock"); + XCTAssertEqualObjects(MTRClusterNameForID(12345678), @""); +} + +- (void)testAttributeNames +{ + XCTAssertEqualObjects(MTRAttributeNameForID(MTRClusterIDTypeOnOffID, MTRAttributeIDTypeClusterOnOffAttributeOnOffID), @"OnOff"); + XCTAssertEqualObjects(MTRAttributeNameForID(MTRClusterIDTypeOnOffID, MTRAttributeIDTypeClusterOnOffAttributeOnTimeID), @"OnTime"); + XCTAssertEqualObjects(MTRAttributeNameForID(12345678, 0), @""); + XCTAssertEqualObjects(MTRAttributeNameForID(MTRClusterIDTypeOnOffID, 12345678), @""); +} + +- (void)testEventNames +{ + XCTAssertEqualObjects(MTREventNameForID(MTRClusterIDTypeAccessControlID, MTREventIDTypeClusterAccessControlEventAccessControlEntryChangedID), @"AccessControlEntryChanged"); + XCTAssertEqualObjects(MTREventNameForID(12345678, 0), @""); + XCTAssertEqualObjects(MTREventNameForID(MTRClusterIDTypeAccessControlID, 12345678), @""); +} + +@end diff --git a/src/darwin/Framework/Matter.xcodeproj/project.pbxproj b/src/darwin/Framework/Matter.xcodeproj/project.pbxproj index b23605ce2eaa4e..055a6c9efbcc3e 100644 --- a/src/darwin/Framework/Matter.xcodeproj/project.pbxproj +++ b/src/darwin/Framework/Matter.xcodeproj/project.pbxproj @@ -182,6 +182,7 @@ 516415FD2B6ACA8300D5CE11 /* MTRServerAccessControl.h in Headers */ = {isa = PBXBuildFile; fileRef = 516415FB2B6ACA8300D5CE11 /* MTRServerAccessControl.h */; }; 516415FF2B6B132200D5CE11 /* DataModelHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 516415FE2B6B132200D5CE11 /* DataModelHandler.cpp */; }; 516416012B6B483C00D5CE11 /* MTRIMDispatch.mm in Sources */ = {isa = PBXBuildFile; fileRef = 516416002B6B483C00D5CE11 /* MTRIMDispatch.mm */; }; + 5165A4B32C5AB978002B9799 /* MTRClusterNamesTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5165A4B22C5AB978002B9799 /* MTRClusterNamesTests.m */; }; 51669AF02913204400F4AA36 /* MTRBackwardsCompatTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 51669AEF2913204400F4AA36 /* MTRBackwardsCompatTests.m */; }; 5173A47529C0E2ED00F67F48 /* MTRFabricInfo_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 5173A47229C0E2ED00F67F48 /* MTRFabricInfo_Internal.h */; }; 5173A47629C0E2ED00F67F48 /* MTRFabricInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5173A47329C0E2ED00F67F48 /* MTRFabricInfo.mm */; }; @@ -596,6 +597,7 @@ 516415FB2B6ACA8300D5CE11 /* MTRServerAccessControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRServerAccessControl.h; sourceTree = ""; }; 516415FE2B6B132200D5CE11 /* DataModelHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DataModelHandler.cpp; path = util/DataModelHandler.cpp; sourceTree = ""; }; 516416002B6B483C00D5CE11 /* MTRIMDispatch.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRIMDispatch.mm; sourceTree = ""; }; + 5165A4B22C5AB978002B9799 /* MTRClusterNamesTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MTRClusterNamesTests.m; sourceTree = ""; }; 51669AEF2913204400F4AA36 /* MTRBackwardsCompatTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MTRBackwardsCompatTests.m; sourceTree = ""; }; 5173A47229C0E2ED00F67F48 /* MTRFabricInfo_Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRFabricInfo_Internal.h; sourceTree = ""; }; 5173A47329C0E2ED00F67F48 /* MTRFabricInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRFabricInfo.mm; sourceTree = ""; }; @@ -1407,6 +1409,7 @@ 3DFCB3282966684500332B35 /* MTRCertificateInfoTests.m */, 517BF3F2282B62CB00A8B7DB /* MTRCertificateTests.m */, 51339B1E2A0DA64D00C798C1 /* MTRCertificateValidityTests.m */, + 5165A4B22C5AB978002B9799 /* MTRClusterNamesTests.m */, 1EE0805C2A448756008A03C2 /* MTRCommissionableBrowserTests.m */, 518D3F842AA14006008E0007 /* MTRControllerAdvertisingTests.m */, 99C65E0F267282F1003402F6 /* MTRControllerTests.m */, @@ -2050,6 +2053,7 @@ 51E24E73274E0DAC007CCF6E /* MTRErrorTestUtils.mm in Sources */, 519498322A25581C00B3BABE /* MTRSetupPayloadInitializationTests.m in Sources */, 51A2F1322A00402A00F03298 /* MTRDataValueParserTests.m in Sources */, + 5165A4B32C5AB978002B9799 /* MTRClusterNamesTests.m in Sources */, 51E95DF82A78110900A434F0 /* MTRPerControllerStorageTests.m in Sources */, 51D9CB0B2BA37DCE0049D6DB /* MTRDSTOffsetTests.m in Sources */, ); diff --git a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp index ca6df3d1c72e99..aaabdae8055e4b 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp @@ -18438,448 +18438,6 @@ Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint16_t valu } // namespace ExpiringUserTimeout -namespace AliroReaderVerificationKey { - -Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - if (value.IsNull()) - { - ChipLogError(Zcl, "Null Nullable passed to DoorLock::AliroReaderVerificationKey::Get"); - return Protocols::InteractionModel::Status::Failure; - } - - uint8_t zclString[65 + 1]; - Protocols::InteractionModel::Status status = - emberAfReadAttribute(endpoint, Clusters::DoorLock::Id, Id, zclString, sizeof(zclString)); - VerifyOrReturnError(Protocols::InteractionModel::Status::Success == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) - { - value.SetNull(); - return Protocols::InteractionModel::Status::Success; - } - auto & span = value.Value(); - - VerifyOrReturnError(span.size() == 65, Protocols::InteractionModel::Status::InvalidDataType); - memcpy(span.data(), &zclString[1], 65); - span.reduce_size(length); - return status; -} - -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::ByteSpan value, MarkAttributeDirty markDirty) -{ - - static_assert(65 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 65, Protocols::InteractionModel::Status::ConstraintError); - uint8_t zclString[65 + 1]; - auto length = static_cast(value.size()); - Encoding::Put8(zclString, length); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::DoorLock::Id, Id, zclString, ZCL_OCTET_STRING_ATTRIBUTE_TYPE, markDirty); -} - -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::ByteSpan value) -{ - - static_assert(65 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 65, Protocols::InteractionModel::Status::ConstraintError); - uint8_t zclString[65 + 1]; - auto length = static_cast(value.size()); - Encoding::Put8(zclString, length); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::DoorLock::Id, Id, zclString, ZCL_OCTET_STRING_ATTRIBUTE_TYPE); -} - -Protocols::InteractionModel::Status SetNull(chip::EndpointId endpoint, MarkAttributeDirty markDirty) -{ - uint8_t zclString[1] = { 0xFF }; - return emberAfWriteAttribute(endpoint, Clusters::DoorLock::Id, Id, zclString, ZCL_OCTET_STRING_ATTRIBUTE_TYPE, markDirty); -} - -Protocols::InteractionModel::Status SetNull(chip::EndpointId endpoint) -{ - uint8_t zclString[1] = { 0xFF }; - return emberAfWriteAttribute(endpoint, Clusters::DoorLock::Id, Id, zclString, ZCL_OCTET_STRING_ATTRIBUTE_TYPE); -} - -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value, - MarkAttributeDirty markDirty) -{ - if (value.IsNull()) - { - return SetNull(endpoint, markDirty); - } - - return Set(endpoint, value.Value(), markDirty); -} - -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace AliroReaderVerificationKey - -namespace AliroReaderGroupIdentifier { - -Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - if (value.IsNull()) - { - ChipLogError(Zcl, "Null Nullable passed to DoorLock::AliroReaderGroupIdentifier::Get"); - return Protocols::InteractionModel::Status::Failure; - } - - uint8_t zclString[16 + 1]; - Protocols::InteractionModel::Status status = - emberAfReadAttribute(endpoint, Clusters::DoorLock::Id, Id, zclString, sizeof(zclString)); - VerifyOrReturnError(Protocols::InteractionModel::Status::Success == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) - { - value.SetNull(); - return Protocols::InteractionModel::Status::Success; - } - auto & span = value.Value(); - - VerifyOrReturnError(span.size() == 16, Protocols::InteractionModel::Status::InvalidDataType); - memcpy(span.data(), &zclString[1], 16); - span.reduce_size(length); - return status; -} - -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::ByteSpan value, MarkAttributeDirty markDirty) -{ - - static_assert(16 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 16, Protocols::InteractionModel::Status::ConstraintError); - uint8_t zclString[16 + 1]; - auto length = static_cast(value.size()); - Encoding::Put8(zclString, length); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::DoorLock::Id, Id, zclString, ZCL_OCTET_STRING_ATTRIBUTE_TYPE, markDirty); -} - -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::ByteSpan value) -{ - - static_assert(16 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 16, Protocols::InteractionModel::Status::ConstraintError); - uint8_t zclString[16 + 1]; - auto length = static_cast(value.size()); - Encoding::Put8(zclString, length); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::DoorLock::Id, Id, zclString, ZCL_OCTET_STRING_ATTRIBUTE_TYPE); -} - -Protocols::InteractionModel::Status SetNull(chip::EndpointId endpoint, MarkAttributeDirty markDirty) -{ - uint8_t zclString[1] = { 0xFF }; - return emberAfWriteAttribute(endpoint, Clusters::DoorLock::Id, Id, zclString, ZCL_OCTET_STRING_ATTRIBUTE_TYPE, markDirty); -} - -Protocols::InteractionModel::Status SetNull(chip::EndpointId endpoint) -{ - uint8_t zclString[1] = { 0xFF }; - return emberAfWriteAttribute(endpoint, Clusters::DoorLock::Id, Id, zclString, ZCL_OCTET_STRING_ATTRIBUTE_TYPE); -} - -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value, - MarkAttributeDirty markDirty) -{ - if (value.IsNull()) - { - return SetNull(endpoint, markDirty); - } - - return Set(endpoint, value.Value(), markDirty); -} - -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace AliroReaderGroupIdentifier - -namespace AliroReaderGroupSubIdentifier { - -Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, chip::MutableByteSpan & value) -{ - uint8_t zclString[16 + 1]; - Protocols::InteractionModel::Status status = - emberAfReadAttribute(endpoint, Clusters::DoorLock::Id, Id, zclString, sizeof(zclString)); - VerifyOrReturnError(Protocols::InteractionModel::Status::Success == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) - { - return Protocols::InteractionModel::Status::ConstraintError; - } - - VerifyOrReturnError(value.size() == 16, Protocols::InteractionModel::Status::InvalidDataType); - memcpy(value.data(), &zclString[1], 16); - value.reduce_size(length); - return status; -} - -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::ByteSpan value, MarkAttributeDirty markDirty) -{ - - static_assert(16 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 16, Protocols::InteractionModel::Status::ConstraintError); - uint8_t zclString[16 + 1]; - auto length = static_cast(value.size()); - Encoding::Put8(zclString, length); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::DoorLock::Id, Id, zclString, ZCL_OCTET_STRING_ATTRIBUTE_TYPE, markDirty); -} - -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::ByteSpan value) -{ - - static_assert(16 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 16, Protocols::InteractionModel::Status::ConstraintError); - uint8_t zclString[16 + 1]; - auto length = static_cast(value.size()); - Encoding::Put8(zclString, length); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::DoorLock::Id, Id, zclString, ZCL_OCTET_STRING_ATTRIBUTE_TYPE); -} - -} // namespace AliroReaderGroupSubIdentifier - -namespace AliroGroupResolvingKey { - -Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, DataModel::Nullable & value) -{ - if (value.IsNull()) - { - ChipLogError(Zcl, "Null Nullable passed to DoorLock::AliroGroupResolvingKey::Get"); - return Protocols::InteractionModel::Status::Failure; - } - - uint8_t zclString[16 + 1]; - Protocols::InteractionModel::Status status = - emberAfReadAttribute(endpoint, Clusters::DoorLock::Id, Id, zclString, sizeof(zclString)); - VerifyOrReturnError(Protocols::InteractionModel::Status::Success == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) - { - value.SetNull(); - return Protocols::InteractionModel::Status::Success; - } - auto & span = value.Value(); - - VerifyOrReturnError(span.size() == 16, Protocols::InteractionModel::Status::InvalidDataType); - memcpy(span.data(), &zclString[1], 16); - span.reduce_size(length); - return status; -} - -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::ByteSpan value, MarkAttributeDirty markDirty) -{ - - static_assert(16 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 16, Protocols::InteractionModel::Status::ConstraintError); - uint8_t zclString[16 + 1]; - auto length = static_cast(value.size()); - Encoding::Put8(zclString, length); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::DoorLock::Id, Id, zclString, ZCL_OCTET_STRING_ATTRIBUTE_TYPE, markDirty); -} - -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::ByteSpan value) -{ - - static_assert(16 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 16, Protocols::InteractionModel::Status::ConstraintError); - uint8_t zclString[16 + 1]; - auto length = static_cast(value.size()); - Encoding::Put8(zclString, length); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::DoorLock::Id, Id, zclString, ZCL_OCTET_STRING_ATTRIBUTE_TYPE); -} - -Protocols::InteractionModel::Status SetNull(chip::EndpointId endpoint, MarkAttributeDirty markDirty) -{ - uint8_t zclString[1] = { 0xFF }; - return emberAfWriteAttribute(endpoint, Clusters::DoorLock::Id, Id, zclString, ZCL_OCTET_STRING_ATTRIBUTE_TYPE, markDirty); -} - -Protocols::InteractionModel::Status SetNull(chip::EndpointId endpoint) -{ - uint8_t zclString[1] = { 0xFF }; - return emberAfWriteAttribute(endpoint, Clusters::DoorLock::Id, Id, zclString, ZCL_OCTET_STRING_ATTRIBUTE_TYPE); -} - -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value, - MarkAttributeDirty markDirty) -{ - if (value.IsNull()) - { - return SetNull(endpoint, markDirty); - } - - return Set(endpoint, value.Value(), markDirty); -} - -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) -{ - if (value.IsNull()) - { - return SetNull(endpoint); - } - - return Set(endpoint, value.Value()); -} - -} // namespace AliroGroupResolvingKey - -namespace AliroBLEAdvertisingVersion { - -Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint8_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - Protocols::InteractionModel::Status status = emberAfReadAttribute(endpoint, Clusters::DoorLock::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(Protocols::InteractionModel::Status::Success == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return Protocols::InteractionModel::Status::ConstraintError; - } - *value = Traits::StorageToWorking(temp); - return status; -} - -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value, MarkAttributeDirty markDirty) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return Protocols::InteractionModel::Status::ConstraintError; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::DoorLock::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE, markDirty); -} - -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return Protocols::InteractionModel::Status::ConstraintError; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::DoorLock::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); -} - -} // namespace AliroBLEAdvertisingVersion - -namespace NumberOfAliroCredentialIssuerKeysSupported { - -Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint16_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - Protocols::InteractionModel::Status status = emberAfReadAttribute(endpoint, Clusters::DoorLock::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(Protocols::InteractionModel::Status::Success == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return Protocols::InteractionModel::Status::ConstraintError; - } - *value = Traits::StorageToWorking(temp); - return status; -} - -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint16_t value, MarkAttributeDirty markDirty) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return Protocols::InteractionModel::Status::ConstraintError; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::DoorLock::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE, markDirty); -} - -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint16_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return Protocols::InteractionModel::Status::ConstraintError; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::DoorLock::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -} // namespace NumberOfAliroCredentialIssuerKeysSupported - -namespace NumberOfAliroEndpointKeysSupported { - -Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint16_t * value) -{ - using Traits = NumericAttributeTraits; - Traits::StorageType temp; - uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); - Protocols::InteractionModel::Status status = emberAfReadAttribute(endpoint, Clusters::DoorLock::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(Protocols::InteractionModel::Status::Success == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return Protocols::InteractionModel::Status::ConstraintError; - } - *value = Traits::StorageToWorking(temp); - return status; -} - -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint16_t value, MarkAttributeDirty markDirty) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return Protocols::InteractionModel::Status::ConstraintError; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::DoorLock::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE, markDirty); -} - -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint16_t value) -{ - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) - { - return Protocols::InteractionModel::Status::ConstraintError; - } - Traits::StorageType storageValue; - Traits::WorkingToStorage(value, storageValue); - uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteAttribute(endpoint, Clusters::DoorLock::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -} // namespace NumberOfAliroEndpointKeysSupported - namespace FeatureMap { Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint32_t * value) diff --git a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h index ea344fcc49b7cd..85a8aabd8791cc 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h +++ b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h @@ -2994,66 +2994,6 @@ Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint16_t valu Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint16_t value, MarkAttributeDirty markDirty); } // namespace ExpiringUserTimeout -namespace AliroReaderVerificationKey { -Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, - DataModel::Nullable & value); // octet_string -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::ByteSpan value); -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::ByteSpan value, MarkAttributeDirty markDirty); -Protocols::InteractionModel::Status SetNull(chip::EndpointId endpoint); -Protocols::InteractionModel::Status SetNull(chip::EndpointId endpoint, MarkAttributeDirty markDirty); -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value, - MarkAttributeDirty markDirty); -} // namespace AliroReaderVerificationKey - -namespace AliroReaderGroupIdentifier { -Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, - DataModel::Nullable & value); // octet_string -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::ByteSpan value); -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::ByteSpan value, MarkAttributeDirty markDirty); -Protocols::InteractionModel::Status SetNull(chip::EndpointId endpoint); -Protocols::InteractionModel::Status SetNull(chip::EndpointId endpoint, MarkAttributeDirty markDirty); -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value, - MarkAttributeDirty markDirty); -} // namespace AliroReaderGroupIdentifier - -namespace AliroReaderGroupSubIdentifier { -Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, chip::MutableByteSpan & value); // octet_string -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::ByteSpan value); -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::ByteSpan value, MarkAttributeDirty markDirty); -} // namespace AliroReaderGroupSubIdentifier - -namespace AliroGroupResolvingKey { -Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, - DataModel::Nullable & value); // octet_string -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::ByteSpan value); -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::ByteSpan value, MarkAttributeDirty markDirty); -Protocols::InteractionModel::Status SetNull(chip::EndpointId endpoint); -Protocols::InteractionModel::Status SetNull(chip::EndpointId endpoint, MarkAttributeDirty markDirty); -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value, - MarkAttributeDirty markDirty); -} // namespace AliroGroupResolvingKey - -namespace AliroBLEAdvertisingVersion { -Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint8_t * value); // int8u -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value); -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value, MarkAttributeDirty markDirty); -} // namespace AliroBLEAdvertisingVersion - -namespace NumberOfAliroCredentialIssuerKeysSupported { -Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint16_t * value); // int16u -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint16_t value); -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint16_t value, MarkAttributeDirty markDirty); -} // namespace NumberOfAliroCredentialIssuerKeysSupported - -namespace NumberOfAliroEndpointKeysSupported { -Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint16_t * value); // int16u -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint16_t value); -Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint16_t value, MarkAttributeDirty markDirty); -} // namespace NumberOfAliroEndpointKeysSupported - namespace FeatureMap { Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint32_t * value); // bitmap32 Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint32_t value);