Hello,
A ZigBee attribute reporting can be used to send the temperature values each X seconds, you may utilize the temperature measurement cluster and configure the ZCL_TEMP_MEAS_ATTR_MEAS_VAL attribute to be reportable.
Here is the configuration you need for this use :
On the Client side :
/* Temp meas client */
zigbee_app_info.temp_meas_client = ZbZclTempMeasClientAlloc(zigbee_app_info.zb,SW1_ENDPOINT);
assert(zigbee_app_info.temp_meas_client != NULL);
zigbee_app_info.temp_meas_client->report = &APP_ZIGBEE_Temp_meas_client_report; <==Callback used to receive ZCL Report
ZbZclClusterEndpointRegister(zigbee_app_info.temp_meas_client);
To configure the attribute reporting, you have to call the function ZbZclAttrReportConfigReq as follow :
static void APP_ZIGBEE_ReportConfig(void)
{
uint16_t rep_change = (uint16_t) ZCL_REPORT_CHANGE;
struct ZbZclAttrReportConfigT report;
report.dst.endpoint = SW1_ENDPOINT;
report.dst.mode = ZB_APSDE_ADDRMODE_SHORT;
report.dst.nwkAddr = 0xFFFF;
report.num_records = 1;
report.record_list[0].direction = ZCL_REPORT_DIRECTION_NORMAL;
report.record_list[0].min = ZCL_MIN_REPORT;
report.record_list[0].max = ZCL_MAX_REPORT;
report.record_list[0].change = 0;
report.record_list[0].attr_id = ZCL_TEMP_MEAS_ATTR_MEAS_VAL;
report.record_list[0].attr_type = ZCL_DATATYPE_SIGNED_16BIT;
ZbZclAttrReportConfigReq(zigbee_app_info.temp_meas_client,&report,&APP_ZIGBEE_Report_cb,(void*)&rep_change);
}/*APP_ZIGBEE_ReportConfig*/
ZCL_MIN_REPORT = Minimum reporting interval (e.g 0x000A => 10s)
ZCL_MAX_REPORT = Maximum reporting interval (e.g 0x0014 => 20s)
Consequently, the Attribute report will be received on the report callback mentionned previously at least every 20sec if temperature does not change and 10sec if it changes.
On the server side ( ED temperature sensor :(
The configuration is as follow:
/* Temp meas server */
zigbee_app_info.temp_meas_server = ZbZclTempMeasServerAlloc(zigbee_app_info.zb,SW1_ENDPOINT,MIN_MEASURED_TEMP,MAX_MEASURED_TEMP,TOLERANCE_TEMP);
The Binding entry is added automatically when the ZbZclAttrReportConfigReq is called from the client.
Now the configuration of the reporting is done, the temperature value is sent after each time intervall or when the value is changed.
To update the temperature attribute value with the measured temperature, the function ZbZclAttrIntegerWrite need to be used as follow:
void APP_ZIGBEE_WriteTempAttribute(float temp_val)
{
enum ZclStatusCodeT status;
float temp = temp_val*100;
int16_t temp_val_attr;
/* Write attribute */
temp_val_attr = (int16_t) temp ;
status = ZbZclAttrIntegerWrite(zigbee_app_info.temp_meas_server, ZCL_TEMP_MEAS_ATTR_MEAS_VAL, (int16_t)temp_val_attr);
}/*APP
You can also refer to the project example in the STM32WB FW Package ..\Projects\STM32WB5MM-DK\Applications\Zigbee\Zigbee_TempMeas_Server_Coord and ..\Projects\STM32WB5MM-DK\Applications\Zigbee\Zigbee_TempMeas_Client_Router which implements the same mechanisms over the temperature measurement cluster.
Best regards