Zigbee Protocol Controller 1.6.0
zigpc_ucl::mqtt Namespace Reference

UCL utility functions available to build and parse MQTT topics and payloads. More...

Classes

struct  topic_data_t
 Data that is used to build UCL topics. More...
 

Enumerations

enum class  topic_type_t {
  BY_UNID_PC_NWMGMT , BY_UNID_PC_NWMGMT_WRITE , BY_UNID_NODE_STATE , BY_UNID_NODE ,
  BY_UNID_NODE_EP
}
 Types of specific UCL topics that can be build along with variables passed via mqtt::topic_data_t. More...
 

Functions

sl_status_t build_topic (zigpc_ucl::mqtt::topic_type_t topic_type, zigpc_ucl::mqtt::topic_data_t topic_data, std::string &topic)
 Populate the topic string based on the topic type and data passed in. More...
 
sl_status_t parse_unid (std::string unid, zigbee_eui64_uint_t &eui64)
 Parse a UCL UNID into Zigbee device identifier. More...
 
sl_status_t parse_endpoint (std::string endpoint_str, zigbee_endpoint_id_t &endpoint)
 
sl_status_t parse_topic_eui64 (const std::string topic, zigbee_eui64_uint_t &eui64)
 
sl_status_t parse_topic_endpoint (const std::string topic, zigbee_endpoint_id_t &endpoint)
 
sl_status_t parse_topic_cluster (const std::string topic, std::string &cluster_name)
 
sl_status_t parse_binding (const std::string topic, const std::string payload, zigbee_eui64_uint_t &source_eui64, zigbee_endpoint_id_t &source_ep, std::string &cluster_name, zigbee_eui64_uint_t &dest_eui64, zigbee_endpoint_id_t &dest_ep)
 
std::string build_unid (zigbee_eui64_uint_t eui64)
 Build a UCL UNID based on the Zigbee device identifier. More...
 
sl_status_t publish_supported_generated (zigbee_eui64_uint_t eui64, zigbee_endpoint_id_t endpoint_id)
 
sl_status_t parse_payload (const char *payload, nlohmann::json &jsn)
 Parse the Incoming JSON payload into the passed in property tree. More...
 
sl_status_t subscribe (zigpc_ucl::mqtt::topic_type_t topic_type, zigpc_ucl::mqtt::topic_data_t topic_data, mqtt_message_callback_t cb)
 Subscribe to a UCL topic based on the type and data passed in. More...
 
sl_status_t publish (zigpc_ucl::mqtt::topic_type_t topic_type, zigpc_ucl::mqtt::topic_data_t topic_data, const char *payload, size_t payload_size, bool retain)
 Publish payload to a UCL topic based on the type and data passed in. More...
 
sl_status_t unretain (zigpc_ucl::mqtt::topic_type_t topic_type, zigpc_ucl::mqtt::topic_data_t topic_data)
 Unretain a UCL topic based on the specific topic type and topic variables passed in. More...
 

Detailed Description

UCL utility functions available to build and parse MQTT topics and payloads.

Enumeration Type Documentation

◆ topic_type_t

enum class zigpc_ucl::mqtt::topic_type_t
strong

Types of specific UCL topics that can be build along with variables passed via mqtt::topic_data_t.

Enumerator
BY_UNID_PC_NWMGMT 

Uses topic_data_t fields: eui64

BY_UNID_PC_NWMGMT_WRITE 

Uses topic_data_t fields: eui64

BY_UNID_NODE_STATE 

Uses topic_data_t fields: eui64

BY_UNID_NODE 

Uses topic_data_t fields: eui64

BY_UNID_NODE_EP 

Uses topic_data_t fields: eui64, endpoint_id

Function Documentation

◆ build_topic()

sl_status_t zigpc_ucl::mqtt::build_topic ( zigpc_ucl::mqtt::topic_type_t  topic_type,
zigpc_ucl::mqtt::topic_data_t  topic_data,
std::string &  topic 
)

Populate the topic string based on the topic type and data passed in.

Parameters
topic_typeTopic type.
topic_dataData to populate in the topic.
topicTopic to populate.
Returns
sl_status_t SL_STATUS_OK on succes, or SL_STATUS_INVALID_TYPE on invalid topic type passed in.

◆ build_unid()

std::string zigpc_ucl::mqtt::build_unid ( zigbee_eui64_uint_t  eui64)

Build a UCL UNID based on the Zigbee device identifier.

Parameters
eui64Zigbee identifier reference to convert.
Returns
std::string UCL UNID including ZigPC prefix.

◆ parse_binding()

sl_status_t zigpc_ucl::mqtt::parse_binding ( const std::string  topic,
const std::string  payload,
zigbee_eui64_uint_t source_eui64,
zigbee_endpoint_id_t source_ep,
std::string &  cluster_name,
zigbee_eui64_uint_t dest_eui64,
zigbee_endpoint_id_t dest_ep 
)

◆ parse_endpoint()

sl_status_t zigpc_ucl::mqtt::parse_endpoint ( std::string  endpoint_str,
zigbee_endpoint_id_t endpoint 
)

◆ parse_payload()

sl_status_t zigpc_ucl::mqtt::parse_payload ( const char *  payload,
nlohmann::json &  jsn 
)

Parse the Incoming JSON payload into the passed in property tree.

Parameters
payloadIncoming character array of payload.
jsnJson object to populate payload to.
Returns
sl_status_t SL_STATUS_OK on success, SL_STATUS_NULL_POINTER on invalid character array passed in,

◆ parse_topic_cluster()

sl_status_t zigpc_ucl::mqtt::parse_topic_cluster ( const std::string  topic,
std::string &  cluster_name 
)

◆ parse_topic_endpoint()

sl_status_t zigpc_ucl::mqtt::parse_topic_endpoint ( const std::string  topic,
zigbee_endpoint_id_t endpoint 
)

◆ parse_topic_eui64()

sl_status_t zigpc_ucl::mqtt::parse_topic_eui64 ( const std::string  topic,
zigbee_eui64_uint_t eui64 
)

◆ parse_unid()

sl_status_t zigpc_ucl::mqtt::parse_unid ( std::string  unid,
zigbee_eui64_uint_t eui64 
)

Parse a UCL UNID into Zigbee device identifier.

Parameters
unidUNID string to parse.
eui64Zigbee identifier reference to poulate.
Returns
sl_status_t SL_STATUS_OK on success, SL_STATUS_INVALID_SIGNATURE if the does not contain the configured UNID format (including prefix).

◆ publish()

sl_status_t zigpc_ucl::mqtt::publish ( zigpc_ucl::mqtt::topic_type_t  topic_type,
zigpc_ucl::mqtt::topic_data_t  topic_data,
const char *  payload,
size_t  payload_size,
bool  retain 
)

Publish payload to a UCL topic based on the type and data passed in.

Parameters
topic_typeUCL topic type.
topic_dataData to be populated in topic.
payloadPayload to publish.
payload_sizeSize of payload to publish.
retainPublish the payload as retained or not.
Returns
sl_status_t SL_STATUS_OK on success, SL_STATUS_NULL_POINTER on invalid payload provided, MQTT API based error otherwise.

◆ publish_supported_generated()

sl_status_t zigpc_ucl::mqtt::publish_supported_generated ( zigbee_eui64_uint_t  eui64,
zigbee_endpoint_id_t  endpoint_id 
)

◆ subscribe()

sl_status_t zigpc_ucl::mqtt::subscribe ( zigpc_ucl::mqtt::topic_type_t  topic_type,
zigpc_ucl::mqtt::topic_data_t  topic_data,
mqtt_message_callback_t  cb 
)

Subscribe to a UCL topic based on the type and data passed in.

Parameters
topic_typeUCL topic type.
topic_dataData to be populated in topic.
cbCallback to invoke on messages to the topic.
Returns
sl_status_t SL_STATUS_OK on success, SL_STATUS_NULL_POINTER on invalid callback provided, MQTT API based error otherwise.

◆ unretain()

sl_status_t zigpc_ucl::mqtt::unretain ( zigpc_ucl::mqtt::topic_type_t  topic_type,
zigpc_ucl::mqtt::topic_data_t  topic_data 
)

Unretain a UCL topic based on the specific topic type and topic variables passed in.

Parameters
topic_typeSpecific UCL topic type.
topic_dataVariables used to populate specific UCL topic type.
Returns
sl_status_t SL_STATUS_OK on success, or topic building error otherwise.