I am new to z-stack and digging through the sample application, and try to understand how things work. right now, I am reading the temperature sensor, thermostat, and heating/cooling unit sample application in the z-stack Home 1.2. I am a little confused about how the input/out clusters are defined in the binding process using EZ mode and end-devince binding request.
In the sample temp sensor app, the code for end device binding is as follows:
// NOT ZCL_EZMODE, Use EndDeviceBind static cId_t bindingOutClusters[] = { ZCL_CLUSTER_ID_MS_TEMPERATURE_MEASUREMENT }; #define ZCLSAMPLETEMPERATURESENSOR_BINDINGLIST 1 // Initiate an End Device Bind Request, this bind request will only use a cluster list that is important to binding. ZDP_EndDeviceBindReq( &dstAddr, NLME_GetShortAddr(), SAMPLETEMPERATURESENSOR_ENDPOINT, ZCL_HA_PROFILE_ID, 0, NULL, ZCLSAMPLETEMPERATURESENSOR_BINDINGLIST, bindingOutClusters,FALSE );
And for EZ mode binding, the following is used:
static uint16 clusterIDs[] = { ZCL_CLUSTER_ID_MS_TEMPERATURE_MEASUREMENT }; // only bind on the Temperature Measurement cluster // Invoke EZ-Mode ezModeData.endpoint = SAMPLETEMPERATURESENSOR_ENDPOINT; // endpoint on which to invoke EZ-Mode if ( ( zclSampleTemperatureSensor_NwkState == DEV_ZB_COORD ) || ( zclSampleTemperatureSensor_NwkState == DEV_ROUTER ) || ( zclSampleTemperatureSensor_NwkState == DEV_END_DEVICE ) ) { ezModeData.onNetwork = TRUE; // node is already on the network } else { ezModeData.onNetwork = FALSE; // node is not yet on the network } ezModeData.initiator = TRUE; // Temperature Sensor is an initiator ezModeData.numActiveInClusters = 1; ezModeData.pActiveInClusterIDs = clusterIDs; ezModeData.numActiveOutClusters = 0; // active output cluster ezModeData.pActiveOutClusterIDs = NULL; zcl_InvokeEZMode( &ezModeData );
In the simpledescriptor, the following is defined:
#define ZCLSAMPLETEMPERATURESENSOR_MAX_INCLUSTERS 3 const cId_t zclSampleTemperatureSensor_InClusterList[ZCLSAMPLETEMPERATURESENSOR_MAX_INCLUSTERS] = { ZCL_CLUSTER_ID_GEN_BASIC, ZCL_CLUSTER_ID_GEN_IDENTIFY, ZCL_CLUSTER_ID_MS_TEMPERATURE_MEASUREMENT }; #define ZCLSAMPLETEMPERATURESENSOR_MAX_OUTCLUSTERS 1 const cId_t zclSampleTemperatureSensor_OutClusterList[ZCLSAMPLETEMPERATURESENSOR_MAX_OUTCLUSTERS] = { ZCL_CLUSTER_ID_GEN_IDENTIFY };
For the thermostat, the following is defined:
#define ZCLSAMPLETHERMOSTAT_MAX_INCLUSTERS 3 const cId_t zclSampleThermostat_InClusterList[ZCLSAMPLETHERMOSTAT_MAX_INCLUSTERS] = { ZCL_CLUSTER_ID_GEN_BASIC, ZCL_CLUSTER_ID_GEN_IDENTIFY, ZCL_CLUSTER_ID_HVAC_THERMOSTAT }; #define ZCLSAMPLETHERMOSTAT_MAX_OUTCLUSTERS 1 const cId_t zclSampleThermostat_OutClusterList[ZCLSAMPLETHERMOSTAT_MAX_OUTCLUSTERS] = { ZCL_CLUSTER_ID_MS_TEMPERATURE_MEASUREMENT }; // NOT ZCL_EZMODE, Use EndDeviceBind static cId_t bindingOutClusters[] = { ZCL_CLUSTER_ID_HVAC_THERMOSTAT }; #define ZCLSAMPLETHERMOSTAT_BINDINGLIST_OUT 1 static cId_t bindingInClusters[] = { ZCL_CLUSTER_ID_HVAC_THERMOSTAT, ZCL_CLUSTER_ID_MS_TEMPERATURE_MEASUREMENT }; #define ZCLSAMPLETHERMOSTAT_BINDINGLIST_IN 2 ZDP_EndDeviceBindReq( &dstAddr, NLME_GetShortAddr(), SAMPLETHERMOSTAT_ENDPOINT, ZCL_HA_PROFILE_ID, ZCLSAMPLETHERMOSTAT_BINDINGLIST_IN, bindingInClusters, ZCLSAMPLETHERMOSTAT_BINDINGLIST_OUT, bindingOutClusters, TRUE ); //invoke EZ mode zclEZMode_InvokeData_t ezModeData; static uint16 clusterIDs[] = { ZCL_CLUSTER_ID_HVAC_THERMOSTAT }; // only bind on the Thermostat cluster // Invoke EZ-Mode ezModeData.endpoint = SAMPLETHERMOSTAT_ENDPOINT; // endpoint on which to invoke EZ-Mode if ( ( zclSampleThermostat_NwkState == DEV_ZB_COORD ) || ( zclSampleThermostat_NwkState == DEV_ROUTER ) || ( zclSampleThermostat_NwkState == DEV_END_DEVICE ) ) { ezModeData.onNetwork = TRUE; // node is already on the network } else { ezModeData.onNetwork = FALSE; // node is not yet on the network } ezModeData.initiator = TRUE; // Thermostat is an initiator ezModeData.numActiveInClusters = 0; ezModeData.pActiveInClusterIDs = NULL; ezModeData.numActiveOutClusters = 1; // active output cluster ezModeData.pActiveOutClusterIDs = clusterIDs; zcl_InvokeEZMode( &ezModeData );
Here are my questions:
- doc says to use EZ mode bind thermostat and temp sensor, but they are both initiators, shouldn't we bind a initiator and a target?
- in the sample temp sensor app, the ZCL_CLUSTER_ID_MS_TEMPERATURE_MEASUREMENT is in the output clusters for end-device binding, and in the input clusters list for EZ mode binding. Why is this?
- say we are binding thermostat and temp sensor, and they indeed can be paired. I suppose this works by matching ZCL_CLUSTER_ID_MS_TEMPERATURE_MEASUREMENT, in the input of temp sensor, and output in the thermostat. I can sort of understand how the ED binding works, but cannot seem to have a clue how it works in the EZ mode.
Thanks a lot for your help on my lengthy question.