-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pull request #502: UIC-2846: emulate attribute IdentifyType
Merge in WMN_TOOLS/matter from feature/UIC-2846_Emulate_attribute_IdentifyType_for_spec_compliance to silabs Squashed commit of the following: commit 6cda15c319dd762e38f7d78de2bb6d25da6fee82 Author: Dennis Jensen <[email protected]> Date: Tue Jan 17 14:29:30 2023 +0100 UIC-2846: emulate attribute IdentifyType Changes: * Added an interface for registering emulators for specific clusters. * Made two data variables/schemes in the cluster emulator for keeping control of clusters, attributes and commands to emulate. * Added unit tests of the cluster emulator. Problems with encoding, so that is not fully tested reading attributes through the emulator.
- Loading branch information
1 parent
1524843
commit 3564345
Showing
11 changed files
with
470 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...examples/unify-matter-bridge/linux/src/cluster_translator/emulations/emulate_identify.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/****************************************************************************** | ||
* # License | ||
* <b>Copyright 2023 Silicon Laboratories Inc. www.silabs.com</b> | ||
****************************************************************************** | ||
* The licensor of this software is Silicon Laboratories Inc. Your use of this | ||
* software is governed by the terms of Silicon Labs Master Software License | ||
* Agreement (MSLA) available at | ||
* www.silabs.com/about-us/legal/master-software-license-agreement. This | ||
* software is distributed to you in Source Code format and is governed by the | ||
* sections of the MSLA applicable to Source Code. | ||
* | ||
*****************************************************************************/ | ||
|
||
#include "emulate_identify.hpp" | ||
|
||
// UIC | ||
#include "sl_log.h" | ||
|
||
// Matter | ||
#include <app-common/zap-generated/cluster-enums.h> | ||
|
||
// Standard library | ||
#include <map> | ||
|
||
namespace unify::matter_bridge { | ||
|
||
using namespace chip::app; | ||
using namespace chip::app::Clusters; | ||
|
||
#define LOG_TAG "EmulateIdentify" | ||
|
||
CHIP_ERROR EmulateIdentify::emulate( | ||
const node_state_monitor::cluster & unify_cluster, matter_cluster_builder & cluster_builder, | ||
std::map<chip::ClusterId, std::map<chip::AttributeId, EmulatorInterface *>> & emulation_attribute_handler_map, | ||
std::map<chip::ClusterId, std::map<chip::CommandId, EmulatorInterface *>> & emulation_command_handler) | ||
{ | ||
// Identify cluster emulation handler registered for IdentifyType attribute | ||
sl_log_debug(LOG_TAG, "Emulating IdentifyType attribute for Identify cluster"); | ||
emulation_attribute_handler_map[Identify::Id][Identify::Attributes::IdentifyType::Id] = this; | ||
|
||
// Add IdentifyType attribute to the matter cluster | ||
cluster_builder.attributes.push_back(EmberAfAttributeMetadata{ Identify::Attributes::IdentifyType::Id, ZCL_ENUM8_ATTRIBUTE_ID, | ||
1, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }); | ||
|
||
return CHIP_NO_ERROR; | ||
} | ||
|
||
CHIP_ERROR EmulateIdentify::read_attribute(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) | ||
{ | ||
sl_log_debug(LOG_TAG, "Read IdentifyType attribute"); | ||
|
||
// IdentifyType is a mandatory attribute we default it to None | ||
if (aPath.mAttributeId == Identify::Attributes::IdentifyType::Id) | ||
{ | ||
return aEncoder.Encode(Identify::IdentifyIdentifyType::EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_NONE); | ||
} | ||
|
||
sl_log_warning(LOG_TAG, "Emulation identify activated for unknown attribute id %d under cluster id %d", aPath.mAttributeId, | ||
aPath.mClusterId); | ||
return CHIP_ERROR_INVALID_ARGUMENT; | ||
} | ||
|
||
} // namespace unify::matter_bridge |
54 changes: 54 additions & 0 deletions
54
...examples/unify-matter-bridge/linux/src/cluster_translator/emulations/emulate_identify.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/****************************************************************************** | ||
* # License | ||
* <b>Copyright 2023 Silicon Laboratories Inc. www.silabs.com</b> | ||
****************************************************************************** | ||
* The licensor of this software is Silicon Laboratories Inc. Your use of this | ||
* software is governed by the terms of Silicon Labs Master Software License | ||
* Agreement (MSLA) available at | ||
* www.silabs.com/about-us/legal/master-software-license-agreement. This | ||
* software is distributed to you in Source Code format and is governed by the | ||
* sections of the MSLA applicable to Source Code. | ||
* | ||
*****************************************************************************/ | ||
|
||
#ifndef EMULATE_IDENTIFY_HPP | ||
#define EMULATE_IDENTIFY_HPP | ||
|
||
// Emulator interface | ||
#include "emulator.hpp" | ||
|
||
namespace unify::matter_bridge { | ||
|
||
using namespace chip::app; | ||
using namespace chip::app::Clusters; | ||
|
||
class EmulateIdentify : public EmulatorInterface | ||
{ | ||
public: | ||
/** | ||
* @brief Emulate Identify cluster this will emulate defined commands and | ||
* attributes | ||
* | ||
* @param unify_cluster | ||
* @param cluster_builder | ||
* @param emulation_handler_map | ||
* @return CHIP_ERROR | ||
*/ | ||
CHIP_ERROR | ||
emulate(const node_state_monitor::cluster & unify_cluster, matter_cluster_builder & cluster_builder, | ||
std::map<chip::ClusterId, std::map<chip::AttributeId, EmulatorInterface *>> & emulation_attribute_handler_map, | ||
std::map<chip::ClusterId, std::map<chip::CommandId, EmulatorInterface *>> & emulation_command_handler) override; | ||
|
||
/** | ||
* @brief Read the emulated IdentifyType attribute | ||
* | ||
* @param aPath | ||
* @param aEncoder | ||
* @return CHIP_ERROR | ||
*/ | ||
CHIP_ERROR read_attribute(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override; | ||
}; | ||
|
||
} // namespace unify::matter_bridge | ||
|
||
#endif // EMULATE_IDENTIFY_HPP |
Oops, something went wrong.