cancel
Showing results for 
Search instead for 
Did you mean: 

STM32WB55: Zigbee - Attribute Reporting

naanichilakalapudi
Associate III

 

Hi,

I'm working on implementing attribute reporting on the Zigbee STM32WB55 Evaluation boards. I've attempted to configure attribute reporting in the Zigbee_DevTemp_Server_Coord and Zigbee_DevTemp_Client_Router baseline examples. However, I encountered an issue on the server side where I am unable to perform the Write operation on the attributes. ([DEV TEMP]Failed to initialize initial Temperature)

 

During my investigation, I came across two APIs, namely ZbZclAttrReportKick() and ZbZclClusterReportCallbackAttach().

Interestingly, without using ZbZclAttrReportKick(), the report callback implemented on the router side is not being triggered. I'm curious about this behavior. The comments suggest that the application might disable automatic periodic reporting, but I'm unsure why this is happening.

Is it not possible to receive the callback output on the client side without calling ZbZclAttrReportKick()

Here are the comments on ZbZclAttrReportKick();

 

 

/**
 * This function is called to manually drive the attribute reporting mechanism.
 * The application may disable the automatic periodic reporting by setting the Network
 * Attribute 'ZB_NWK_NIB_ID_DisablePeriodicTimers' to 1.
 *  cluster Cluster instance
 *  callback Callback that is called once all reports have been sent. The 'next_timeout'
 * parameter is the time until the next scheduled report, in milliseconds.
 *  arg Callback argument
 * @return ZCL Status Code. If not ZCL_STATUS_SUCCESS, then callback will not be called.
 */
enum ZclStatusCodeT ZbZclAttrReportKick(struct ZbZclClusterT *cluster, bool send_all,
    void (*callback)(struct ZbZclClusterT *cluster, unsigned int next_timeout, void *arg), void *arg);

 

 

Objective: My primary goal is to retrieve updated attribute values on the client device whenever changes occur on the server side.

Inquiry 1: I require clarification regarding the unsuccessful Write operation.

Inquiry 2: I need further understanding and information about the relevant APIs.

Inquiry 3: I'm interested in any additional useful details related to Attribute Reporting.

 

I've provided the files for both the coordinator and the router for your reference.

Your insights on this matter would be appreciated. 
--
Thanks in advance,
Naani Ch

1 ACCEPTED SOLUTION

Accepted Solutions
Ouadi
ST Employee

Hello @naanichilakalapudi,

Please find below my answers to your questions :

1. Unsuccessful write operation with message  ([DEV TEMP]Failed to initialize initial Temperature)

From your code, you have defined a custom attribute within the cluster Device Temperature with the following configuration :

static const struct ZbZclAttrT ZclTemp_AttrList[] = {
{
MY_ZCL_DEV_TEMP_CURRENT, ZCL_DATATYPE_SIGNED_16BIT,
ZCL_ATTR_FLAG_REPORTABLE | ZCL_ATTR_FLAG_WRITABLE,
0, // custom size
NULL, // callback
{60, 120},=> {min_value_range, max_value_range}
{5, 10}=> {min_report, max_report}
}
};

From this config, the integer attribute value range is set to (60, 120), so only values within this interval could be written using the ZbZclAttrIntegerWrite API.

The write operation fails as the value written is out of range => #define ZCL_DEVICE_TEMP_INI 35

2. Implementation of the custom attribute and How to configure it as reportable on Serve/Client side 

A custom cluster can be configured using the ZbZclAttrAppendList() as described in document AN5491. 

Attribute reporting can be configured in several ways:

  • Automaticly during commissioning process by using find and bind mechanism.
  • Attribute configuration can also be set from client side using ZbZclAttrReportConfigReq().
  • Reporting configuration can be set on server side directly using cluster attributes list at cluster init or configured later on using ZbZclAttrReportConfigDefault() (after binding table configuration).

You can refer to these 2 posts for more details on how to configure a reportable attribute :

Post1 : Zigbee example/help on how to configure and send values 

Post2 : STM32WB55 Zigbee - Can't report value 

3. Code review and recommendation :

After analyzing your code, I noticed many points:

  • The custom attribut ID #define MY_ZCL_DEV_TEMP_CURRENT 0x0000 is already existing and allocated for the ZCL_DEV_TEMP_CURRENT which is a mandatory attribute ( file zcl.device.temp.h ), so the first modification is to change the attribut ID, to 0x04 for example.
  • The attribut value written is out of range, change on the value to be sure that the attribute is updated
  • The configuration of the reporting is done in both sides Coord/Router which is not correct => need to do the configuration only in one side following the steps discussed previously => in the modified files, the reporting is done in the client side using the right API.

Taking into account these points, I have modified the files server_coord_app_zigbee.c and client_router_app_zigbee.c so you can test your app successfully.

Another point, did you take a look to my answer regarding your post on how to implement RMS Current and Voltage attributes in this post? Could you please give your feedback directly on that post ?

Best regards,

Ouadi

View solution in original post

6 REPLIES 6
Christian N
ST Employee

Hello naanichilakalapudi, 

Thank you for contacting STMicroelectronics. Your inquiry is being escalated for specialized support.

Kind Regards,

Christian

ST Support

Ouadi
ST Employee

Hello @naanichilakalapudi,

Please find below my answers to your questions :

1. Unsuccessful write operation with message  ([DEV TEMP]Failed to initialize initial Temperature)

From your code, you have defined a custom attribute within the cluster Device Temperature with the following configuration :

static const struct ZbZclAttrT ZclTemp_AttrList[] = {
{
MY_ZCL_DEV_TEMP_CURRENT, ZCL_DATATYPE_SIGNED_16BIT,
ZCL_ATTR_FLAG_REPORTABLE | ZCL_ATTR_FLAG_WRITABLE,
0, // custom size
NULL, // callback
{60, 120},=> {min_value_range, max_value_range}
{5, 10}=> {min_report, max_report}
}
};

From this config, the integer attribute value range is set to (60, 120), so only values within this interval could be written using the ZbZclAttrIntegerWrite API.

The write operation fails as the value written is out of range => #define ZCL_DEVICE_TEMP_INI 35

2. Implementation of the custom attribute and How to configure it as reportable on Serve/Client side 

A custom cluster can be configured using the ZbZclAttrAppendList() as described in document AN5491. 

Attribute reporting can be configured in several ways:

  • Automaticly during commissioning process by using find and bind mechanism.
  • Attribute configuration can also be set from client side using ZbZclAttrReportConfigReq().
  • Reporting configuration can be set on server side directly using cluster attributes list at cluster init or configured later on using ZbZclAttrReportConfigDefault() (after binding table configuration).

You can refer to these 2 posts for more details on how to configure a reportable attribute :

Post1 : Zigbee example/help on how to configure and send values 

Post2 : STM32WB55 Zigbee - Can't report value 

3. Code review and recommendation :

After analyzing your code, I noticed many points:

  • The custom attribut ID #define MY_ZCL_DEV_TEMP_CURRENT 0x0000 is already existing and allocated for the ZCL_DEV_TEMP_CURRENT which is a mandatory attribute ( file zcl.device.temp.h ), so the first modification is to change the attribut ID, to 0x04 for example.
  • The attribut value written is out of range, change on the value to be sure that the attribute is updated
  • The configuration of the reporting is done in both sides Coord/Router which is not correct => need to do the configuration only in one side following the steps discussed previously => in the modified files, the reporting is done in the client side using the right API.

Taking into account these points, I have modified the files server_coord_app_zigbee.c and client_router_app_zigbee.c so you can test your app successfully.

Another point, did you take a look to my answer regarding your post on how to implement RMS Current and Voltage attributes in this post? Could you please give your feedback directly on that post ?

Best regards,

Ouadi

naanichilakalapudi
Associate III

Thanks for the quick reply @Ouadi.

I have one more question regarding point #3. My primary goal is to activate the RMS current and voltage attributes for this Attribute Reporting.

Please examine the provided configurations for enabling them. Despite not utilizing new attribute IDs, I am still able to execute read and write operations on them without any issues.

 

/* Re-define Disabled Electrical Measurement Cluster's Attributes here */
enum {
    // Attributes that are reported
	ENABLE_ZCL_ELEC_MEAS_ATTR_RMS_VOLT = 0x0505, /**< RMSVoltage (Optional) */
	ENABLE_ZCL_ELEC_MEAS_ATTR_RMS_CURR = 0x0508, /**< RMSCurrent (Optional) */
};

/*
 * Breaker State Information:
 *   Live Data Basic: Line Voltage   |   Live Data Basic: Load Current
 *     Type: float                   |     Type: float
 *     Size: 4 bytes                 |     Size: 4 bytes
 *     Format: nn.nn                 |     Format: nn.nn
 *     Default Value: 0              |     Default Value: 0
 *     Source: BKR                   |     Source: BKR
 */

// structure used to initialize a ZCL attribute
// when calling ZbZclAttrAppendList.
static struct ZbZclAttrT ZbZclAttrElecMeasAppendList[] =
{
	{ENABLE_ZCL_ELEC_MEAS_ATTR_RMS_VOLT,
			ZCL_DATATYPE_FLOATING_SINGLE,
			// ZCL_ATTR_FLAG_WRITABLE | ZCL_ATTR_FLAG_PERSISTABLE | ZCL_ATTR_FLAG_REPORTABLE,
			ZCL_ATTR_FLAG_REPORTABLE,
			0, NULL,
			.range = {.min = 0x0000, .max = 0xFFFE},
			.reporting = {.interval_min = 1, .interval_max = 5}},

	{ENABLE_ZCL_ELEC_MEAS_ATTR_RMS_CURR,
			ZCL_DATATYPE_FLOATING_SINGLE,
			// ZCL_ATTR_FLAG_WRITABLE | ZCL_ATTR_FLAG_PERSISTABLE | ZCL_ATTR_FLAG_REPORTABLE,
			ZCL_ATTR_FLAG_REPORTABLE,
			0, NULL,
			.range = {.min = 0x0000, .max = 0xFFFE},
			.reporting = {.interval_min = 1, .interval_max = 5}},
	// Add some more if needed
};

typedef struct {
	// const uint8_t rmsVoltData[4];
	// const uint8_t rmsCurrData[4];
	uint8_t rmsVoltData[4];
	uint8_t rmsCurrData[4];
}elecMeas_t;

 

In this scenario, if we intend to activate the default-disabled existing Attribute IDs (0x505 and 0x508) for Attribute Reporting in ZigBee, what steps should be taken to proceed with them?

--
With Regards,
Naani Ch

Ouadi
ST Employee

Hello @naanichilakalapudi,

The answer to this question is exactly what I provided in this post.

Attributes (ZCL_ELEC_MEAS_ATTR_RMS_VOLT/ ZCL_ELEC_MEAS_ATTR_RMS_CURR) are already existing within the Electrical Measurement Cluster, but disabled by default as they are optional attributes according to ZigBee spec.

Please follow my answer on the mentioned post to enable these optional attributes and to configure the reporting feature.

PS: Both attributes should be defined with a type ZCL_DATATYPE_UNSIGNED_16BIT according to the specification.

Finally, I don't recommend to define a custom attribute with an existing ID affected to a mandatory attribute to avoid any conflict and to be in line with the specification.

Best regards

Ouadi

naanichilakalapudi
Associate III

Okay. Thanks for the suggestions @Ouadi 

Okay. At what conditions, the reporting will be disabled. How can we detect this situation? Can you please give some example here?

Thanks