5.2.6.4. Custom Cluster

This section provides the APIs and defines to create and use customized clusters.

5.2.6.4.1. API Reference

5.2.6.4.1.1. Header File

5.2.6.4.1.2. Functions

ezb_err_t ezb_zcl_custom_cluster_desc_add_manuf_attr(ezb_zcl_cluster_desc_t cluster_desc, uint16_t attr_id, uint8_t attr_type, uint8_t attr_access, uint16_t manuf_code, const void *value)

Add a manufacturer-specific attribute to a custom cluster descriptor.

Parameters:
  • cluster_desc -- Pointer to the custom cluster descriptor, ezb_zcl_cluster_desc_t.

  • attr_id -- Attribute identifier.

  • attr_type -- Attribute type.

  • attr_access -- Attribute access.

  • manuf_code -- Manufacturer code for the attribute.

  • value -- Pointer to the attribute value.

Returns:

Error code.

ezb_err_t ezb_zcl_custom_cluster_desc_add_attr(ezb_zcl_cluster_desc_t cluster_desc, uint16_t attr_id, uint8_t attr_type, uint8_t attr_access, const void *value)

Add an attribute to a custom cluster descriptor.

Parameters:
  • cluster_desc -- Pointer to the custom cluster descriptor, ezb_zcl_cluster_desc_t.

  • attr_id -- Attribute identifier.

  • attr_type -- Attribute type.

  • attr_access -- Attribute access.

  • value -- Pointer to the attribute value.

Returns:

Error code.

ezb_zcl_cluster_desc_t ezb_zcl_custom_create_cluster_desc(const ezb_zcl_custom_cluster_config_t *cluster_cfg, uint8_t role_mask)

Create a custom cluster descriptor.

Parameters:
Returns:

Created cluster descriptor.

ezb_err_t ezb_zcl_custom_cmd_req(const ezb_zcl_custom_cmd_t *cmd_req)

Send ZCL custom command request.

Parameters:

cmd_req -- Pointer to the custom command request structure, ezb_zcl_custom_cmd_s.

Returns:

Error code.

ezb_err_t ezb_zcl_custom_cluster_cmd_req(const ezb_zcl_custom_cluster_cmd_t *cmd_req)

Send ZCL custom cluster command request.

Note

This function is used to send a custom command request from a client/server to a server/client of a custom cluster. If the request is sent to a client, the custom cluster server must be present on the source endpoint, and vice versa.

Parameters:

cmd_req -- Pointer to the custom command request structure, ezb_zcl_custom_cluster_cmd_t.

Returns:

Error code.

ezb_err_t ezb_zcl_custom_cluster_handlers_register(const ezb_zcl_custom_cluster_handlers_t *handlers)

Register custom cluster handlers.

Parameters:

handlers -- Pointer to the custom cluster handlers structure, ezb_zcl_custom_cluster_handlers_s.

Returns:

Error code.

5.2.6.4.1.3. Structures

struct ezb_zcl_custom_cluster_handlers_s

Structure describing a ZCL cluster handler template.

Public Members

uint16_t cluster_id

Cluster identifier

uint8_t cluster_role

Cluster role (server/client)

ezb_zcl_custom_cluster_check_value_t check_value_cb

Callback for checking the attribute value of the custom cluster is correct.

ezb_zcl_custom_cluster_write_attr_t write_attr_cb

Callback for post-processing of the attribute of the custom cluster had been written.

ezb_zcl_custom_cluster_disc_cmd_t cmd_disc_cb

Callback for discovering the supported commands of the custom cluster.

ezb_zcl_custom_cluster_process_cmd_t process_cmd_cb

Callback for processing the custom cluster command.

struct ezb_zcl_custom_cmd_s

Structure for the ZCL Custom command request.

The cluster_id in cmd_ctrl SHALL be greater than EZB_ZCL_CLUSTER_ID_MIN_CUSTOM.

Public Members

ezb_zcl_custom_cmd_ctrl_t cmd_ctrl

Control information for the ZCL command.

uint8_t cmd_id

Custom command identifier.

uint16_t data_length

Length of data for custom command.

uint8_t *data

Data of custom command.

struct ezb_zcl_custom_cluster_config_s

Structure for the ZCL Custom cluster configuration.

Public Members

uint16_t cluster_id

Custom cluster identifier (SHALL be greater than EZB_ZCL_CLUSTER_ID_MIN_CUSTOM).

ezb_zcl_custom_cluster_init_t init_func

Function for initializing the custom cluster.

ezb_zcl_custom_cluster_deinit_t deinit_func

Function for de-initializing the custom cluster.

5.2.6.4.1.4. Type Definitions

typedef void (*ezb_zcl_custom_cluster_init_t)(uint8_t ep_id)

Callback for initializing the custom cluster.

Param ep_id:

Endpoint identifier that the custom cluster is being initialized.

typedef void (*ezb_zcl_custom_cluster_deinit_t)(uint8_t ep_id)

Callback for de-initializing the custom cluster.

Param ep_id:

Endpoint identifier that the custom cluster is being de-initialized.

typedef ezb_zcl_status_t (*ezb_zcl_custom_cluster_check_value_t)(uint16_t attr_id, uint8_t ep_id, void *value)

Callback for checking the attribute value of the custom cluster is correct.

Param attr_id:

Attribute identifier that is being checked.

Param ep_id:

Endpoint identifier that the custom cluster is being checked.

Param value:

Pointer to the attribute value that is being checked.

Return:

Status code.

typedef void (*ezb_zcl_custom_cluster_write_attr_t)(uint8_t ep_id, uint16_t attr_id, void *new_value, uint16_t manuf_code)

Callback for post-processing of the attribute of the custom cluster had been written.

Param ep_id:

Endpoint identifier that the custom cluster is being written to.

Param attr_id:

Attribute identifier that is being written.

Param new_value:

Pointer to the new attribute value that is being written.

Param manuf_code:

Manufacturer code.

typedef uint8_t (*ezb_zcl_custom_cluster_disc_cmd_t)(bool is_recv, uint8_t **list)

Callback for discovering the supported commands of the custom cluster.

Param is_recv:

[in] Indicate that the supported commands are received or sent.

Param list:

[out] Pointer to the list of supported commands.

Return:

Number of supported commands.

typedef ezb_zcl_status_t (*ezb_zcl_custom_cluster_process_cmd_t)(const ezb_zcl_cmd_hdr_t *header, const uint8_t *payload, uint16_t payload_length)

Callback for processing the custom cluster command.

Param header:

Pointer to the command header, see ezb_zcl_cmd_hdr_s.

Param payload:

Pointer to the command payload.

Param payload_length:

Length of the command payload.

Return:

Error code.

typedef struct ezb_zcl_custom_cluster_handlers_s ezb_zcl_custom_cluster_handlers_t

Structure describing a ZCL cluster handler template.

typedef ezb_zcl_cmd_ctrl_t ezb_zcl_custom_cmd_ctrl_t

Custom command control type (alias of ezb_zcl_cmd_ctrl_s).

typedef struct ezb_zcl_custom_cmd_s ezb_zcl_custom_cmd_t

Structure for the ZCL Custom command request.

The cluster_id in cmd_ctrl SHALL be greater than EZB_ZCL_CLUSTER_ID_MIN_CUSTOM.

typedef ezb_zcl_custom_cmd_t ezb_zcl_custom_cluster_cmd_t

Structure for the ZCL Custom cluster command request. .

typedef struct ezb_zcl_custom_cluster_config_s ezb_zcl_custom_cluster_config_t

Structure for the ZCL Custom cluster configuration.