TI中文支持网
TI专业的中文技术问题搜集分享网站

zigbee教程中Zigbee Fundamental Project Development代码咨询,cc2652.

教程part1中task1中第4步。多了一个#endif(32行),导致编译不通过。删除之后,编程成功,但运行绑定之后,系统死机

case zstackmsg_CmdIDs_ZDO_DEVICE_ANNOUNCE:
#if defined (Z_POWER_TEST)
#if defined (POWER_TEST_POLL_DATA){zstackmsg_zdoDeviceAnnounceInd_t *pInd;pInd = (zstackmsg_zdoDeviceAnnounceInd_t*)pMsg;// save the short address of the ZED to send ZCL test datapowerTestZEDAddr = pInd->req.srcAddr;// start periodic timer for sending ZCL data to zedOsalPortTimers_startReloadTimer(appServiceTaskId, SAMPLEAPP_POWER_TEST_ZCL_DATA_EVT, Z_POWER_TEST_DATA_TX_INTERVAL);}
#endif
#else{zstackmsg_zdoDeviceAnnounceInd_t *pInd;pInd = (zstackmsg_zdoDeviceAnnounceInd_t*)pMsg;zstack_zdoActiveEndpointReq_t pReq;pReq.dstAddr = pInd->req.srcAddr;pReq.nwkAddrOfInterest = pInd->req.devAddr;shortAddr = pInd->req.srcAddr;memcpy(bindAddr, &(pInd->req.devExtAddr), Z_EXTADDR_LEN);Zstackapi_ZdoActiveEndpointReq(appServiceTaskId, &pReq);}
#endifbreak;
//此处多了endif!!!!!!!!!!!!!编译不通过。
#endif
//...break;case zstackmsg_CmdIDs_ZDO_SIMPLE_DESC_RSP:{zstackmsg_zdoSimpleDescRspInd_t *pInd;pInd = (zstackmsg_zdoSimpleDescRspInd_t*)pMsg;for (uint8_t i = 0; i < pInd->rsp.simpleDesc.n_outputClusters; i++){if (*(pInd->rsp.simpleDesc.pOutputClusters) == ZCL_CLUSTER_ID_GEN_ON_OFF){zstack_sysNwkInfoReadRsp_t pRsp;Zstackapi_sysNwkInfoReadReq(appServiceTaskId, &pRsp);zstack_zdoBindReq_t pReq;pReq.nwkAddr = pRsp.nwkAddr;pReq.bindInfo.clusterID = ZCL_CLUSTER_ID_GEN_ON_OFF;pReq.bindInfo.srcEndpoint = SAMPLELIGHT_ENDPOINT;pReq.bindInfo.dstAddr.addrMode = (zstack_AFAddrMode)Addr64Bit;pReq.bindInfo.dstAddr.endpoint = pInd->rsp.simpleDesc.endpoint;EP = pInd->rsp.simpleDesc.endpoint;memcpy(pReq.bindInfo.dstAddr.addr.extAddr, &bindAddr, Z_EXTADDR_LEN);memcpy(pReq.bindInfo.srcAddr, &(pRsp.ieeeAddr), Z_EXTADDR_LEN);Zstackapi_ZdoBindReq(appServiceTaskId, &pReq);}pInd->rsp.simpleDesc.pOutputClusters++;}}break;case zstackmsg_CmdIDs_ZDO_ACTIVE_EP_RSP:{zstackmsg_zdoActiveEndpointsRspInd_t *pInd;pInd = (zstackmsg_zdoActiveEndpointsRspInd_t*)pMsg;zstack_zdoSimpleDescReq_t pReq;pReq.dstAddr = pInd->rsp.srcAddr;pReq.nwkAddrOfInterest = pInd->rsp.nwkAddrOfInterest;for (uint8_t i = 0; i < pInd->rsp.n_activeEPList; i++){pReq.endpoint = pInd->rsp.pActiveEPList[i];Zstackapi_ZdoSimpleDescReq(appServiceTaskId, &pReq);}}break;

Viki Shi:

哪个教程可以明示吗?链接或文档麻烦贴一下

Daoming Liu:

回复 Viki Shi:

dev.ti.com/…/node

Viki Shi:

回复 Daoming Liu:

我把第四步改了一下,可以通过编译了。详情如下:

1、

case zstackmsg_CmdIDs_ZDO_DEVICE_ANNOUNCE:
#if defined (Z_POWER_TEST)
#if defined (POWER_TEST_POLL_DATA){zstackmsg_zdoDeviceAnnounceInd_t *pInd;pInd = (zstackmsg_zdoDeviceAnnounceInd_t*)pMsg;// save the short address of the ZED to send ZCL test datapowerTestZEDAddr = pInd->req.srcAddr;// start periodic timer for sending ZCL data to zedOsalPortTimers_startReloadTimer(appServiceTaskId, SAMPLEAPP_POWER_TEST_ZCL_DATA_EVT, Z_POWER_TEST_DATA_TX_INTERVAL);}
#endif
#else{zstackmsg_zdoDeviceAnnounceInd_t *pInd;pInd = (zstackmsg_zdoDeviceAnnounceInd_t*)pMsg;zstack_zdoActiveEndpointReq_t pReq;pReq.dstAddr = pInd->req.srcAddr;pReq.nwkAddrOfInterest = pInd->req.devAddr;shortAddr = pInd->req.srcAddr;memcpy(bindAddr, &(pInd->req.devExtAddr), Z_EXTADDR_LEN);Zstackapi_ZdoActiveEndpointReq(appServiceTaskId, &pReq);}
//#endifbreak;
#endif

尾部第一个endif屏蔽掉

2、

//break;case zstackmsg_CmdIDs_ZDO_SIMPLE_DESC_RSP:{zstackmsg_zdoSimpleDescRspInd_t *pInd;pInd = (zstackmsg_zdoSimpleDescRspInd_t*)pMsg;for (uint8_t i = 0; i < pInd->rsp.simpleDesc.n_outputClusters; i++){if (*(pInd->rsp.simpleDesc.pOutputClusters) == ZCL_CLUSTER_ID_GEN_ON_OFF){zstack_sysNwkInfoReadRsp_t pRsp;Zstackapi_sysNwkInfoReadReq(appServiceTaskId, &pRsp);zstack_zdoBindReq_t pReq;pReq.nwkAddr = pRsp.nwkAddr;pReq.bindInfo.clusterID = ZCL_CLUSTER_ID_GEN_ON_OFF;pReq.bindInfo.srcEndpoint = SAMPLELIGHT_ENDPOINT;pReq.bindInfo.dstAddr.addrMode = (zstack_AFAddrMode)Addr64Bit;pReq.bindInfo.dstAddr.endpoint = pInd->rsp.simpleDesc.endpoint;EP = pInd->rsp.simpleDesc.endpoint;memcpy(pReq.bindInfo.dstAddr.addr.extAddr, &bindAddr, Z_EXTADDR_LEN);memcpy(pReq.bindInfo.srcAddr, &(pRsp.ieeeAddr), Z_EXTADDR_LEN);Zstackapi_ZdoBindReq(appServiceTaskId, &pReq);}pInd->rsp.simpleDesc.pOutputClusters++;}}break;case zstackmsg_CmdIDs_ZDO_ACTIVE_EP_RSP:{zstackmsg_zdoActiveEndpointsRspInd_t *pInd;pInd = (zstackmsg_zdoActiveEndpointsRspInd_t*)pMsg;zstack_zdoSimpleDescReq_t pReq;pReq.dstAddr = pInd->rsp.srcAddr;pReq.nwkAddrOfInterest = pInd->rsp.nwkAddrOfInterest;for (uint8_t i = 0; i < pInd->rsp.n_activeEPList; i++){pReq.endpoint = pInd->rsp.pActiveEPList[i];Zstackapi_ZdoSimpleDescReq(appServiceTaskId, &pReq);}}break;

上面这段代码替换zcl_samplelight.c里的

case zstackmsg_CmdIDs_ZDO_SIMPLE_DESC_RSP:

case zstackmsg_CmdIDs_ZDO_ACTIVE_EP_RSP:

两行,你试一下,注意第一行的break屏蔽掉

Daoming Liu:

回复 Viki Shi:

您好,可以编译成功,但下载之后进行bind时,这个设备就死机不能运行了。左右两边按钮都不起作用。您那边可以实现这个教程的结果吗?

Daoming Liu:

回复 Viki Shi:

这是按教程Part1之后形成的代码,使用这个会出现死机问题

zcl_samplelight.czcl_samplelight_data.c

Viki Shi:

回复 Daoming Liu:

目前无法实现,板子不在手边

Daoming Liu:

回复 Viki Shi:

等您有空的时候能否帮忙看看呢?十分感谢

赞(0)
未经允许不得转载:TI中文支持网 » zigbee教程中Zigbee Fundamental Project Development代码咨询,cc2652.
分享到: 更多 (0)