This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

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 data
        powerTestZEDAddr = pInd->req.srcAddr;

        // start periodic timer for sending ZCL data to zed
        OsalPortTimers_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);
      }
#endif
      break;
//此处多了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;

  • 哪个教程可以明示吗?链接或文档麻烦贴一下
  • 我把第四步改了一下,可以通过编译了。详情如下:

    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 data
            powerTestZEDAddr = pInd->req.srcAddr;
    
            // start periodic timer for sending ZCL data to zed
            OsalPortTimers_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);
          }
    //#endif
          break;
    #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屏蔽掉

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

    zcl_samplelight.c

    zcl_samplelight_data.c
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    /**************************************************************************************************
    Filename: zcl_samplelight_data.c
    Revised: $Date: 2014-05-12 13:14:02 -0700 (Mon, 12 May 2014) $
    Revision: $Revision: 38502 $
    Description: Zigbee Cluster Library - sample device application.
    Copyright 2006-2014 Texas Instruments Incorporated. All rights reserved.
    IMPORTANT: Your use of this Software is limited to those specific rights
    granted under the terms of a software license agreement between the user
    who downloaded the software, his/her employer (which must be your employer)
    and Texas Instruments Incorporated (the "License"). You may not use this
    Software unless you agree to abide by the terms of the License. The License
    limits your use, and you acknowledge, that the Software may not be modified,
    copied or distributed unless embedded on a Texas Instruments microcontroller
    or used solely and exclusively in conjunction with a Texas Instruments radio
    frequency transceiver, which is integrated into your product. Other than for
    the foregoing purpose, you may not use, reproduce, copy, prepare derivative
    works of, modify, distribute, perform, display or sell this Software and/or
    its documentation for any purpose.
    YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
    PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
    INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
    NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
    TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
    NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
    LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
    INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
    OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
    OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
    (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
    Should you have any questions regarding your right to use this Software,
    contact Texas Instruments Incorporated at www.TI.com.
    **************************************************************************************************/
    /*********************************************************************
    * INCLUDES
    */
    #include "zcomdef.h"
    #include "zcl.h"
    #include "zcl_general.h"
    #include "zcl_ha.h"
    #include "zcl_poll_control.h"
    #include "zcl_electrical_measurement.h"
    #include "zcl_meter_identification.h"
    #include "zcl_appliance_identification.h"
    #include "zcl_appliance_events_alerts.h"
    #include "zcl_power_profile.h"
    #include "zcl_appliance_control.h"
    #include "zcl_appliance_statistics.h"
    #include "zcl_hvac.h"
    #include "zcl_samplelight.h"
    #ifdef BDB_REPORTING
    #include "zstackapi.h"
    #endif
    /*********************************************************************
    * CONSTANTS
    */
    #define SAMPLELIGHT_DEVICE_VERSION 1
    #define SAMPLELIGHT_FLAGS 0
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • 目前无法实现,板子不在手边
  • 等您有空的时候能否帮忙看看呢?十分感谢
x 出现错误。请重试或与管理员联系。