Zigbee Protocol Controller 1.6.0
attribute_management_int.h File Reference
#include "sl_status.h"
#include "sys/ctimer.h"
#include "zigpc_common_zigbee.h"

Go to the source code of this file.

Classes

struct  node_config_report_data_t
 the data structure representing all data required to handle a "Configure Reports - Node" event, represented by ATTR_MGMT_EVT_INIT_NODE More...
 
struct  endpoint_config_report_data_t
 the data structure representing all data required to handle a "Configure Reports - Endpoint" event, represented by ATTR_MGMT_EVT_INIT_ENDPOINT More...
 
struct  zigpc_attr_mgmt_read_data_t
 the structure used to initialize attribute data. In order to populate initial values of all attributes, it is necessary to request attributes after a delay. This structure holds all information related to this operation. More...
 
struct  zigpc_attr_mgmt_write_data_t
 the structure used to send a write attribute command. Contains all the information from MQTT and expected to be parsed into a valid ZCL frame. More...
 
struct  attribute_report_t
 the structure used to represent a report record used by the ZCL application framework when sending attribute/report information More...
 
struct  zigpc_attrmgmt_on_frame_receive_t
 the structure used to represent the data received on a report for a changed attribute More...
 

Enumerations

enum  attr_mgmt_evt {
  ZIGPC_ATTR_MGMT_EVT_INIT_NODE = 0 , ZIGPC_ATTR_MGMT_EVT_INIT_ENDPOINT , ZIGPC_ATTR_MGMT_EVT_ATTR_UPDATE , ZIGPC_ATTR_MGMT_EVT_CONFIGURE_RESPONSE ,
  ZIGPC_ATTR_MGMT_EVT_READ_ATTRIBUTES_COMMAND
}
 the enum representing the events handled by the attribute management Contiki process. Entries outside of this data structure are not valid More...
 

Functions

sl_status_t zigpc_attrmgmt_process_send_event (const enum attr_mgmt_evt event, const void *data, size_t data_size)
 Send an event and associated data to the attribute management Contiki process. Based on the data and data_size passed in, memory will be dynamically allocated in the heap and sent in order to be processed. More...
 
size_t zigpc_attrmgmt_get_records_to_send_in_message (size_t start_index, size_t count, size_t limit)
 Determine the number of records to send per ZCL message. More...
 
sl_status_t zigpc_attrmgmt_configure_reports_for_endpoint (const zigbee_eui64_t eui64, const zigbee_endpoint_t endpoint)
 zigpc_attrmgmt_configure_reports_for_endpoint - API for sending a ZCL command to the zigpc_gateway to configure reports for a single endpoint. This is an internal API, expected to be abstracted away. More...
 
sl_status_t node_send_report_config_cmd (const zigbee_node_t node)
 node_send_report_config_cmd - API for sending a ZCL command to the zigpc_gateway to configure reports for a node. This is an internal API, expected to be abstracted away. More...
 
sl_status_t zigpc_attribute_management_read_cluster_attributes (const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id, zcl_cluster_id_t cluster_id)
 Request to send a Read Attribute commands to the associated device, endpoint, and cluster combination. More...
 
void zigpc_attrmgmt_send_delayed_read_command_callback (void *read_data)
 Callback invoked by zigpc_attrmgmt_send_delayed_read_command after delay of ZIGPC_ATTR_MGMT_DELAY_READ_ATTRIBUTES. This handler will call zigpc_attribute_management_read_cluster_attributes afterwards. More...
 
sl_status_t zigpc_attrmgmt_send_read_attributes_command (const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id, zcl_cluster_id_t cluster_id)
 Send a ZCL Global Read Attribute Command to the associated device, endpoint, and cluster combination. More...
 
sl_status_t zigpc_attrmgmt_receive_attribute_frame (const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id, zcl_cluster_id_t cluster_id, bool is_read_response, const zcl_frame_t *frame)
 Process Attribute update response frames received from the a Device. This function is capable of processing the following Response record lists: More...
 
sl_status_t zigpc_attrmgmt_receive_configure_response_frame (const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id, zcl_cluster_id_t cluster_id, const zcl_frame_t *frame)
 zigpc_attrmgmt_receive_configure_response_frame Process a configure attribute response frame Accepts a ZCL frame for the response to a configure reports command. On a failed configure, adds the given EUI64, endpoint and cluster combination to the poll lis More...
 
sl_status_t attr_mgmt_gateway_init_observer (void)
 attr_mgmt_gateway_init_observer - the function that initiates all observers from the zigpc_gateway. Required to process a ReadAttribute Reponse, an Attribute Report or other data received asynchronously from the Zigbee network. More...
 
sl_status_t zigpc_attrmgmt_publish_reported (const zigbee_eui64_uint_t eui64, const zigbee_endpoint_id_t endpoint_id, const zcl_cluster_id_t cluster_id, const zcl_attribute_id_t attr_id, const uint8_t *attr_value)
 Publish Reported Attribute Values. More...
 
size_t zigpc_attrmgmt_get_poll_list_current_size ()
 zigpc_attrmgmt_get_poll_list_size More...
 
size_t zigpc_attrmgmt_get_poll_list_max_size ()
 zigpc_attrmgmt_get_poll_list_Max_size More...
 
sl_status_t zigpc_attrmgmt_send_poll_attributes ()
 zigpc_attrmgmt_send_poll_attributes More...
 
sl_status_t zigpc_attrmgmt_add_poll_entry (const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id, zcl_cluster_id_t cluster_id)
 zigpc_attrmgmt_add_poll_entry More...
 
sl_status_t zigpc_attrmgmt_remove_poll_entry (const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id, zcl_cluster_id_t cluster_id)
 
void zigpc_attrmgmt_empty_poll_list ()
 zigpc_attrmgmt_empty_poll_list More...
 

Variables

static const unsigned int ZIGPC_ATTR_MGMT_DELAY_READ_ATTRIBUTES = CLOCK_SECOND * 5
 
static const unsigned int ZIGPC_ATTRMGMT_READ_RECORDS_LIMIT_PER_MESSAGE = 25
 Limit of Read Attribute Records to send per ZCL Message. More...
 
static const unsigned int ZIGPC_ATTRMGMT_REPORT_RECORDS_LIMIT_PER_MESSAGE = 5
 Limit of Configure Reporting Records to send per ZCL Message. More...
 
static const uint16_t ZIGPC_ATTRMGMT_REPORT_INTERVAL_MIN_DEFAULT = 1000
 Default Configure Reporting Record Minimum Interval (Seconds). More...
 
static const uint16_t ZIGPC_ATTRMGMT_REPORT_INTERVAL_MAX_DEFAULT = 10000
 Default Configure Reporting Record Maximum Interval (Seconds). More...
 
static const uint32_t ZIGPC_ATTRMGMT_REPORT_CHANGE_DEFAULT = 0x0001
 Default Configure Reporting Record Reportable Change to allow any change to be reported. More...
 
static const uint32_t ZIGPC_ATTRMGMT_DEFAULT_POLL_SIZE = 256
 Default poll list size. The maximum number of clusters that can be stoed in the poll list. More...
 

Enumeration Type Documentation

◆ attr_mgmt_evt

the enum representing the events handled by the attribute management Contiki process. Entries outside of this data structure are not valid

attr_mgmt_evt

Enumerator
ZIGPC_ATTR_MGMT_EVT_INIT_NODE 
ZIGPC_ATTR_MGMT_EVT_INIT_ENDPOINT 
ZIGPC_ATTR_MGMT_EVT_ATTR_UPDATE 

Event corresponding to a new attribute update message received.

ZIGPC_ATTR_MGMT_EVT_CONFIGURE_RESPONSE 
ZIGPC_ATTR_MGMT_EVT_READ_ATTRIBUTES_COMMAND 

Function Documentation

◆ attr_mgmt_gateway_init_observer()

sl_status_t attr_mgmt_gateway_init_observer ( void  )

attr_mgmt_gateway_init_observer - the function that initiates all observers from the zigpc_gateway. Required to process a ReadAttribute Reponse, an Attribute Report or other data received asynchronously from the Zigbee network.

◆ node_send_report_config_cmd()

sl_status_t node_send_report_config_cmd ( const zigbee_node_t  node)

node_send_report_config_cmd - API for sending a ZCL command to the zigpc_gateway to configure reports for a node. This is an internal API, expected to be abstracted away.

Parameters
node- the node, whose endpoints should be configured for reports
Returns
SL_STATUS_OK if the command was sent successfully, SL_STATUS_FAIL otherwise

◆ zigpc_attribute_management_read_cluster_attributes()

sl_status_t zigpc_attribute_management_read_cluster_attributes ( const zigbee_eui64_t  eui64,
zigbee_endpoint_id_t  endpoint_id,
zcl_cluster_id_t  cluster_id 
)

Request to send a Read Attribute commands to the associated device, endpoint, and cluster combination.

Parameters
eui64Device identifier.
endpoint_idDevice endpoint identifier.
cluster_idCluster identifer to read attributes from.
Returns
sl_status_t SL_STATUS_OK if the request is sent.

◆ zigpc_attrmgmt_add_poll_entry()

sl_status_t zigpc_attrmgmt_add_poll_entry ( const zigbee_eui64_t  eui64,
zigbee_endpoint_id_t  endpoint_id,
zcl_cluster_id_t  cluster_id 
)

zigpc_attrmgmt_add_poll_entry

Add a new entry to be polled by ReadAttribute commands Will be put at the end of the list

Parameters
eui64- the eui64 of the node
endpoint_id- the endpoint specified
cluster_id- the cluster specified
Returns
SL_STATUS_OK if the new entry could be added properly

◆ zigpc_attrmgmt_configure_reports_for_endpoint()

sl_status_t zigpc_attrmgmt_configure_reports_for_endpoint ( const zigbee_eui64_t  eui64,
const zigbee_endpoint_t  endpoint 
)

zigpc_attrmgmt_configure_reports_for_endpoint - API for sending a ZCL command to the zigpc_gateway to configure reports for a single endpoint. This is an internal API, expected to be abstracted away.

Parameters
eui64- the eui64, whose endpoints should be configured for reports
endpoint- the endpoint, expected to give reports
Returns
SL_STATUS_OK if the command was sent successfully, SL_STATUS_FAIL otherwise

◆ zigpc_attrmgmt_empty_poll_list()

void zigpc_attrmgmt_empty_poll_list ( )

zigpc_attrmgmt_empty_poll_list

Empty the polling list

◆ zigpc_attrmgmt_get_poll_list_current_size()

size_t zigpc_attrmgmt_get_poll_list_current_size ( )

zigpc_attrmgmt_get_poll_list_size

Get the size of the current list we are polling with ReadAttributes

Returns
the number of clusters on the list we are polling

◆ zigpc_attrmgmt_get_poll_list_max_size()

size_t zigpc_attrmgmt_get_poll_list_max_size ( )

zigpc_attrmgmt_get_poll_list_Max_size

Get the maximum size of the polling list

Returns
the maximum number of clusters the poll list can contain

◆ zigpc_attrmgmt_get_records_to_send_in_message()

size_t zigpc_attrmgmt_get_records_to_send_in_message ( size_t  start_index,
size_t  count,
size_t  limit 
)

Determine the number of records to send per ZCL message.

Parameters
start_indexStarting index of record to send.
countTotal number of records in list.
limitMaximum number of records to send in each message.
Returns
size_t The number of records to send.

◆ zigpc_attrmgmt_process_send_event()

sl_status_t zigpc_attrmgmt_process_send_event ( const enum attr_mgmt_evt  event,
const void *  data,
size_t  data_size 
)

Send an event and associated data to the attribute management Contiki process. Based on the data and data_size passed in, memory will be dynamically allocated in the heap and sent in order to be processed.

NOTE: The attribute management process will free the memory allocated for data in the process loop.

Parameters
eventEvent type to send
dataPointer to data to be sent with the above event.
data_sizeSize of the data passed in.
Returns
SL_STATUS_OK if the event is sent to the Contiki process, SL_STATUS_NULL_POINTER on invalid arguments passed in, or SL_STATUS_EMPTY if the data_size to send is 0.

◆ zigpc_attrmgmt_publish_reported()

sl_status_t zigpc_attrmgmt_publish_reported ( const zigbee_eui64_uint_t  eui64,
const zigbee_endpoint_id_t  endpoint_id,
const zcl_cluster_id_t  cluster_id,
const zcl_attribute_id_t  attr_id,
const uint8_t *  attr_value 
)

Publish Reported Attribute Values.

Update the attribute value for a node, ep, cluster combination. This function will call the uic_dotdot_mqtt publish APIs in order to format and publish the reported attribute value.

Returns
SL_STATUS_OK on successful publish of a supported cluster attribute, another error if not.

◆ zigpc_attrmgmt_receive_attribute_frame()

sl_status_t zigpc_attrmgmt_receive_attribute_frame ( const zigbee_eui64_t  eui64,
zigbee_endpoint_id_t  endpoint_id,
zcl_cluster_id_t  cluster_id,
bool  is_read_response,
const zcl_frame_t frame 
)

Process Attribute update response frames received from the a Device. This function is capable of processing the following Response record lists:

  • ReadAttributeResponse records
  • ReportAttribute records
Parameters
eui64Device identifier.
endpoint_idDevice endpoint identifier.
cluster_idCluster identifer to read attributes from.
is_read_responseIf the passed frame is a ReadAttributeResponse
frameZCL Frame containing read attribute records.
Returns
sl_status_t SL_STATUS_OK on successfully processing and updating attributes on MQTT, SL_STATUS_NULL_POINTER if invalid arguments are supplied.

◆ zigpc_attrmgmt_receive_configure_response_frame()

sl_status_t zigpc_attrmgmt_receive_configure_response_frame ( const zigbee_eui64_t  eui64,
zigbee_endpoint_id_t  endpoint_id,
zcl_cluster_id_t  cluster_id,
const zcl_frame_t frame 
)

zigpc_attrmgmt_receive_configure_response_frame Process a configure attribute response frame Accepts a ZCL frame for the response to a configure reports command. On a failed configure, adds the given EUI64, endpoint and cluster combination to the poll lis

Parameters
eui64Device identifier.
endpoint_idDevice endpoint identifier
cluster_idCluster identifer of the source from
frameZCL Frame containing configure report response

◆ zigpc_attrmgmt_remove_poll_entry()

sl_status_t zigpc_attrmgmt_remove_poll_entry ( const zigbee_eui64_t  eui64,
zigbee_endpoint_id_t  endpoint_id,
zcl_cluster_id_t  cluster_id 
)

@briefzigpc_attrmgmt_remove_poll_entry

Remove a eui64, endpoint and cluster combination from the poll list

Parameters
eui64- the eui64 of the node
endpoint_id- the endpoint specified
cluster_id- the cluster specified
Returns
SL_STATUS_OK if the new entry could be removed properly

◆ zigpc_attrmgmt_send_delayed_read_command_callback()

void zigpc_attrmgmt_send_delayed_read_command_callback ( void *  read_data)

Callback invoked by zigpc_attrmgmt_send_delayed_read_command after delay of ZIGPC_ATTR_MGMT_DELAY_READ_ATTRIBUTES. This handler will call zigpc_attribute_management_read_cluster_attributes afterwards.

Parameters
read_dataPointer to zigpc_attr_mgmt_read_data_t

◆ zigpc_attrmgmt_send_poll_attributes()

sl_status_t zigpc_attrmgmt_send_poll_attributes ( )

zigpc_attrmgmt_send_poll_attributes

Send a ReadAttribute command to the next entry in the polling list

Returns
SL_STATUS_OK if the command could be sent properly

◆ zigpc_attrmgmt_send_read_attributes_command()

sl_status_t zigpc_attrmgmt_send_read_attributes_command ( const zigbee_eui64_t  eui64,
zigbee_endpoint_id_t  endpoint_id,
zcl_cluster_id_t  cluster_id 
)

Send a ZCL Global Read Attribute Command to the associated device, endpoint, and cluster combination.

Parameters
eui64Device identifier.
endpoint_idDevice endpoint identifier.
cluster_idCluster identifer to read attributes from.
Returns
sl_status_t SL_STATUS_OK if the read attributes command is sent, SL_STATUS_NULL_POINTER if invalid parameters are passed in, SL_STATUS_NOT_SUPPORTED if there is no supported attributes for the given cluster.

Variable Documentation

◆ ZIGPC_ATTR_MGMT_DELAY_READ_ATTRIBUTES

const unsigned int ZIGPC_ATTR_MGMT_DELAY_READ_ATTRIBUTES = CLOCK_SECOND * 5
static

◆ ZIGPC_ATTRMGMT_DEFAULT_POLL_SIZE

const uint32_t ZIGPC_ATTRMGMT_DEFAULT_POLL_SIZE = 256
static

Default poll list size. The maximum number of clusters that can be stoed in the poll list.

◆ ZIGPC_ATTRMGMT_READ_RECORDS_LIMIT_PER_MESSAGE

const unsigned int ZIGPC_ATTRMGMT_READ_RECORDS_LIMIT_PER_MESSAGE = 25
static

Limit of Read Attribute Records to send per ZCL Message.

Due to the ZCL messages only having a maximum payload of 70-80 bytes (depending on added manfacuturer-specific header information), and since each attribute record is 2-bytes, the maximum number of attribute read records to set per ZCL message should be limited. The current limit is chosen arbitrarily to allow the attribute read records to reliabily sent to the device.

◆ ZIGPC_ATTRMGMT_REPORT_CHANGE_DEFAULT

const uint32_t ZIGPC_ATTRMGMT_REPORT_CHANGE_DEFAULT = 0x0001
static

Default Configure Reporting Record Reportable Change to allow any change to be reported.

NOTE: This value is chosen arbitrarily and will likely be configurable in the future.

◆ ZIGPC_ATTRMGMT_REPORT_INTERVAL_MAX_DEFAULT

const uint16_t ZIGPC_ATTRMGMT_REPORT_INTERVAL_MAX_DEFAULT = 10000
static

Default Configure Reporting Record Maximum Interval (Seconds).

NOTE: This value is chosen arbitrarily and will likely be configurable in the future.

◆ ZIGPC_ATTRMGMT_REPORT_INTERVAL_MIN_DEFAULT

const uint16_t ZIGPC_ATTRMGMT_REPORT_INTERVAL_MIN_DEFAULT = 1000
static

Default Configure Reporting Record Minimum Interval (Seconds).

NOTE: This value is chosen arbitrarily and will likely be configurable in the future.

◆ ZIGPC_ATTRMGMT_REPORT_RECORDS_LIMIT_PER_MESSAGE

const unsigned int ZIGPC_ATTRMGMT_REPORT_RECORDS_LIMIT_PER_MESSAGE = 5
static

Limit of Configure Reporting Records to send per ZCL Message.

Due to the ZCL messages only having a maximum payload of 70-80 bytes (depending on added manfacuturer-specific header information), and since each attribute record is 8-bytes, the maximum number of attribute report records to set per ZCL message should be limited. The current limit is chosen arbitrarily to allow the configure report records to reliabily sent to the device.