Skip to content

Commit

Permalink
Pull request project-chip#146: Updated the zap files for genarting co…
Browse files Browse the repository at this point in the history
…mmand and attribute handler for unify bridge

Merge in WMN_TOOLS/matter from bugix/no_jira_updating_zap_genarted_files to silabs

Squashed commit of the following:

commit b704f0b222259f9caf9d21885a1c0e49bb7b6741
Author: Dereje Wassie <[email protected]>
Date:   Thu Oct 6 15:46:53 2022 +0200

    fixing data type mapping

commit 4e866bea88f3f0af41de2d7eb2a90b0a6428d963
Author: Dereje Wassie <[email protected]>
Date:   Thu Oct 6 13:51:35 2022 +0200

    Updated the zap files for genarting command and attribute handler for unify bridge
  • Loading branch information
Dereje Wassie authored and jmartinez-silabs committed Aug 22, 2023
1 parent 19b68e7 commit 6663ba5
Show file tree
Hide file tree
Showing 14 changed files with 37,457 additions and 45,652 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ using namespace unify::matter_bridge;
#include "unify_accessors.hpp"

{{#zcl_clusters}}
{{#if (supportedCluster label)}}
CHIP_ERROR
{{asUpperCamelCase label}}AttributeAccess::Read(const ConcreteReadAttributePath &aPath,
AttributeValueEncoder &aEncoder)
Expand Down Expand Up @@ -114,7 +115,7 @@ CHIP_ERROR {{asUpperCamelCase label}}AttributeAccess::Write(const ConcreteDataAt
std::string payload_str;
std::string topic = "ucl/by-unid/" + unify_node->unify_unid + "/ep"
+ std::to_string(unify_node->unify_endpoint)
+ "/{{asUpperCamelCase label}}/Attributes/" + attribute_name + "/Desired";
+ "/{{matterClusterConversion label}}/Attributes/" + attribute_name + "/Desired";
payload_str = jsn.dump();
uic_mqtt_publish(topic.c_str(),
payload_str.c_str(),
Expand Down Expand Up @@ -181,4 +182,5 @@ void {{asUpperCamelCase label}}AttributeAccess::reported_updated(const bridged_e
}
}

{{/if}}
{{/zcl_clusters}}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
namespace unify::matter_bridge
{
{{#zcl_clusters}}

{{#if (supportedCluster label)}}
class {{asUpperCamelCase label}}AttributeAccess : public attribute_translator_interface
{
public:
Expand All @@ -45,8 +45,8 @@ class {{asUpperCamelCase label}}AttributeAccess : public attribute_translator_in
const std::string& attribute,
const nlohmann::json &unify_value) override;

std::vector<const char *> unify_cluster_names() const override {return std::vector<const char *>({ "{{asUpperCamelCase label}}" });}
std::vector<const char *> unify_cluster_names() const override {return std::vector<const char *>({ "{{matterClusterConversion label}}" });}
};

{{/if}}
{{/zcl_clusters}}
} // namespace unify::matter_bridge
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
*
******************************************************************************/


// Default translation
#include "app/data-model/NullObject.h"
#include <app-common/zap-generated/cluster-objects.h>
#include <nlohmann/json.hpp>

// Default translation
template <typename T>
nlohmann::json inline to_json(const T & value)
{
return __FUNCTION__;
return "unknown value";
}

/***************************** Simple types Convertes **************/
Expand Down Expand Up @@ -65,6 +66,16 @@ nlohmann::json inline to_json(const uint64_t & value)
return value;
}

template <typename T>
nlohmann::json inline to_json(chip::app::DataModel::Nullable<T> & value)
{
if (value.HasValidValue())
{
return to_json(value.Value());
}
return nlohmann::json::value_t::null;
}

/***************************** Bitmap Convertes **************/
{{#zcl_clusters}}
{{#if (supportedCluster label)}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ void {{asUpperCamelCase label}}ClusterCommandHandler::InvokeCommand(
case Commands::{{asUpperCamelCase label}}::Id:
{
cmd = "{{asUpperCamelCase label}}";
{{#zcl_command_arguments}}
{
Commands::{{asUpperCamelCase parent.label}}::DecodableType data;
if (DataModel::Decode(ctxt.GetReader(), data) == CHIP_NO_ERROR) {
Commands::{{asUpperCamelCase label}}::DecodableType data;
if (DataModel::Decode(ctxt.GetReader(), data) == CHIP_NO_ERROR){
{{#zcl_command_arguments}}
{{#isOptional}}
if( data.{{asLowerCamelCase label}}.HasValue() ) {
try {
Expand All @@ -67,11 +66,10 @@ void {{asUpperCamelCase label}}ClusterCommandHandler::InvokeCommand(
} catch (std::exception &ex) {
sl_log_warning(LOG_TAG, "Failed to add the command argument value to json format: %s", ex.what());
}
{{/isOptional}}
{{/isOptional}}
{{/zcl_command_arguments}}
}
}
{{/zcl_command_arguments}}
}
break;
{{/zcl_commands_source_client}}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class {{asUpperCamelCase label}}ClusterCommandHandler : public command_translato
{{asUpperCamelCase label}}ClusterCommandHandler(
const matter_node_state_monitor &node_state_monitor, UicMqtt &uic_mqtt) :
command_translator_interface(node_state_monitor,
chip::app::Clusters::{{asUpperCamelCase label}}::Id,"{{asUpperCamelCase label}}", uic_mqtt)
chip::app::Clusters::{{asUpperCamelCase label}}::Id,"{{matterClusterConversion label}}", uic_mqtt)
{}
void InvokeCommand(chip::app::CommandHandlerInterface::HandlerContext
&HandlerContext) override;
Expand Down
Loading

0 comments on commit 6663ba5

Please sign in to comment.