Custom Attributes Addition In Temperature Measurement Cluster

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Custom Attributes Addition In Temperature Measurement Cluster

1,840 Views
talhamir49
Contributor III

Hi All

I'm using the JN-5189 DK and I want to report the value of 4 temperature sensors to the coordinator but unfortunately, the msTemperatureMeasurement cluster has only one attribute for reporting temperature.  How can I add more attributes to the cluster?

Thank  you

0 Kudos
Reply
2 Replies

1,835 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi @talhamir49,

Sensor device responding to simple descriptor request on all endpoints does not guarantee that endpoint has been registered at ZigBee Cluster Library. You should send some read attribute request commands to see whether they get back the read attribute response from the newly added endpoint or not.

Now regarding the default reporting for attributes on the additional endpoints that you added, you need to consider the following points:

  1. While creating the report they need to pass the endpoint corresponding to the attribute on that endpoint.
  2. You need to use bound non - blocking addressing mode.

Please look at the next example, LightSensor application where I have added another endpoint (Endpoint ID 2) on which Temperature Sensor sits and Measured Value attribute for temperature measurement cluster is reported along with Measured Value attribute for IL luminance Measurement cluster from Endpoint 1. You could take this example as a reference.

Now to create the report the following changes are required:

1.In zcl_options.h file, define the number of reports as in the example, two attributes which are reported the value for ZCL_NUMBER_OF_REPORTS should be set 2 as shown below:

#define ZCL_NUMBER_OF_REPORTS 2

2. In app_reporting.h, add endpoint as of the parameter for tsReports structure as shown below:

typedef struct 
{
   uint8 u8EndpointID;
   uint16 u16ClusterID;
   tsZCL_AttributeReportingConfigurationRecord sAttributeReportingConfigurationRecord;
}tsReports;

3. In App_LightSensor.c, change the definition of default report record to add the endpoint Id as one of the parameters and to add a new entry for temperature measurement as shown below:

/* define the default reports */
tsReports asDefaultReports[ZCL_NUMBER_OF_REPORTS] = \
{\
{LIGHTSENSOR_SENSOR_ENDPOINT,MEASUREMENT_AND_SENSING_CLUSTER_ID_ILLUMINANCE_MEASUREMENT,{0, E_ZCL_UINT16,E_CLD_ILLMEAS_ATTR_ID_MEASURED_VALUE,ZLO_MIN_REPORT_INTERVAL,ZLO_MAX_REPORT_INTERVAL,0,{LIGHT_SENSOR_MINIMUM_REPORTABLE_CHANGE}}},\

{LIGHTSENSOR_TEMPSENSOR_ENDPOINT,MEASUREMENT_AND_SENSING_CLUSTER_ID_TEMPERATURE_MEASUREMENT,{0, E_ZCL_INT16,E_CLD_TEMPMEAS_ATTR_ID_MEASURED_VALUE,ZLO_MIN_REPORT_INTERVAL,ZLO_MAX_REPORT_INTERVAL,0,{TEMPERATURE_SENSOR_MINIMUM_REPORTABLE_CHANGE}}},\

};

4.In app_reporting.c, change the functions vMakeSupportedAttributesReportable and vSaveReportableRecord as follow:

PUBLIC void vMakeSupportedAttributesReportable(void)
{
uint16 u16AttributeEnum;
uint16 u16ClusterId;
int i;

tsZCL_AttributeReportingConfigurationRecord* psAttributeReportingConfigurationRecord;
for(i=0; i<ZCL_NUMBER_OF_REPORTS; i++)
{
u16AttributeEnum = asSavedReports[i].sAttributeReportingConfigurationRecord.u16AttributeEnum;
u16ClusterId = asSavedReports[i].u16ClusterID;
psAttributeReportingConfigurationRecord = &(asSavedReports[i].sAttributeReportingConfigurationRecord);
DBG_vPrintf(TRACE_REPORT, "MAKE Reportable ep %d\n", asSavedReports[i].u8EndpointID);

DBG_vPrintf(TRACE_REPORT, "Cluster %04x Attribute %04x Min %d Max %d IntV %d Direct %d Change %d\n",
u16ClusterId,
u16AttributeEnum,
asSavedReports[i].sAttributeReportingConfigurationRecord.u16MinimumReportingInterval,
asSavedReports[i].sAttributeReportingConfigurationRecord.u16MaximumReportingInterval,
asSavedReports[i].sAttributeReportingConfigurationRecord.u16TimeoutPeriodField,
asSavedReports[i].sAttributeReportingConfigurationRecord.u8DirectionIsReceived,

asSavedReports[i].sAttributeReportingConfigurationRecord.uAttributeReportableChange.zint8ReportableChange);

eZCL_CreateLocalReport( asSavedReports[i].u8EndpointID, u16ClusterId, 0, TRUE, psAttributeReportingConfigurationRecord);
}
}
 
PUBLIC void vSaveReportableRecord( uint8 u8Endpoint,
uint16 u16ClusterID,tsZCL_AttributeReportingConfigurationRecord* psAttributeReportingConfigurationRecord)
{
int iIndex = 0;
/*For MeasuredValue attribute in Illuminance Measurement Cluster*/
asSavedReports[iIndex].u16ClusterID=u16ClusterID;
asSavedReports[iIndex].u8EndpointID=u8Endpoint;
memcpy( &(asSavedReports[iIndex].sAttributeReportingConfigurationRecord),
psAttributeReportingConfigurationRecord,
sizeof(tsZCL_AttributeReportingConfigurationRecord) );

DBG_vPrintf(TRACE_REPORT,"Cluster %04x Type %d Attrib %04x Min %d Max %d IntV %d Direction %d Change %d\n",
asSavedReports[iIndex].u16ClusterID,
asSavedReports[iIndex].sAttributeReportingConfigurationRecord.eAttributeDataType,
asSavedReports[iIndex].sAttributeReportingConfigurationRecord.u16AttributeEnum,
asSavedReports[iIndex].sAttributeReportingConfigurationRecord.u16MinimumReportingInterval,
asSavedReports[iIndex].sAttributeReportingConfigurationRecord.u16MaximumReportingInterval,
asSavedReports[iIndex].sAttributeReportingConfigurationRecord.u16TimeoutPeriodField,
asSavedReports[iIndex].sAttributeReportingConfigurationRecord.u8DirectionIsReceived,
asSavedReports[iIndex].sAttributeReportingConfigurationRecord.uAttributeReportableChange.zuint8ReportableChange );

/*Save this Records*/
PDM_eSaveRecordData(PDM_ID_APP_REPORTS,
asSavedReports,sizeof(asSavedReports));
}
  1. In app_zcl_sensor_task.c, inside APP_ZCL_cbEndpointCallback add the following changes:
case E_ZCL_CBET_REPORT_INDIVIDUAL_ATTRIBUTES_CONFIGURE:
{
tsZCL_AttributeReportingConfigurationRecord *psAttributeReportingRecord= &psEvent->uMessage.sAttributeReportingConfigurationRecord;
 if (E_ZCL_SUCCESS == psEvent->eZCL_Status)

{
if(MEASUREMENT_AND_SENSING_CLUSTER_ID_ILLUMINANCE_MEASUREMENT == psEvent->psClusterInstance->psClusterDefinition->u16ClusterEnum)
{

vSaveReportableRecord(psEvent->u8EndPoint,MEASUREMENT_AND_SENSING_CLUSTER_ID_ILLUMINANCE_MEASUREMENT,psAttributeReportingRecord);
}
if(MEASUREMENT_AND_SENSING_CLUSTER_ID_TEMPERATURE_MEASUREMENT == psEvent->psClusterInstance->psClusterDefinition->u16ClusterEnum)
{
vSaveReportableRecord(psEvent->u8EndPoint,MEASUREMENT_AND_SENSING_CLUSTER_ID_TEMPERATURE_MEASUREMENT,psAttributeReportingRecord);
}
}
}
break;

Be sure that the next file vReportSchedulerUpdate function inside zcl_reportScheduler.c (JN-SW-4170/Components/ZCIF/Source) should be as below:

 if(psTransmitReportRecord!=NULL)                   
{                        
// transmit request                        
sZCL_Address.eAddressMode = E_ZCL_AM_BOUND_NON_BLOCKING; //be sure that your file is like this [MC]                      
  if(eZCL_TransmitDataRequest(myPDUM_thAPduInstance,                                                    
   u16outputOffset,    
   psEndPointDefinition->u8EndPointNumber,   
   0, // No dest EP for bound                                                    
   psClusterInstance->psClusterDefinition->u16ClusterEnum,                                                  
   &sZCL_Address) != E_ZCL_SUCCESS)*/                    
     {                             return;                        
     }                    
} 

 

Please let me know if you need any further assistance.

Regards,

Mario

0 Kudos
Reply

1,829 Views
talhamir49
Contributor III

Thanks for your response @mario_castaneda 

Added another attribute to send the values of the 2nd temperature sensor.

 

Regard,

Talha