2024-07-04 01:15 PM
Dear Support Team,
I am currently working on a project involving Zigbee communication, where I have multiple devices configured as Sleepy End Devices (SEDs). Specifically, I have ten SEDs connected to a single Zigbee Coordinator (ZC).
I have encountered a challenge in identifying the source of the measurements received by the ZC. Each SED is transmitting its data, but I am unable to distinguish which measurement corresponds to which device.
Could you please provide guidance on how to implement a system or method to uniquely identify the measurements from each SED? Any advice on best practices or example code snippets would be greatly appreciated.
I am working with the Nucleo Board WB55RG and i have checked several examples included in the stack, for example
DevTemp_Server_coord,DevTemp_Client_Router, OnOff_server_Coord, OnOff_Client_SED, etc.
@Ouadi Please could you help me?
2024-07-29 02:49 AM
Hi @TonyRivera0514 ,
The source of measurement can be easily done through the APS layer using the source address information of the incoming APS message.
Actually when the reporting is done, the client (ZC) can catch the APSDE-DATA structure that contains informations including the src address using the callback defined at the initialization as follow :
/**
* @brief report
* @param cluster,dataind,attribute,datatype,datapayload,datalength
* @retval None
*/
static void APP_ZIGBEE_Temp_meas_client_report(struct ZbZclClusterT *clusterPtr,
struct ZbApsdeDataIndT *dataIndPtr,
uint16_t attributeId,
enum ZclDataTypeT dataType,
const uint8_t *in_payload,
uint16_t in_len)
{
int attrLen;
uint16_t attr_val;
int16_t temp_cur;
float temp_val;
char text[32];
aPwmLedGsData_TypeDef aPwmLedGsData;
attrLen = ZbZclAttrParseLength(dataType, in_payload, dataIndPtr->asduLength, 0);
if (attrLen < 0)
{
APP_DBG("[TEMP MEAS] Report error length 0");
APP_ZIgbee_Error_Cnt++;
APP_Zigbee_Display_ErrorCnt();
return;
}
if (attrLen > (int)in_len)
{
APP_DBG("[TEMP MEAS] Report error length >");
APP_ZIgbee_Error_Cnt++;
APP_Zigbee_Display_ErrorCnt();
return;
}
if (dataIndPtr->src.endpoint!= SW1_ENDPOINT)
{
APP_DBG("[TEMP MEAS] Report error wrong endpoint");
APP_ZIgbee_Error_Cnt++;
APP_Zigbee_Display_ErrorCnt();
return;
}
switch(attributeId)
{
case ZCL_TEMP_MEAS_ATTR_MEAS_VAL:
attr_val= pletoh16(in_payload);
temp_cur = (int16_t)attr_val;
APP_DBG("[From 0x%016llx] - [TEMP MEAS] %d C",dataIndPtr->src.extAddr,temp_cur/100);
temp_val = (float) temp_cur/100;
sprintf(text,"Rep.Rem T:%.1f C",temp_val);
UTIL_LCD_ClearStringLine(3);
UTIL_LCD_DisplayStringAt(0, LINE(3), (uint8_t *)text, CENTER_MODE);
BSP_LCD_Refresh(0);
aPwmLedGsData[PWM_LED_RED] = PWM_LED_GSDATA_OFF;
aPwmLedGsData[PWM_LED_GREEN] = PWM_LED_GSDATA_OFF;
aPwmLedGsData[PWM_LED_BLUE] = PWM_LED_GSDATA_7_0;
LED_Toggle(aPwmLedGsData);
break;
default:
APP_DBG("[From 0x%016llx] - Reported another attribute 0x%04X",dataIndPtr->src.extAddr,attributeId);
APP_DBG("");
break;
}
} /* APP_ZIGBEE_temp_meas_client_report */
Best regards,
Ouadi