Hello.
I have three devices.
1. Thermostat 0x535A
2. Thermostat 0xC0E0
3. Test device 0x3F13
I want to use device 3 to find all thermostats in the network, get their short addresses, so that I can read and write to the ZCL_CLUSTER_HAVC_THERMOSTAT cluster attributes.
My code, where I call test_find_hvac_cluster() on button press.
void test_find_hvac_clusterCb(void *args) {
zdo_zdpDataInd_t *p = (zdo_zdpDataInd_t *)args;
zdo_match_descriptor_resp_t *rsp = (zdo_match_descriptor_resp_t*)p->zpdu;
if ((rsp->status == ZDO_SUCCESS) && (rsp->matchLen)) {
printf("matchLen: %d\r\n", rsp->matchLen);
printf("dstEp: %d\r\n", rsp->matchList[0]);
printf("shortAddr: 0x%04x\r\n", rsp->nwk_addr_interest);
}
}
void test_find_hvac_cluster() {
zdo_match_descriptor_req_t req;
req.nwk_addr_interest = NWK_BROADCAST_RX_ON_WHEN_IDLE;
req.profile_id = app_simpleDesc.app_profile_id;
req.num_in_clusters = 1;
req.num_out_clusters = 0;
req.cluster_list[0] = ZCL_CLUSTER_HAVC_THERMOSTAT;
u8 sn = 0;
zdo_status_t ret = zb_zdoMatchDescReq(NWK_BROADCAST_RX_ON_WHEN_IDLE, &req, &sn, test_find_hvac_clusterCb);
printf("ret: %d\r\n", ret);
}
But test_find_hvac_clusterCb is called only once and reports only one thermostat 0x535A
Button push 4 time
ret: 0
matchLen: 1
dstEp: 1
shortAddr: 0x535A
Button push 4 time
ret: 0
matchLen: 1
dstEp: 1
shortAddr: 0x535A
And rsp->matchLen always returns 1.
But with the help of a sniffer you can see that both thermostats send a response.
How to do it right?
|