diff --git a/examples/all-clusters-app/all-clusters-common/gen/IMClusterCommandHandler.cpp b/examples/all-clusters-app/all-clusters-common/gen/IMClusterCommandHandler.cpp index c4b9adcd04513b..d4ca60f1c9d5d3 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/IMClusterCommandHandler.cpp +++ b/examples/all-clusters-app/all-clusters-common/gen/IMClusterCommandHandler.cpp @@ -7023,6 +7023,12 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En { switch (aCommandId) { + case ZCL_REMOVE_ALL_FABRICS_COMMAND_ID: { + + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfOperationalCredentialsClusterRemoveAllFabricsCallback(apCommandObj); + break; + } case ZCL_REMOVE_FABRIC_COMMAND_ID: { // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. diff --git a/examples/all-clusters-app/all-clusters-common/gen/call-command-handler.cpp b/examples/all-clusters-app/all-clusters-common/gen/call-command-handler.cpp index 5aeb7e7274b8fe..d680f1183e8d5c 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/call-command-handler.cpp +++ b/examples/all-clusters-app/all-clusters-common/gen/call-command-handler.cpp @@ -2310,6 +2310,10 @@ EmberAfStatus emberAfOperationalCredentialsClusterServerCommandParse(EmberAfClus { switch (cmd->commandId) { + case ZCL_REMOVE_ALL_FABRICS_COMMAND_ID: { + wasHandled = emberAfOperationalCredentialsClusterRemoveAllFabricsCallback(nullptr); + break; + } case ZCL_REMOVE_FABRIC_COMMAND_ID: { uint16_t payloadOffset = cmd->payloadStartIndex; chip::FabricId FabricId; diff --git a/examples/all-clusters-app/all-clusters-common/gen/callback.h b/examples/all-clusters-app/all-clusters-common/gen/callback.h index f9b47114ea5a5a..732b370cdc11a9 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/callback.h +++ b/examples/all-clusters-app/all-clusters-common/gen/callback.h @@ -2718,6 +2718,12 @@ bool emberAfOnOffClusterOnCallback(chip::app::Command * commandObj); bool emberAfOnOffClusterToggleCallback(chip::app::Command * commandObj); +/** + * @brief Operational Credentials Cluster RemoveAllFabrics Command callback + */ + +bool emberAfOperationalCredentialsClusterRemoveAllFabricsCallback(chip::app::Command * commandObj); + /** * @brief Operational Credentials Cluster RemoveFabric Command callback * @param fabricId diff --git a/examples/all-clusters-app/all-clusters-common/gen/client-command-macro.h b/examples/all-clusters-app/all-clusters-common/gen/client-command-macro.h index 1ac6d9550498d1..8f3a01b8e721b1 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/client-command-macro.h +++ b/examples/all-clusters-app/all-clusters-common/gen/client-command-macro.h @@ -2217,6 +2217,15 @@ \ ZCL_SET_FABRIC_RESPONSE_COMMAND_ID, "u", FabricId); +/** @brief Command description for RemoveAllFabrics + * + * Command: RemoveAllFabrics + */ +#define emberAfFillCommandOperational \ + CredentialsClusterRemoveAllFabrics() emberAfFillExternalBuffer(mask, \ + \ + ZCL_REMOVE_ALL_FABRICS_COMMAND_ID, "", ); + /** @brief Command description for UpdateFabricLabel * * Command: UpdateFabricLabel diff --git a/examples/all-clusters-app/all-clusters-common/gen/command-id.h b/examples/all-clusters-app/all-clusters-common/gen/command-id.h index cbda27333416da..eadb6aa0fa4411 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/command-id.h +++ b/examples/all-clusters-app/all-clusters-common/gen/command-id.h @@ -268,6 +268,7 @@ // Commands for cluster: Operational Credentials #define ZCL_SET_FABRIC_COMMAND_ID (0x00) #define ZCL_SET_FABRIC_RESPONSE_COMMAND_ID (0x01) +#define ZCL_REMOVE_ALL_FABRICS_COMMAND_ID (0x02) #define ZCL_UPDATE_FABRIC_LABEL_COMMAND_ID (0x09) #define ZCL_REMOVE_FABRIC_COMMAND_ID (0x0A) diff --git a/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h b/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h index 8b9ac541cb8b32..cc6c54c7b52b87 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h +++ b/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h @@ -1263,7 +1263,7 @@ // Array of EmberAfCommandMetadata structs. #define ZAP_COMMAND_MASK(mask) COMMAND_MASK_##mask -#define EMBER_AF_GENERATED_COMMAND_COUNT (140) +#define EMBER_AF_GENERATED_COMMAND_COUNT (141) #define GENERATED_COMMANDS \ { \ \ @@ -1304,6 +1304,7 @@ /* Endpoint: 0, Cluster: Operational Credentials (server) */ \ { 0x003E, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* SetFabric */ \ { 0x003E, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* SetFabricResponse */ \ + { 0x003E, 0x02, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* RemoveAllFabrics */ \ { 0x003E, 0x09, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* UpdateFabricLabel */ \ { 0x003E, 0x0A, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* RemoveFabric */ \ \ diff --git a/examples/bridge-app/bridge-common/gen/client-command-macro.h b/examples/bridge-app/bridge-common/gen/client-command-macro.h index 1ac6d9550498d1..8f3a01b8e721b1 100644 --- a/examples/bridge-app/bridge-common/gen/client-command-macro.h +++ b/examples/bridge-app/bridge-common/gen/client-command-macro.h @@ -2217,6 +2217,15 @@ \ ZCL_SET_FABRIC_RESPONSE_COMMAND_ID, "u", FabricId); +/** @brief Command description for RemoveAllFabrics + * + * Command: RemoveAllFabrics + */ +#define emberAfFillCommandOperational \ + CredentialsClusterRemoveAllFabrics() emberAfFillExternalBuffer(mask, \ + \ + ZCL_REMOVE_ALL_FABRICS_COMMAND_ID, "", ); + /** @brief Command description for UpdateFabricLabel * * Command: UpdateFabricLabel diff --git a/examples/bridge-app/bridge-common/gen/command-id.h b/examples/bridge-app/bridge-common/gen/command-id.h index cbda27333416da..eadb6aa0fa4411 100644 --- a/examples/bridge-app/bridge-common/gen/command-id.h +++ b/examples/bridge-app/bridge-common/gen/command-id.h @@ -268,6 +268,7 @@ // Commands for cluster: Operational Credentials #define ZCL_SET_FABRIC_COMMAND_ID (0x00) #define ZCL_SET_FABRIC_RESPONSE_COMMAND_ID (0x01) +#define ZCL_REMOVE_ALL_FABRICS_COMMAND_ID (0x02) #define ZCL_UPDATE_FABRIC_LABEL_COMMAND_ID (0x09) #define ZCL_REMOVE_FABRIC_COMMAND_ID (0x0A) diff --git a/examples/chip-tool/commands/clusters/Commands.h b/examples/chip-tool/commands/clusters/Commands.h index 4491175bbc6fe1..1fd947de7a528c 100644 --- a/examples/chip-tool/commands/clusters/Commands.h +++ b/examples/chip-tool/commands/clusters/Commands.h @@ -10498,6 +10498,7 @@ class ReadOnOffClusterRevision : public ModelCommand | Cluster OperationalCredentials | 0x003E | |------------------------------------------------------------------------------| | Commands: | | +| * RemoveAllFabrics | 0x02 | | * RemoveFabric | 0x0A | | * SetFabric | 0x00 | | * UpdateFabricLabel | 0x09 | @@ -10507,6 +10508,35 @@ class ReadOnOffClusterRevision : public ModelCommand | * ClusterRevision | 0xFFFD | \*----------------------------------------------------------------------------*/ +/* + * Command RemoveAllFabrics + */ +class OperationalCredentialsRemoveAllFabrics : public ModelCommand +{ +public: + OperationalCredentialsRemoveAllFabrics() : ModelCommand("remove-all-fabrics") { ModelCommand::AddArguments(); } + ~OperationalCredentialsRemoveAllFabrics() + { + delete onSuccessCallback; + delete onFailureCallback; + } + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x003E) command (0x02) on endpoint %" PRIu16, endpointId); + + chip::Controller::OperationalCredentialsCluster cluster; + cluster.Associate(device, endpointId); + return cluster.RemoveAllFabrics(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + } + +private: + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnDefaultSuccessResponse, this); + chip::Callback::Callback * onFailureCallback = + new chip::Callback::Callback(OnDefaultFailureResponse, this); +}; + /* * Command RemoveFabric */ @@ -14923,9 +14953,10 @@ void registerClusterOperationalCredentials(Commands & commands) const char * clusterName = "OperationalCredentials"; commands_list clusterCommands = { - make_unique(), make_unique(), - make_unique(), make_unique(), - make_unique(), make_unique(), + make_unique(), make_unique(), + make_unique(), make_unique(), + make_unique(), make_unique(), + make_unique(), }; commands.Register(clusterName, clusterCommands); diff --git a/examples/chip-tool/gen/CHIPClusters.cpp b/examples/chip-tool/gen/CHIPClusters.cpp index 9b3266936b1045..c3b051266383b9 100644 --- a/examples/chip-tool/gen/CHIPClusters.cpp +++ b/examples/chip-tool/gen/CHIPClusters.cpp @@ -4511,6 +4511,32 @@ CHIP_ERROR OnOffCluster::ReadAttributeClusterRevision(Callback::Cancelable * onS } // OperationalCredentials Cluster Commands +CHIP_ERROR OperationalCredentialsCluster::RemoveAllFabrics(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ +#if CHIP_ENABLE_INTERACTION_MODEL + VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); + (void) onSuccessCallback; + (void) onFailureCallback; + + app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kRemoveAllFabricsCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + app::Command * ZCLcommand = mDevice->GetCommandSender(); + + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); + + // Command takes no arguments. + + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); + + return mDevice->SendCommands(); +#else + uint8_t seqNum = mDevice->GetNextSequenceNumber(); + System::PacketBufferHandle encodedCommand = encodeOperationalCredentialsClusterRemoveAllFabricsCommand(seqNum, mEndpoint); + return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); +#endif +} + CHIP_ERROR OperationalCredentialsCluster::RemoveFabric(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, chip::FabricId fabricId, chip::NodeId nodeId, uint16_t vendorId) diff --git a/examples/chip-tool/gen/CHIPClusters.h b/examples/chip-tool/gen/CHIPClusters.h index 0b6700348d3678..f6be4cf44d2f51 100644 --- a/examples/chip-tool/gen/CHIPClusters.h +++ b/examples/chip-tool/gen/CHIPClusters.h @@ -817,6 +817,7 @@ class DLL_EXPORT OperationalCredentialsCluster : public ClusterBase ~OperationalCredentialsCluster() {} // Cluster Commands + CHIP_ERROR RemoveAllFabrics(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); CHIP_ERROR RemoveFabric(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, chip::FabricId fabricId, chip::NodeId nodeId, uint16_t vendorId); CHIP_ERROR SetFabric(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t vendorId); @@ -829,6 +830,7 @@ class DLL_EXPORT OperationalCredentialsCluster : public ClusterBase CHIP_ERROR ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); private: + static constexpr CommandId kRemoveAllFabricsCommandId = 0x02; static constexpr CommandId kRemoveFabricCommandId = 0x0A; static constexpr CommandId kSetFabricCommandId = 0x00; static constexpr CommandId kUpdateFabricLabelCommandId = 0x09; diff --git a/examples/chip-tool/gen/CHIPClustersObjc.h b/examples/chip-tool/gen/CHIPClustersObjc.h index 50045a1bd724f4..0d6d737bf4361f 100644 --- a/examples/chip-tool/gen/CHIPClustersObjc.h +++ b/examples/chip-tool/gen/CHIPClustersObjc.h @@ -686,6 +686,7 @@ NS_ASSUME_NONNULL_BEGIN */ @interface CHIPOperationalCredentials : CHIPCluster +- (void)removeAllFabrics:(ResponseHandler)responseHandler; - (void)removeFabric:(uint64_t)fabricId nodeId:(uint64_t)nodeId vendorId:(uint16_t)vendorId diff --git a/examples/chip-tool/gen/CHIPClustersObjc.mm b/examples/chip-tool/gen/CHIPClustersObjc.mm index 8b236ee878ae9f..60f04472de669b 100644 --- a/examples/chip-tool/gen/CHIPClustersObjc.mm +++ b/examples/chip-tool/gen/CHIPClustersObjc.mm @@ -10180,6 +10180,32 @@ @implementation CHIPOperationalCredentials return &_cppCluster; } +- (void)removeAllFabrics:(ResponseHandler)responseHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]); + if (!onSuccess) { + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.RemoveAllFabrics(onSuccess->Cancel(), onFailure->Cancel()); + }); + + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + responseHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} - (void)removeFabric:(uint64_t)fabricId nodeId:(uint64_t)nodeId vendorId:(uint16_t)vendorId diff --git a/examples/chip-tool/gen/client-command-macro.h b/examples/chip-tool/gen/client-command-macro.h index 1ac6d9550498d1..8f3a01b8e721b1 100644 --- a/examples/chip-tool/gen/client-command-macro.h +++ b/examples/chip-tool/gen/client-command-macro.h @@ -2217,6 +2217,15 @@ \ ZCL_SET_FABRIC_RESPONSE_COMMAND_ID, "u", FabricId); +/** @brief Command description for RemoveAllFabrics + * + * Command: RemoveAllFabrics + */ +#define emberAfFillCommandOperational \ + CredentialsClusterRemoveAllFabrics() emberAfFillExternalBuffer(mask, \ + \ + ZCL_REMOVE_ALL_FABRICS_COMMAND_ID, "", ); + /** @brief Command description for UpdateFabricLabel * * Command: UpdateFabricLabel diff --git a/examples/chip-tool/gen/command-id.h b/examples/chip-tool/gen/command-id.h index cbda27333416da..eadb6aa0fa4411 100644 --- a/examples/chip-tool/gen/command-id.h +++ b/examples/chip-tool/gen/command-id.h @@ -268,6 +268,7 @@ // Commands for cluster: Operational Credentials #define ZCL_SET_FABRIC_COMMAND_ID (0x00) #define ZCL_SET_FABRIC_RESPONSE_COMMAND_ID (0x01) +#define ZCL_REMOVE_ALL_FABRICS_COMMAND_ID (0x02) #define ZCL_UPDATE_FABRIC_LABEL_COMMAND_ID (0x09) #define ZCL_REMOVE_FABRIC_COMMAND_ID (0x0A) diff --git a/examples/chip-tool/gen/endpoint_config.h b/examples/chip-tool/gen/endpoint_config.h index 9edc8106c64547..88897ef5d16126 100644 --- a/examples/chip-tool/gen/endpoint_config.h +++ b/examples/chip-tool/gen/endpoint_config.h @@ -320,7 +320,7 @@ // Array of EmberAfCommandMetadata structs. #define ZAP_COMMAND_MASK(mask) COMMAND_MASK_##mask -#define EMBER_AF_GENERATED_COMMAND_COUNT (191) +#define EMBER_AF_GENERATED_COMMAND_COUNT (192) #define GENERATED_COMMANDS \ { \ \ @@ -408,6 +408,7 @@ /* Endpoint: 1, Cluster: Operational Credentials (client) */ \ { 0x003E, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* SetFabric */ \ { 0x003E, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* SetFabricResponse */ \ + { 0x003E, 0x02, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* RemoveAllFabrics */ \ { 0x003E, 0x09, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* UpdateFabricLabel */ \ { 0x003E, 0x0A, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* RemoveFabric */ \ \ diff --git a/examples/lighting-app/lighting-common/gen/client-command-macro.h b/examples/lighting-app/lighting-common/gen/client-command-macro.h index 1ac6d9550498d1..8f3a01b8e721b1 100644 --- a/examples/lighting-app/lighting-common/gen/client-command-macro.h +++ b/examples/lighting-app/lighting-common/gen/client-command-macro.h @@ -2217,6 +2217,15 @@ \ ZCL_SET_FABRIC_RESPONSE_COMMAND_ID, "u", FabricId); +/** @brief Command description for RemoveAllFabrics + * + * Command: RemoveAllFabrics + */ +#define emberAfFillCommandOperational \ + CredentialsClusterRemoveAllFabrics() emberAfFillExternalBuffer(mask, \ + \ + ZCL_REMOVE_ALL_FABRICS_COMMAND_ID, "", ); + /** @brief Command description for UpdateFabricLabel * * Command: UpdateFabricLabel diff --git a/examples/lighting-app/lighting-common/gen/command-id.h b/examples/lighting-app/lighting-common/gen/command-id.h index cbda27333416da..eadb6aa0fa4411 100644 --- a/examples/lighting-app/lighting-common/gen/command-id.h +++ b/examples/lighting-app/lighting-common/gen/command-id.h @@ -268,6 +268,7 @@ // Commands for cluster: Operational Credentials #define ZCL_SET_FABRIC_COMMAND_ID (0x00) #define ZCL_SET_FABRIC_RESPONSE_COMMAND_ID (0x01) +#define ZCL_REMOVE_ALL_FABRICS_COMMAND_ID (0x02) #define ZCL_UPDATE_FABRIC_LABEL_COMMAND_ID (0x09) #define ZCL_REMOVE_FABRIC_COMMAND_ID (0x0A) diff --git a/examples/lock-app/lock-common/gen/client-command-macro.h b/examples/lock-app/lock-common/gen/client-command-macro.h index 1ac6d9550498d1..8f3a01b8e721b1 100644 --- a/examples/lock-app/lock-common/gen/client-command-macro.h +++ b/examples/lock-app/lock-common/gen/client-command-macro.h @@ -2217,6 +2217,15 @@ \ ZCL_SET_FABRIC_RESPONSE_COMMAND_ID, "u", FabricId); +/** @brief Command description for RemoveAllFabrics + * + * Command: RemoveAllFabrics + */ +#define emberAfFillCommandOperational \ + CredentialsClusterRemoveAllFabrics() emberAfFillExternalBuffer(mask, \ + \ + ZCL_REMOVE_ALL_FABRICS_COMMAND_ID, "", ); + /** @brief Command description for UpdateFabricLabel * * Command: UpdateFabricLabel diff --git a/examples/lock-app/lock-common/gen/command-id.h b/examples/lock-app/lock-common/gen/command-id.h index cbda27333416da..eadb6aa0fa4411 100644 --- a/examples/lock-app/lock-common/gen/command-id.h +++ b/examples/lock-app/lock-common/gen/command-id.h @@ -268,6 +268,7 @@ // Commands for cluster: Operational Credentials #define ZCL_SET_FABRIC_COMMAND_ID (0x00) #define ZCL_SET_FABRIC_RESPONSE_COMMAND_ID (0x01) +#define ZCL_REMOVE_ALL_FABRICS_COMMAND_ID (0x02) #define ZCL_UPDATE_FABRIC_LABEL_COMMAND_ID (0x09) #define ZCL_REMOVE_FABRIC_COMMAND_ID (0x0A) diff --git a/examples/temperature-measurement-app/esp32/main/gen/client-command-macro.h b/examples/temperature-measurement-app/esp32/main/gen/client-command-macro.h index 1ac6d9550498d1..8f3a01b8e721b1 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/client-command-macro.h +++ b/examples/temperature-measurement-app/esp32/main/gen/client-command-macro.h @@ -2217,6 +2217,15 @@ \ ZCL_SET_FABRIC_RESPONSE_COMMAND_ID, "u", FabricId); +/** @brief Command description for RemoveAllFabrics + * + * Command: RemoveAllFabrics + */ +#define emberAfFillCommandOperational \ + CredentialsClusterRemoveAllFabrics() emberAfFillExternalBuffer(mask, \ + \ + ZCL_REMOVE_ALL_FABRICS_COMMAND_ID, "", ); + /** @brief Command description for UpdateFabricLabel * * Command: UpdateFabricLabel diff --git a/examples/temperature-measurement-app/esp32/main/gen/command-id.h b/examples/temperature-measurement-app/esp32/main/gen/command-id.h index cbda27333416da..eadb6aa0fa4411 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/command-id.h +++ b/examples/temperature-measurement-app/esp32/main/gen/command-id.h @@ -268,6 +268,7 @@ // Commands for cluster: Operational Credentials #define ZCL_SET_FABRIC_COMMAND_ID (0x00) #define ZCL_SET_FABRIC_RESPONSE_COMMAND_ID (0x01) +#define ZCL_REMOVE_ALL_FABRICS_COMMAND_ID (0x02) #define ZCL_UPDATE_FABRIC_LABEL_COMMAND_ID (0x09) #define ZCL_REMOVE_FABRIC_COMMAND_ID (0x0A) diff --git a/examples/tv-app/tv-common/gen/client-command-macro.h b/examples/tv-app/tv-common/gen/client-command-macro.h index 1ac6d9550498d1..8f3a01b8e721b1 100644 --- a/examples/tv-app/tv-common/gen/client-command-macro.h +++ b/examples/tv-app/tv-common/gen/client-command-macro.h @@ -2217,6 +2217,15 @@ \ ZCL_SET_FABRIC_RESPONSE_COMMAND_ID, "u", FabricId); +/** @brief Command description for RemoveAllFabrics + * + * Command: RemoveAllFabrics + */ +#define emberAfFillCommandOperational \ + CredentialsClusterRemoveAllFabrics() emberAfFillExternalBuffer(mask, \ + \ + ZCL_REMOVE_ALL_FABRICS_COMMAND_ID, "", ); + /** @brief Command description for UpdateFabricLabel * * Command: UpdateFabricLabel diff --git a/examples/tv-app/tv-common/gen/command-id.h b/examples/tv-app/tv-common/gen/command-id.h index cbda27333416da..eadb6aa0fa4411 100644 --- a/examples/tv-app/tv-common/gen/command-id.h +++ b/examples/tv-app/tv-common/gen/command-id.h @@ -268,6 +268,7 @@ // Commands for cluster: Operational Credentials #define ZCL_SET_FABRIC_COMMAND_ID (0x00) #define ZCL_SET_FABRIC_RESPONSE_COMMAND_ID (0x01) +#define ZCL_REMOVE_ALL_FABRICS_COMMAND_ID (0x02) #define ZCL_UPDATE_FABRIC_LABEL_COMMAND_ID (0x09) #define ZCL_REMOVE_FABRIC_COMMAND_ID (0x0A) diff --git a/examples/window-app/common/gen/client-command-macro.h b/examples/window-app/common/gen/client-command-macro.h index 1ac6d9550498d1..8f3a01b8e721b1 100644 --- a/examples/window-app/common/gen/client-command-macro.h +++ b/examples/window-app/common/gen/client-command-macro.h @@ -2217,6 +2217,15 @@ \ ZCL_SET_FABRIC_RESPONSE_COMMAND_ID, "u", FabricId); +/** @brief Command description for RemoveAllFabrics + * + * Command: RemoveAllFabrics + */ +#define emberAfFillCommandOperational \ + CredentialsClusterRemoveAllFabrics() emberAfFillExternalBuffer(mask, \ + \ + ZCL_REMOVE_ALL_FABRICS_COMMAND_ID, "", ); + /** @brief Command description for UpdateFabricLabel * * Command: UpdateFabricLabel diff --git a/examples/window-app/common/gen/command-id.h b/examples/window-app/common/gen/command-id.h index cbda27333416da..eadb6aa0fa4411 100644 --- a/examples/window-app/common/gen/command-id.h +++ b/examples/window-app/common/gen/command-id.h @@ -268,6 +268,7 @@ // Commands for cluster: Operational Credentials #define ZCL_SET_FABRIC_COMMAND_ID (0x00) #define ZCL_SET_FABRIC_RESPONSE_COMMAND_ID (0x01) +#define ZCL_REMOVE_ALL_FABRICS_COMMAND_ID (0x02) #define ZCL_UPDATE_FABRIC_LABEL_COMMAND_ID (0x09) #define ZCL_REMOVE_FABRIC_COMMAND_ID (0x0A) diff --git a/src/app/chip-zcl-zpro-codec-api.h b/src/app/chip-zcl-zpro-codec-api.h index 149b37133852a7..21974ceab15ef5 100644 --- a/src/app/chip-zcl-zpro-codec-api.h +++ b/src/app/chip-zcl-zpro-codec-api.h @@ -2362,6 +2362,7 @@ chip::System::PacketBufferHandle encodeOnOffClusterReadClusterRevisionAttribute( | Cluster OperationalCredentials | 0x003E | |------------------------------------------------------------------------------| | Commands: | | +| * RemoveAllFabrics | 0x02 | | * RemoveFabric | 0x0A | | * SetFabric | 0x00 | | * UpdateFabricLabel | 0x09 | @@ -2371,6 +2372,13 @@ chip::System::PacketBufferHandle encodeOnOffClusterReadClusterRevisionAttribute( | * ClusterRevision | 0xFFFD | \*----------------------------------------------------------------------------*/ +/** + * @brief + * Encode an RemoveAllFabrics command for Operational Credentials server into buffer including the APS frame + */ +chip::System::PacketBufferHandle encodeOperationalCredentialsClusterRemoveAllFabricsCommand(uint8_t seqNum, + chip::EndpointId destinationEndpoint); + /** * @brief * Encode an RemoveFabric command for Operational Credentials server into buffer including the APS frame diff --git a/src/app/encoder.cpp b/src/app/encoder.cpp index f298266a98d0b2..77d3be89d0d320 100644 --- a/src/app/encoder.cpp +++ b/src/app/encoder.cpp @@ -302,6 +302,7 @@ uint16_t encodeApsFrame(uint8_t * buffer, uint16_t buf_length, EmberApsFrame * a #define ZCL_TOGGLE_COMMAND_ID (0x02) #define OPERATIONAL_CREDENTIALS_CLUSTER_ID 0x003E +#define ZCL_REMOVE_ALL_FABRICS_COMMAND_ID (0x02) #define ZCL_REMOVE_FABRIC_COMMAND_ID (0x0A) #define ZCL_SET_FABRIC_COMMAND_ID (0x00) #define ZCL_UPDATE_FABRIC_LABEL_COMMAND_ID (0x09) @@ -4142,6 +4143,7 @@ PacketBufferHandle encodeOnOffClusterReadClusterRevisionAttribute(uint8_t seqNum | Cluster OperationalCredentials | 0x003E | |------------------------------------------------------------------------------| | Commands: | | +| * RemoveAllFabrics | 0x02 | | * RemoveFabric | 0x0A | | * SetFabric | 0x00 | | * UpdateFabricLabel | 0x09 | @@ -4151,6 +4153,16 @@ PacketBufferHandle encodeOnOffClusterReadClusterRevisionAttribute(uint8_t seqNum | * ClusterRevision | 0xFFFD | \*----------------------------------------------------------------------------*/ +/* + * Command RemoveAllFabrics + */ +PacketBufferHandle encodeOperationalCredentialsClusterRemoveAllFabricsCommand(uint8_t seqNum, EndpointId destinationEndpoint) +{ + COMMAND_HEADER("RemoveAllFabrics", OPERATIONAL_CREDENTIALS_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand).Put8(seqNum).Put8(ZCL_REMOVE_ALL_FABRICS_COMMAND_ID); + COMMAND_FOOTER(); +} + /* * Command RemoveFabric */ diff --git a/src/controller/python/chip/clusters/CHIPClusters.cpp b/src/controller/python/chip/clusters/CHIPClusters.cpp index 25b5b90ccdbaad..e172cd3441d4e9 100644 --- a/src/controller/python/chip/clusters/CHIPClusters.cpp +++ b/src/controller/python/chip/clusters/CHIPClusters.cpp @@ -2170,6 +2170,14 @@ CHIP_ERROR chip_ime_ReadAttribute_OnOff_ClusterRevision(chip::Controller::Device // End of Cluster OnOff // Cluster OperationalCredentials +CHIP_ERROR chip_ime_AppendCommand_OperationalCredentials_RemoveAllFabrics(chip::Controller::Device * device, + chip::EndpointId ZCLendpointId, chip::GroupId) +{ + VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT); + chip::Controller::OperationalCredentialsCluster cluster; + cluster.Associate(device, ZCLendpointId); + return cluster.RemoveAllFabrics(gDefaultSuccessCallback.Cancel(), gDefaultFailureCallback.Cancel()); +} CHIP_ERROR chip_ime_AppendCommand_OperationalCredentials_RemoveFabric(chip::Controller::Device * device, chip::EndpointId ZCLendpointId, chip::GroupId, chip::FabricId fabricId, chip::NodeId nodeId, diff --git a/src/controller/python/chip/clusters/CHIPClusters.py b/src/controller/python/chip/clusters/CHIPClusters.py index cacf420d2332f1..e91070fd3f437f 100644 --- a/src/controller/python/chip/clusters/CHIPClusters.py +++ b/src/controller/python/chip/clusters/CHIPClusters.py @@ -481,6 +481,8 @@ def ListClusterCommands(self): }, }, "OperationalCredentials": { + "RemoveAllFabrics": { + }, "RemoveFabric": { "fabricId": "int", "nodeId": "int", @@ -1279,6 +1281,10 @@ def ClusterOnOff_CommandToggle(self, device: ctypes.c_void_p, ZCLendpoint: int, return self._chipLib.chip_ime_AppendCommand_OnOff_Toggle( device, ZCLendpoint, ZCLgroupid ) + def ClusterOperationalCredentials_CommandRemoveAllFabrics(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): + return self._chipLib.chip_ime_AppendCommand_OperationalCredentials_RemoveAllFabrics( + device, ZCLendpoint, ZCLgroupid + ) def ClusterOperationalCredentials_CommandRemoveFabric(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, fabricId: int, nodeId: int, vendorId: int): return self._chipLib.chip_ime_AppendCommand_OperationalCredentials_RemoveFabric( device, ZCLendpoint, ZCLgroupid, fabricId, nodeId, vendorId @@ -2478,6 +2484,9 @@ def InitLib(self, chipLib): self._chipLib.chip_ime_ReadAttribute_OnOff_ClusterRevision.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] self._chipLib.chip_ime_ReadAttribute_OnOff_ClusterRevision.restype = ctypes.c_uint32 # Cluster OperationalCredentials + # Cluster OperationalCredentials Command RemoveAllFabrics + self._chipLib.chip_ime_AppendCommand_OperationalCredentials_RemoveAllFabrics.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] + self._chipLib.chip_ime_AppendCommand_OperationalCredentials_RemoveAllFabrics.restype = ctypes.c_uint32 # Cluster OperationalCredentials Command RemoveFabric self._chipLib.chip_ime_AppendCommand_OperationalCredentials_RemoveFabric.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint64, ctypes.c_uint64, ctypes.c_uint16] self._chipLib.chip_ime_AppendCommand_OperationalCredentials_RemoveFabric.restype = ctypes.c_uint32 diff --git a/src/controller/python/gen/CHIPClusters.cpp b/src/controller/python/gen/CHIPClusters.cpp index 1a6deb926c5223..59b6767b4924c3 100644 --- a/src/controller/python/gen/CHIPClusters.cpp +++ b/src/controller/python/gen/CHIPClusters.cpp @@ -4511,6 +4511,32 @@ CHIP_ERROR OnOffCluster::ReadAttributeClusterRevision(Callback::Cancelable * onS } // OperationalCredentials Cluster Commands +CHIP_ERROR OperationalCredentialsCluster::RemoveAllFabrics(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ +#if CHIP_ENABLE_INTERACTION_MODEL + VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); + (void) onSuccessCallback; + (void) onFailureCallback; + + app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kRemoveAllFabricsCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + app::Command * ZCLcommand = mDevice->GetCommandSender(); + + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); + + // Command takes no arguments. + + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); + + return mDevice->SendCommands(); +#else + uint8_t seqNum = mDevice->GetNextSequenceNumber(); + System::PacketBufferHandle encodedCommand = encodeOperationalCredentialsClusterRemoveAllFabricsCommand(seqNum, mEndpoint); + return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); +#endif +} + CHIP_ERROR OperationalCredentialsCluster::RemoveFabric(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, chip::FabricId fabricId, chip::NodeId nodeId, uint16_t vendorId) diff --git a/src/controller/python/gen/CHIPClusters.h b/src/controller/python/gen/CHIPClusters.h index 1a8e5d93fed59b..c212e18d3b3159 100644 --- a/src/controller/python/gen/CHIPClusters.h +++ b/src/controller/python/gen/CHIPClusters.h @@ -818,6 +818,7 @@ class DLL_EXPORT OperationalCredentialsCluster : public ClusterBase ~OperationalCredentialsCluster() {} // Cluster Commands + CHIP_ERROR RemoveAllFabrics(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); CHIP_ERROR RemoveFabric(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, chip::FabricId fabricId, chip::NodeId nodeId, uint16_t vendorId); CHIP_ERROR SetFabric(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t vendorId); @@ -830,6 +831,7 @@ class DLL_EXPORT OperationalCredentialsCluster : public ClusterBase CHIP_ERROR ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); private: + static constexpr CommandId kRemoveAllFabricsCommandId = 0x02; static constexpr CommandId kRemoveFabricCommandId = 0x0A; static constexpr CommandId kSetFabricCommandId = 0x00; static constexpr CommandId kUpdateFabricLabelCommandId = 0x09; diff --git a/src/controller/python/gen/CHIPClustersObjc.h b/src/controller/python/gen/CHIPClustersObjc.h index 2df796e1bb82a7..f84daeca21765c 100644 --- a/src/controller/python/gen/CHIPClustersObjc.h +++ b/src/controller/python/gen/CHIPClustersObjc.h @@ -686,6 +686,7 @@ NS_ASSUME_NONNULL_BEGIN */ @interface CHIPOperationalCredentials : CHIPCluster +- (void)removeAllFabrics:(ResponseHandler)responseHandler; - (void)removeFabric:(uint64_t)fabricId nodeId:(uint64_t)nodeId vendorId:(uint16_t)vendorId diff --git a/src/controller/python/gen/CHIPClustersObjc.mm b/src/controller/python/gen/CHIPClustersObjc.mm index ca29cdb86ff577..9195ff70a0ec1f 100644 --- a/src/controller/python/gen/CHIPClustersObjc.mm +++ b/src/controller/python/gen/CHIPClustersObjc.mm @@ -10106,6 +10106,32 @@ @implementation CHIPOperationalCredentials return &_cppCluster; } +- (void)removeAllFabrics:(ResponseHandler)responseHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]); + if (!onSuccess) { + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.RemoveAllFabrics(onSuccess->Cancel(), onFailure->Cancel()); + }); + + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + responseHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} - (void)removeFabric:(uint64_t)fabricId nodeId:(uint64_t)nodeId vendorId:(uint16_t)vendorId diff --git a/src/controller/python/gen/client-command-macro.h b/src/controller/python/gen/client-command-macro.h index 1ac6d9550498d1..8f3a01b8e721b1 100644 --- a/src/controller/python/gen/client-command-macro.h +++ b/src/controller/python/gen/client-command-macro.h @@ -2217,6 +2217,15 @@ \ ZCL_SET_FABRIC_RESPONSE_COMMAND_ID, "u", FabricId); +/** @brief Command description for RemoveAllFabrics + * + * Command: RemoveAllFabrics + */ +#define emberAfFillCommandOperational \ + CredentialsClusterRemoveAllFabrics() emberAfFillExternalBuffer(mask, \ + \ + ZCL_REMOVE_ALL_FABRICS_COMMAND_ID, "", ); + /** @brief Command description for UpdateFabricLabel * * Command: UpdateFabricLabel diff --git a/src/controller/python/gen/command-id.h b/src/controller/python/gen/command-id.h index cbda27333416da..eadb6aa0fa4411 100644 --- a/src/controller/python/gen/command-id.h +++ b/src/controller/python/gen/command-id.h @@ -268,6 +268,7 @@ // Commands for cluster: Operational Credentials #define ZCL_SET_FABRIC_COMMAND_ID (0x00) #define ZCL_SET_FABRIC_RESPONSE_COMMAND_ID (0x01) +#define ZCL_REMOVE_ALL_FABRICS_COMMAND_ID (0x02) #define ZCL_UPDATE_FABRIC_LABEL_COMMAND_ID (0x09) #define ZCL_REMOVE_FABRIC_COMMAND_ID (0x0A) diff --git a/src/controller/python/gen/endpoint_config.h b/src/controller/python/gen/endpoint_config.h index a927535f5aeb5d..65af3dc24d6a5e 100644 --- a/src/controller/python/gen/endpoint_config.h +++ b/src/controller/python/gen/endpoint_config.h @@ -326,7 +326,7 @@ // Array of EmberAfCommandMetadata structs. #define ZAP_COMMAND_MASK(mask) COMMAND_MASK_##mask -#define EMBER_AF_GENERATED_COMMAND_COUNT (198) +#define EMBER_AF_GENERATED_COMMAND_COUNT (199) #define GENERATED_COMMANDS \ { \ \ @@ -414,6 +414,7 @@ /* Endpoint: 1, Cluster: Operational Credentials (client) */ \ { 0x003E, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* SetFabric */ \ { 0x003E, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* SetFabricResponse */ \ + { 0x003E, 0x02, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* RemoveAllFabrics */ \ { 0x003E, 0x09, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* UpdateFabricLabel */ \ { 0x003E, 0x0A, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* RemoveFabric */ \ \ diff --git a/src/darwin/Framework/CHIP/gen/CHIPClusters.cpp b/src/darwin/Framework/CHIP/gen/CHIPClusters.cpp index f54b07907e2e16..a53d9ca5b1a24d 100644 --- a/src/darwin/Framework/CHIP/gen/CHIPClusters.cpp +++ b/src/darwin/Framework/CHIP/gen/CHIPClusters.cpp @@ -3704,6 +3704,32 @@ CHIP_ERROR OnOffCluster::ReadAttributeClusterRevision(Callback::Cancelable * onS } // OperationalCredentials Cluster Commands +CHIP_ERROR OperationalCredentialsCluster::RemoveAllFabrics(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ +#if CHIP_ENABLE_INTERACTION_MODEL + VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); + (void) onSuccessCallback; + (void) onFailureCallback; + + app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kRemoveAllFabricsCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + app::Command * ZCLcommand = mDevice->GetCommandSender(); + + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); + + // Command takes no arguments. + + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); + + return mDevice->SendCommands(); +#else + uint8_t seqNum = mDevice->GetNextSequenceNumber(); + System::PacketBufferHandle encodedCommand = encodeOperationalCredentialsClusterRemoveAllFabricsCommand(seqNum, mEndpoint); + return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); +#endif +} + CHIP_ERROR OperationalCredentialsCluster::RemoveFabric(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, chip::FabricId fabricId, chip::NodeId nodeId, uint16_t vendorId) diff --git a/src/darwin/Framework/CHIP/gen/CHIPClusters.h b/src/darwin/Framework/CHIP/gen/CHIPClusters.h index d4aa3fd1af4608..4c06771b3cc6b5 100644 --- a/src/darwin/Framework/CHIP/gen/CHIPClusters.h +++ b/src/darwin/Framework/CHIP/gen/CHIPClusters.h @@ -640,6 +640,7 @@ class DLL_EXPORT OperationalCredentialsCluster : public ClusterBase ~OperationalCredentialsCluster() {} // Cluster Commands + CHIP_ERROR RemoveAllFabrics(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); CHIP_ERROR RemoveFabric(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, chip::FabricId fabricId, chip::NodeId nodeId, uint16_t vendorId); CHIP_ERROR SetFabric(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t vendorId); @@ -652,6 +653,7 @@ class DLL_EXPORT OperationalCredentialsCluster : public ClusterBase CHIP_ERROR ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); private: + static constexpr CommandId kRemoveAllFabricsCommandId = 0x02; static constexpr CommandId kRemoveFabricCommandId = 0x0A; static constexpr CommandId kSetFabricCommandId = 0x00; static constexpr CommandId kUpdateFabricLabelCommandId = 0x09; diff --git a/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.h b/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.h index 52ba9308e8ad8c..c80acefdc35749 100644 --- a/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.h +++ b/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.h @@ -578,6 +578,7 @@ NS_ASSUME_NONNULL_BEGIN */ @interface CHIPOperationalCredentials : CHIPCluster +- (void)removeAllFabrics:(ResponseHandler)responseHandler; - (void)removeFabric:(uint64_t)fabricId nodeId:(uint64_t)nodeId vendorId:(uint16_t)vendorId diff --git a/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm b/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm index 618dab45d9fe9e..c42244b115d9e9 100644 --- a/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm +++ b/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm @@ -8464,6 +8464,32 @@ @implementation CHIPOperationalCredentials return &_cppCluster; } +- (void)removeAllFabrics:(ResponseHandler)responseHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]); + if (!onSuccess) { + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.RemoveAllFabrics(onSuccess->Cancel(), onFailure->Cancel()); + }); + + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + responseHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} - (void)removeFabric:(uint64_t)fabricId nodeId:(uint64_t)nodeId vendorId:(uint16_t)vendorId diff --git a/src/darwin/Framework/CHIP/gen/client-command-macro.h b/src/darwin/Framework/CHIP/gen/client-command-macro.h index 1ac6d9550498d1..8f3a01b8e721b1 100644 --- a/src/darwin/Framework/CHIP/gen/client-command-macro.h +++ b/src/darwin/Framework/CHIP/gen/client-command-macro.h @@ -2217,6 +2217,15 @@ \ ZCL_SET_FABRIC_RESPONSE_COMMAND_ID, "u", FabricId); +/** @brief Command description for RemoveAllFabrics + * + * Command: RemoveAllFabrics + */ +#define emberAfFillCommandOperational \ + CredentialsClusterRemoveAllFabrics() emberAfFillExternalBuffer(mask, \ + \ + ZCL_REMOVE_ALL_FABRICS_COMMAND_ID, "", ); + /** @brief Command description for UpdateFabricLabel * * Command: UpdateFabricLabel diff --git a/src/darwin/Framework/CHIP/gen/command-id.h b/src/darwin/Framework/CHIP/gen/command-id.h index cbda27333416da..eadb6aa0fa4411 100644 --- a/src/darwin/Framework/CHIP/gen/command-id.h +++ b/src/darwin/Framework/CHIP/gen/command-id.h @@ -268,6 +268,7 @@ // Commands for cluster: Operational Credentials #define ZCL_SET_FABRIC_COMMAND_ID (0x00) #define ZCL_SET_FABRIC_RESPONSE_COMMAND_ID (0x01) +#define ZCL_REMOVE_ALL_FABRICS_COMMAND_ID (0x02) #define ZCL_UPDATE_FABRIC_LABEL_COMMAND_ID (0x09) #define ZCL_REMOVE_FABRIC_COMMAND_ID (0x0A) diff --git a/src/darwin/Framework/CHIP/gen/endpoint_config.h b/src/darwin/Framework/CHIP/gen/endpoint_config.h index aefcc4b9237a23..9cab58993c89b9 100644 --- a/src/darwin/Framework/CHIP/gen/endpoint_config.h +++ b/src/darwin/Framework/CHIP/gen/endpoint_config.h @@ -260,7 +260,7 @@ // Array of EmberAfCommandMetadata structs. #define ZAP_COMMAND_MASK(mask) COMMAND_MASK_##mask -#define EMBER_AF_GENERATED_COMMAND_COUNT (146) +#define EMBER_AF_GENERATED_COMMAND_COUNT (147) #define GENERATED_COMMANDS \ { \ \ @@ -348,6 +348,7 @@ /* Endpoint: 1, Cluster: Operational Credentials (client) */ \ { 0x003E, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* SetFabric */ \ { 0x003E, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* SetFabricResponse */ \ + { 0x003E, 0x02, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* RemoveAllFabrics */ \ { 0x003E, 0x09, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* UpdateFabricLabel */ \ { 0x003E, 0x0A, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* RemoveFabric */ \ \