Hi, since I finally succeed to send data using the APS component. I'm trying now to send data through the ZCL layer of Bitcloud, in order to respect the Zigbee HA standard. But I have to admit that it is much harder.
The aim of my program is to simply send a temperature to my coordinator.
So in order to get this work, i have used the ZCL section of the Bitcloud API reference and the Bitcloud Profile suite developer guide.
First I have configured the cluster and the endpoint but I'm not sure what i have to do with the ZCL_DEFINE_TEMPERATURE_MEASUREMENT_CLUSTER_SERVER macro's argument (TempIdClusterServeurAttributes)
ZCL_Cluster_t TempServerCluster[DS_SERVER_CLUSTERS_COUNT]= { ZCL_DEFINE_TEMPERATURE_MEASUREMENT_CLUSTER_SERVER(&TempIdClusterServeurAttributes) }; ClusterId_t TempServerClusterIds[DS_SERVER_CLUSTERS_COUNT]= { TEMPERATURE_MEASUREMENT_CLUSTER_ID }; static ZCL_DeviceEndpoint_t TempEndpoint = { .simpleDescriptor = { .endpoint = APP_SRC_ENDPOINT_ID, .AppProfileId = PROFILE_ID_HOME_AUTOMATION, .AppDeviceId = HA_COMBINED_INTERFACE_ID, .AppInClustersCount = 0, .AppInClustersList = 0, .AppOutClustersCount = ARRAY_SIZE(TempServerClusterIds), .AppOutClustersList =TempServerClusterIds, }, .serverCluster = 0, .clientCluster = TempServerCluster, };
void configurTempEndpoint(void) { appEndpoint.simpleDescriptor.endpoint = APP_SRC_ENDPOINT_ID; appEndpoint.simpleDescriptor.AppProfileId = PROFILE_ID_HOME_AUTOMATION; appEndpoint.simpleDescriptor.AppDeviceId=HA_DIMMER_SWITCH_DEVICE_ID; appEndpoint.simpleDescriptor.AppInClustersCount = 0; appEndpoint.simpleDescriptor.AppInClustersList =0; appEndpoint.simpleDescriptor.AppOutClustersCount = ARRAY_SIZE(TempServerClusterIds); appEndpoint.simpleDescriptor.AppOutClustersList = TempServerClusterIds; appEndpoint.serverCluster= NULL; appEndpoint.clientCluster = TempServerCluster; };
Then in my appDeviceTaskHandler I configured and tried to sent a request to write a test value(16) in the temperature attribute
typedef struct PACK { ZCL_AttributeId_t id; uint8_t type; uint8_t value; } APP_Write8BitAttributeReq_t; void appDeviceTaskHandler(void) { switch (appDeviceState) { case DEVICE_INITIAL_STATE : { appSnprintf("appinit\n\r"); ZCL_Notify_t notify; configurTempEndpoint(); ZCL_RegisterEndpoint(&appEndpoint); req.id=ZCL_WRITE_ATTRIBUTES_COMMAND_ID; ZCL_AttributeReq(&req); ZCL_NextElement_t element; APP_Write8BitAttributeReq_t writeAttrReqElement; uint8_t* buffer[128]; element.payloadLength = buffer; element.id = ZCL_WRITE_ATTRIBUTES_COMMAND_ID; element.content = &writeAttrReqElement; writeAttrReqElement.id = ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_SERVER_MEASURED_VALUE_ATTRIBUTE_ID; writeAttrReqElement.type = ZCL_8BIT_DATA_TYPE_ID; writeAttrReqElement.value = 16; ZCL_PutNextElement(&element); req.id=ZCL_WRITE_ATTRIBUTES_COMMAND_ID; req.defaultResponse=NULL; req.responseWaitTimeout=0; req.dstAddressing.addrMode=APS_SHORT_ADDRESS; req.dstAddressing.addr.shortAddress=0x0000; req.endpointId=APP_SRC_ENDPOINT_ID; req.dstAddressing.clusterId=CCPU_TO_LE16(0x0402); req.dstAddressing.profileId=PROFILE_ID_HOME_AUTOMATION; req.dstAddressing.clusterSide=ZCL_CLUSTER_SIDE_SERVER; req.requestLength=element.payloadLength; req.requestPayload=buffer; req.defaultResponse=ZCL_FRAME_CONTROL_ENABLE_DEFAULT_RESPONSE; ZCL_AttributeReq(&req); } break; } }
But no packets are going out of the transceiver. The program seems to be block because I only see one time the "appinit" which I send at the first line the appDeviceTaskHandler.
What am I doing wrong? What am I missing?
Is anyone have a clear example of How to write one attribute with the ZCL layer?
Also
Is it possible to create a new device with Bitlcoud? How to proceed? Because i'm actually writting my code in the dimmerSwitch files.
Thank you for your time
Quentin