Hi!
I try on the basis of JN-AN-1189 and tsHA_LightSensorDevice to make automatic sending of attributes.
End Device:
#define LIGHT_SENSOR_MINIMUM_MEASURED_VALUE 0x0001
#define LIGHT_SENSOR_MAXIMUM_MEASURED_VALUE 0x00FC
#define LIGHT_SENSOR_MINIMUM_REPORTABLE_CHANGE 0x01
#define HA_NUMBER_OF_REPORTS 2
void vAPP_ZCL_DeviceSpecific_Init(void)
{
/* Initialise the strings in Basic */
memcpy(sSensor.sBasicServerCluster.au8ManufacturerName, "1NXP", CLD_BAS_MANUF_NAME_SIZE);
memcpy(sSensor.sBasicServerCluster.au8ModelIdentifier, "ZHA-OccupancySensor", CLD_BAS_MODEL_ID_SIZE);
memcpy(sSensor.sBasicServerCluster.au8DateCode, "20141604", CLD_BAS_DATE_SIZE);
memcpy(sSensor.sBasicServerCluster.au8SWBuildID, "4000-0001", CLD_BAS_SW_BUILD_SIZE);
/* Initialise the attribute in illuminance Measurement */
/* Initialise the attribute in illuminance Measurement */
sSensor.sIlluminanceMeasurementServerCluster.u16MeasuredValue = 0;
//sSensor.sIlluminanceMeasurementServerCluster.eLightSensorType = E_CLD_ILLMEAS_LST_CMOS;
sSensor.sIlluminanceMeasurementServerCluster.u16MinMeasuredValue = LIGHT_SENSOR_MINIMUM_MEASURED_VALUE;
sSensor.sIlluminanceMeasurementServerCluster.u16MaxMeasuredValue = LIGHT_SENSOR_MAXIMUM_MEASURED_VALUE;
}
PUBLIC void vMakeSupportedAttributesReportable(void)
{
uint16 u16AttributeEnum;
uint16 u16ClusterId;
uint8 i;
tsZCL_AttributeReportingConfigurationRecord* psAttributeReportingConfigurationRecord;
for(i=0;i<HA_NUMBER_OF_REPORTS;i++)
{
u16AttributeEnum=asSavedReports[i].sAttributeReportingConfigurationRecord.u16AttributeEnum;
u16ClusterId= asSavedReports[i].u16ClusterID;
psAttributeReportingConfigurationRecord = &(asSavedReports[i].sAttributeReportingConfigurationRecord);
eZCL_SetReportableFlag(1,u16ClusterId, TRUE, FALSE,u16AttributeEnum);
eZCL_CreateLocalReport(1,u16ClusterId,0,TRUE,psAttributeReportingConfigurationRecord);
}
}
.....
asSavedReports[1].u16ClusterID=MEASUREMENT_AND_SENSING_CLUSTER_ID_ILLUMINANCE_MEASUREMENT;
asSavedReports[1].sAttributeReportingConfigurationRecord.eAttributeDataType = E_ZCL_UINT16;
asSavedReports[1].sAttributeReportingConfigurationRecord.u16AttributeEnum = E_CLD_ILLMEAS_ATTR_ID_MEASURED_VALUE;
asSavedReports[1].sAttributeReportingConfigurationRecord.u16MaximumReportingInterval=LIGHT_SENSOR_MAXIMUM_MEASURED_VALUE;
asSavedReports[1].sAttributeReportingConfigurationRecord.u16MinimumReportingInterval=LIGHT_SENSOR_MINIMUM_MEASURED_VALUE;
asSavedReports[1].sAttributeReportingConfigurationRecord.u16TimeoutPeriodField=0; //0
asSavedReports[1].sAttributeReportingConfigurationRecord.u8DirectionIsReceived=0; //0
asSavedReports[1].sAttributeReportingConfigurationRecord.uAttributeReportableChange.zuint8ReportableChange=LIGHT_SENSOR_MINIMUM_REPORTABLE_CHANGE;
.....
In code for test change MeasuredValue
PUBLIC void vUpdateKeepAliveTimer(void)
{
te_SwitchState eSwitchState = eGetSwitchState();
if( (eSwitchState == LIGHT_CONTROL_MODE ) || (eSwitchState == INDIVIDUAL_CONTROL_MODE ) )
{
if( u8KeepAliveTime > 0 )
{
u8KeepAliveTime--;
sSensor.sIlluminanceMeasurementServerCluster.u16MeasuredValue = sSensor.sIlluminanceMeasurementServerCluster.u16MeasuredValue + 1;
But End Device not reporting attribute. Moreover, if I read attribute on gate:
devchange: 0x00158d0001833d77 260 1 { cid: 'msIlluminanceMeasurement', data: { measuredValue: 27 } }
What can I do wrong?
All work. SED sent attr report every 0x00FC.
After debug code I'll find answer. Clean project and rebuild + be sure vLoadDefaultConfigForReportable renew parameters.
Sorry for stuped question.