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.

cc2530无法烧录

Other Parts Discussed in Thread: CC2530

您好,我在CC2530烧录路由代码(sampleR)出现了这个问题,你们知道什么问题吗

  • 就这个报错而言,是内存不足
  • 是的,请问怎么解决
  • 試試降低global variable的size
  • 请问是否用的zigbee3.0?建议按照如下文档的要求优化内存使用:
    www.ti.com/.../swra635.pdf
  • 我们使用的是zstack home,是否可以提供相关文档

  • 您好,从哪里可以设置
  • 這個通常是你的應用程序用了很大的array或是數量很大的global variables造成,你要自己查一下程序
  • 我们是实现这种功能,那路由是否需要白名单,还是直接删除

  • 不大懂你的問題,這跟白名单,还是直接删除好像沒什麼關聯
  • 那你可以帮我看一下工程吗?在哪个文件夹下面的
  • 看一下什麼工程?
  • 裡面只有一個GenericApp.eww檔案,請問是要看什麼?
  • 你好,那需要整个工程上传吗?我是想让你看一下那个代码
  • /******************************************************************************
    Filename:       GenericApp.c
    Revised:        $Date: 2014-09-07 13:36:30 -0700 (Sun, 07 Sep 2014) $
    Revision:       $Revision: 40046 $
    
    Description:    Generic Application (no Profile).
    
    
    Copyright 2004-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.
    ******************************************************************************/
    
    /*********************************************************************
    This application isn't intended to do anything useful - it is
    intended to be a simple example of an application's structure.
    
    This application periodically sends a "Hello World" message to
    another "Generic" application (see 'txMsgDelay'). The application
    will also receive "Hello World" packets.
    
    This application doesn't have a profile, so it handles everything
    directly - by itself.
    
    Key control:
    SW1:  changes the delay between TX packets
    SW2:  initiates end device binding
    SW3:
    SW4:  initiates a match description request
    *********************************************************************/
    
    /*********************************************************************
    * INCLUDES
    */
    #include "OSAL.h"
    #include "AF.h"
    #include "ZDApp.h"
    #include "ZDObject.h"
    #include "ZDProfile.h"
    
    #include "GenericApp.h"
    #include "DebugTrace.h"
    #include "nwk_util.h"
    #include "MT_UART.h"// ���ô���ͷ�ļ�
    #include "string.h"
    #if !defined( WIN32 ) || defined( ZBIT )
    #include "OnBoard.h"
    #endif
    
    /* HAL */
    #include "hal_lcd.h"
    #include "hal_led.h"
    #include "hal_key.h"
    #include "hal_uart.h"
    
    /* RTOS */
    #if defined( IAR_ARMCM3_LM )
    #include "RTOS_App.h"
    #endif
    
    /*********************************************************************
    * MACROS
    */
    
    /*********************************************************************
    * CONSTANTS
    */
    extern uint8 extendAddr[20][8];
    uint8 contanst=20;
    uint8 asc_16[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
    /*********************************************************************
    * TYPEDEFS
    */
    
    /*********************************************************************
    * GLOBAL VARIABLES
    */
    // This list should be filled with Application specific Cluster IDs.
    const cId_t GenericApp_ClusterList[GENERICAPP_MAX_CLUSTERS] =
    {
      GENERICAPP_CLUSTERID
    };
    
    const SimpleDescriptionFormat_t GenericApp_SimpleDesc =
    {
      GENERICAPP_ENDPOINT,              //  int Endpoint;
      GENERICAPP_PROFID,                //  uint16 AppProfId[2];
      GENERICAPP_DEVICEID,              //  uint16 AppDeviceId[2];
      GENERICAPP_DEVICE_VERSION,        //  int   AppDevVer:4;
      GENERICAPP_FLAGS,                 //  int   AppFlags:4;
      GENERICAPP_MAX_CLUSTERS,          //  byte  AppNumInClusters;
      (cId_t *)GenericApp_ClusterList,  //  byte *pAppInClusterList;
      GENERICAPP_MAX_CLUSTERS,          //  byte  AppNumInClusters;
      (cId_t *)GenericApp_ClusterList   //  byte *pAppInClusterList;
    };
    
    // This is the Endpoint/Interface description.  It is defined here, but
    // filled-in in GenericApp_Init().  Another way to go would be to fill
    // in the structure here and make it a "const" (in code space).  The
    // way it's defined in this sample app it is define in RAM.
    endPointDesc_t GenericApp_epDesc;
    
    /*********************************************************************
    * EXTERNAL VARIABLES
    */
    
    /*********************************************************************
    * EXTERNAL FUNCTIONS
    */
    
    /*********************************************************************
    * LOCAL VARIABLES
    */
    byte GenericApp_TaskID;   // Task ID for internal task/event processing
    // This variable will be received when
    // GenericApp_Init() is called.
    
    devStates_t GenericApp_NwkState;
    
    byte GenericApp_TransID;  // This is the unique message ID (counter)
    
    afAddrType_t GenericApp_DstAddr;
    
    afAddrType_t Point_To_Point_DstAddr;//��Ե�����
    //RSSI 
    uint8 rssi_buff[13];
    uint16 devShortAddr;//�豸�̵�ַ
    uint16 parentShortAddr;
    ZLongAddr_t devExtAddr;
    uint8 neighbor_count=0;
    uint8 neighbor_count_index=0;
    uint8 neighbor=0;
    uint16 neighbor_shortaddr;//�ھӶ̵�ַ
    uint8 neighbor_addr[42];
    uint8 data_Shortaddr[2];//��·��̵�ַ
    uint8 Order_Rssi[10][13]=0;//�洢һ��ѭ���ɼ�������RSSI��ֵ
    uint8 Order_Rssi_index ;
    uint8 index_array_limit;
    char route_send_coor[30];
    //��������
    uint8 send_data[13];
    uint8 send_count;
    
    uint8 Order_count=0;//�ɼ��������ݽ���ͳ���ж�
    uint8 Re_notify=21;//����ͬһ��·���ٴε���
    uint8 Re_notify_temp=21;//����ͬһ��·���ٴε���
    uint8 Re_notify_count=0;//����ͬһ��·�ɱ���������������εļ���
    neighborEntry_t neighbor_message;
    // Number of recieved messages
    static uint16 rxMsgCount;
    
    // Time interval between sending messages
    static uint32 txMsgDelay = GENERICAPP_SEND_MSG_TIMEOUT;
    
    /*********************************************************************
    * LOCAL FUNCTIONS
    */
    static void GenericApp_ProcessZDOMsgs( zdoIncomingMsg_t *inMsg );
    static void GenericApp_HandleKeys( byte shift, byte keys );
    static void GenericApp_MessageMSGCB( afIncomingMSGPacket_t *pckt );
    static void GenericApp_SendTheMessage( void ); //�㲥
    static void GenericApp_SendRouteMessage( void );//·����·�ɵ���
    static void GenericApp_SendPointToPointMessage( void ) ;// ·�ɶ�Э������������
    static void GenericApp_SendPointToPointToCoordMessage( void );//�����ж��ھӽڵ��Ƿ�
    static void GenericApp_SendPointToPointToCoordMessage1( void );//�����ж��ھӽڵ��Ƿ�
    static void GenericApp_RouteToCoordMessage( void );
    static void GenericApp_Receive( void );
    #if defined( IAR_ARMCM3_LM )
    static void GenericApp_ProcessRtosMessage( void );
    #endif
    
    /*********************************************************************
    * NETWORK LAYER CALLBACKS
    */
    
    /*********************************************************************
    * PUBLIC FUNCTIONS
    */
    
    /*********************************************************************
    * @fn      GenericApp_Init
    *
    * @brief   Initialization function for the Generic App Task.
    *          This is called during initialization and should contain
    *          any application specific initialization (ie. hardware
    *          initialization/setup, table initialization, power up
    *          notificaiton ... ).
    *
    * @param   task_id - the ID assigned by OSAL.  This ID should be
    *                    used to send messages and set timers.
    *
    * @return  none
    */
    void GenericApp_Init( uint8 task_id )
    {
      
      GenericApp_TaskID = task_id;
      GenericApp_NwkState = DEV_INIT;
      GenericApp_TransID = 0;
      
      MT_UartInit(); //���ڳ�ʼ��
      MT_UartRegisterTaskID(task_id);//��Ӵ�������
      // HalUARTWrite(0," hello world " ,13);//����ʹ��
      
      // Device hardware initialization can be added here or in main() (Zmain.c).
      // If the hardware is application specific - add it here.
      // If the hardware is other parts of the device add it in main().
      
      GenericApp_DstAddr.addrMode = (afAddrMode_t)Addr16Bit;
      GenericApp_DstAddr.endPoint = GENERICAPP_ENDPOINT;
      GenericApp_DstAddr.addr.shortAddr = 0xFFFF;
      
      Point_To_Point_DstAddr.addrMode = (afAddrMode_t)Addr16Bit; //  �㲥
      Point_To_Point_DstAddr.endPoint = GENERICAPP_ENDPOINT;     //ע���Ƿ���Ҫ�޸�
      
      
      
      // Fill out the endpoint description.
      GenericApp_epDesc.endPoint = GENERICAPP_ENDPOINT;
      GenericApp_epDesc.task_id = &GenericApp_TaskID;
      GenericApp_epDesc.simpleDesc
        = (SimpleDescriptionFormat_t *)&GenericApp_SimpleDesc;
      GenericApp_epDesc.latencyReq = noLatencyReqs;
      
      // Register the endpoint description with the AF
      afRegister( &GenericApp_epDesc );
      
      // Register for all key events - This app will handle all key events
      RegisterForKeys( GenericApp_TaskID );
      
      // Update the display
    #if defined ( LCD_SUPPORTED )
      HalLcdWriteString( "GenericApp", HAL_LCD_LINE_1 );
    #endif
      
      ZDO_RegisterForZDOMsg( GenericApp_TaskID, End_Device_Bind_rsp );
      ZDO_RegisterForZDOMsg( GenericApp_TaskID, Match_Desc_rsp );
      
    #if defined( IAR_ARMCM3_LM )
      // Register this task with RTOS task initiator
      RTOS_RegisterApp( task_id, GENERICAPP_RTOS_MSG_EVT );
    #endif
    }
    
    /*********************************************************************
    * @fn      GenericApp_ProcessEvent
    *
    * @brief   Generic Application Task event processor.  This function
    *          is called to process all events for the task.  Events
    *          include timers, messages and any other user defined events.
    *
    * @param   task_id  - The OSAL assigned task ID.
    * @param   events - events to process.  This is a bit map and can
    *                   contain more than one event.
    *
    * @return  none
    */
    uint16 GenericApp_ProcessEvent( uint8 task_id, uint16 events )
    {
      afIncomingMSGPacket_t *MSGpkt;
      afDataConfirm_t *afDataConfirm;
      
      // Data Confirmation message fields
      byte sentEP;
      ZStatus_t sentStatus;
      byte sentTransID;       // This should match the value sent
      (void)task_id;  // Intentionally unreferenced parameter
      
      if ( events & SYS_EVENT_MSG )
      {
        MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( GenericApp_TaskID );
        while ( MSGpkt )
        {
          switch ( MSGpkt->hdr.event )
          {
          case ZDO_CB_MSG:
            GenericApp_ProcessZDOMsgs( (zdoIncomingMsg_t *)MSGpkt );
            break;
            
          case KEY_CHANGE:
            GenericApp_HandleKeys( ((keyChange_t *)MSGpkt)->state, ((keyChange_t *)MSGpkt)->keys );
            break;
            
          case AF_DATA_CONFIRM_CMD:
            // This message is received as a confirmation of a data packet sent.
            // The status is of ZStatus_t type [defined in ZComDef.h]
            // The message fields are defined in AF.h
            afDataConfirm = (afDataConfirm_t *)MSGpkt;
            
            sentEP = afDataConfirm->endpoint;
            (void)sentEP;  // This info not used now
            sentTransID = afDataConfirm->transID;
            (void)sentTransID;  // This info not used now
            
            sentStatus = afDataConfirm->hdr.status;
            // Action taken when confirmation is received.
            if ( sentStatus != ZSuccess )
            {
              // The data wasn't delivered -- Do something
            }
            break;
            
          case AF_INCOMING_MSG_CMD:
            GenericApp_MessageMSGCB( MSGpkt );
            break;
            
          case ZDO_STATE_CHANGE:
            GenericApp_NwkState = (devStates_t)(MSGpkt->hdr.status);
            if ( (GenericApp_NwkState == DEV_ZB_COORD) ||  //�㲥��ʱ��Э���������Լ��㲥�Լ� ��Ҫ����
                (GenericApp_NwkState == DEV_ROUTER) ||
                  (GenericApp_NwkState == DEV_END_DEVICE) )
            {
              // Start sending "the" message in a regular interval.
              osal_start_timerEx( GenericApp_TaskID,
                                 GENERICAPP_SEND_MSG_EVT,
                                 txMsgDelay );
            }
            break;
            
          default:
            break;
          }
          
          // Release the memory
          osal_msg_deallocate( (uint8 *)MSGpkt );
          
          // Next
          MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( GenericApp_TaskID );
        }
        
        // return unprocessed events
        return (events ^ SYS_EVENT_MSG);
      }
      
      //�㲥�¼�
      if ( events & GENERICAPP_SEND_MSG_EVT )
      {
        // GenericApp_SendTheMessage();   
        // Setup to send message again
        
        // return unprocessed events
        return (events ^ GENERICAPP_SEND_MSG_EVT);
      }
      
      //���յ�������Ϣ����л�Ӧ�ĵ���
      if ( events & GENERICAPP_SEND_MSG_EVT2 )
      {
        
        GenericApp_SendPointToPointMessage();            //���͵�����Ϣ
        // Setup to send message again
        
        // return unprocessed events
        return (events ^ GENERICAPP_SEND_MSG_EVT2);
      }
      
      
      // Send a message out - This event is generated by a timer
      //  ����·�ɱ�
      if ( events & GENERICAPP_SEND_MSG_EVT3 )
      {
    
        if(neighbor_count==contanst)
        {
          for(int index_i = 0; index_i<index_array_limit; index_i++)
          {
            if(Order_Rssi[index_i][0] == 0 &&Order_Rssi[index_i][1]==0 && Order_Rssi[index_i][2] ==0 &&Order_Rssi[index_i][3] ==0)
            {
              Order_Rssi[index_i][0] = asc_16[0];
              Order_Rssi[index_i][1] = asc_16[0];
              Order_Rssi[index_i][2] = asc_16[0];
              Order_Rssi[index_i][3] = asc_16[0];
              Order_Rssi[index_i][4] = ':';
              Order_Rssi[index_i][5] = asc_16[0];
              Order_Rssi[index_i][6] = asc_16[0];
              Order_Rssi[index_i][7] = asc_16[0];
              Order_Rssi[index_i][8] = asc_16[0];
              Order_Rssi[index_i][9] = ':';
              Order_Rssi[index_i][10]='-';
              Order_Rssi[index_i][11]=asc_16[0];
              Order_Rssi[index_i][12]=asc_16[0];
            }
          }
          send_count=0;
          osal_start_timerEx(GenericApp_TaskID,
                             GENERICAPP_SEND_MSG_EVT5,
                             10);
        }
        else
        {   
          Point_To_Point_DstAddr.addr.shortAddr = ((neighbor_addr[neighbor_count*2]&0x00FF)<<8)|(neighbor_addr[neighbor_count*2+1]);      //���Լ��Ĵ洢�б��в��������ַ
          GenericApp_SendRouteMessage();   
          osal_start_timerEx( GenericApp_TaskID,
                             GENERICAPP_SEND_MSG_EVT4,
                             200 );
          
        }
        
        
        return (events ^ GENERICAPP_SEND_MSG_EVT3);
      }
      if ( events & GENERICAPP_SEND_MSG_EVT4 )
      {
        
    //    if(Re_notify_count<2)
    //    {
    //      Re_notify_count++;//ͬһ���豸ֻ�ܵ�������
    //      Point_To_Point_DstAddr.addr.shortAddr = ((neighbor_addr[neighbor_count*2]& 0x00FF)<<8)|(neighbor_addr[neighbor_count*2+1]); //���µ㲥
    //      GenericApp_SendRouteMessage();   //���µ���
    //      osal_start_timerEx( GenericApp_TaskID,
    //                         GENERICAPP_SEND_MSG_EVT4,
    //                         200 );
    //    }
    //    else
    //    {  
    //      Re_notify_count =0;//������������
          neighbor_count = neighbor_count + 1;
          osal_start_timerEx( GenericApp_TaskID,
                             GENERICAPP_SEND_MSG_EVT3,
                             10 );
    //    }
        
        // GenericApp_Receive();            //���͵�����Ϣ
        // Setup to send message again
        
        // return unprocessed events
        return (events ^ GENERICAPP_SEND_MSG_EVT4);
      }
      if ( events & GENERICAPP_SEND_MSG_EVT5 )
      {
        if(send_count!=index_array_limit)
        {
          
          osal_memcpy(send_data,Order_Rssi[send_count],13);
          GenericApp_RouteToCoordMessage();            //���͵�����Ϣ  
          send_count++;
          osal_start_timerEx(GenericApp_TaskID,
                             GENERICAPP_SEND_MSG_EVT5,
                             10);
        }
        else
        {
          send_count=0;
          osal_memset(send_data,0,sizeof(send_data));
        }
        
        // Setup to send message again
        // return unprocessed events
        return (events ^ GENERICAPP_SEND_MSG_EVT5);
      }
      
    #if defined( IAR_ARMCM3_LM )
      // Receive a message from the RTOS queue
      if ( events & GENERICAPP_RTOS_MSG_EVT )
      {
        // Process message from RTOS queue
        GenericApp_ProcessRtosMessage();
        
        // return unprocessed events
        return (events ^ GENERICAPP_RTOS_MSG_EVT);
      }
    #endif
      
      // Discard unknown events
      return 0;
    }
    
    /*********************************************************************
    * Event Generation Functions
    */
    
    /*********************************************************************
    * @fn      GenericApp_ProcessZDOMsgs()
    *
    * @brief   Process response messages
    *
    * @param   none
    *
    * @return  none
    */
    static void GenericApp_ProcessZDOMsgs( zdoIncomingMsg_t *inMsg )
    {
      switch ( inMsg->clusterID )
      {
      case End_Device_Bind_rsp:
        if ( ZDO_ParseBindRsp( inMsg ) == ZSuccess )
        {
          // Light LED
          HalLedSet( HAL_LED_4, HAL_LED_MODE_ON );
        }
    #if defined( BLINK_LEDS )
        else
        {
          // Flash LED to show failure
          HalLedSet ( HAL_LED_4, HAL_LED_MODE_FLASH );
        }
    #endif
        break;
        
      case Match_Desc_rsp:
        {
          ZDO_ActiveEndpointRsp_t *pRsp = ZDO_ParseEPListRsp( inMsg );
          if ( pRsp )
          {
            if ( pRsp->status == ZSuccess && pRsp->cnt )
            {
              GenericApp_DstAddr.addrMode = (afAddrMode_t)Addr16Bit;
              GenericApp_DstAddr.addr.shortAddr = pRsp->nwkAddr;
              // Take the first endpoint, Can be changed to search through endpoints
              GenericApp_DstAddr.endPoint = pRsp->epList[0];
              
              // Light LED
              HalLedSet( HAL_LED_4, HAL_LED_MODE_ON );
            }
            osal_mem_free( pRsp );
          }
        }
        break;
      }
    }
    
    /*********************************************************************
    * @fn      GenericApp_HandleKeys
    *
    * @brief   Handles all key events for this device.
    *
    * @param   shift - true if in shift/alt.
    * @param   keys - bit field for key events. Valid entries:
    *                 HAL_KEY_SW_4
    *                 HAL_KEY_SW_3
    *                 HAL_KEY_SW_2
    *                 HAL_KEY_SW_1
    *
    * @return  none
    */
    static void GenericApp_HandleKeys( uint8 shift, uint8 keys )
    {
      zAddrType_t dstAddr;
      
      // Shift is used to make each button/switch dual purpose.
      if ( shift )
      {
        if ( keys & HAL_KEY_SW_1 )
        {
        }
        if ( keys & HAL_KEY_SW_2 )
        {
        }
        if ( keys & HAL_KEY_SW_3 )
        {
        }
        if ( keys & HAL_KEY_SW_4 )
        {
        }
      }
      else
      {
        if ( keys & HAL_KEY_SW_1 )
        {
    #if defined( SWITCH1_BIND )
          // We can use SW1 to simulate SW2 for devices that only have one switch,
          keys |= HAL_KEY_SW_2;
    #elif defined( SWITCH1_MATCH )
          // or use SW1 to simulate SW4 for devices that only have one switch
          keys |= HAL_KEY_SW_4;
    #else
          // Normally, SW1 changes the rate that messages are sent
          if ( txMsgDelay > 100 )
          {
            // Cut the message TX delay in half
            txMsgDelay /= 2;
          }
          else
          {
            // Reset to the default
            txMsgDelay = GENERICAPP_SEND_MSG_TIMEOUT;
          }
    #endif
        }
        
        if ( keys & HAL_KEY_SW_2 )
        {
          //HalLedSet ( HAL_LED_4, HAL_LED_MODE_OFF );
          
          // Initiate an End Device Bind Request for the mandatory endpoint
          dstAddr.addrMode = Addr16Bit;
          dstAddr.addr.shortAddr = 0x0000; // Coordinator
          ZDP_EndDeviceBindReq( &dstAddr, NLME_GetShortAddr(),
                               GenericApp_epDesc.endPoint,
                               GENERICAPP_PROFID,
                               GENERICAPP_MAX_CLUSTERS, (cId_t *)GenericApp_ClusterList,
                               GENERICAPP_MAX_CLUSTERS, (cId_t *)GenericApp_ClusterList,
                               FALSE );
        }
        
        if ( keys & HAL_KEY_SW_3 )
        {
        }
        
        if ( keys & HAL_KEY_SW_4 )
        {
          HalLedSet ( HAL_LED_4, HAL_LED_MODE_OFF );
          // Initiate a Match Description Request (Service Discovery)
          dstAddr.addrMode = AddrBroadcast;
          dstAddr.addr.shortAddr = NWK_BROADCAST_SHORTADDR;
          ZDP_MatchDescReq( &dstAddr, NWK_BROADCAST_SHORTADDR,
                           GENERICAPP_PROFID,
                           GENERICAPP_MAX_CLUSTERS, (cId_t *)GenericApp_ClusterList,
                           GENERICAPP_MAX_CLUSTERS, (cId_t *)GenericApp_ClusterList,
                           FALSE );
        }
      }
    }
    
    /*********************************************************************
    * LOCAL FUNCTIONS
    */
    
    /*********************************************************************
    * @fn      GenericApp_MessageMSGCB
    *
    * @brief   Data message processor callback.  This function processes
    *          any incoming data - probably from other devices.  So, based
    *          on cluster ID, perform the intended action.
    *
    * @param   none
    *
    * @return  none
    */
    static void GenericApp_MessageMSGCB( afIncomingMSGPacket_t *pkt )
    {
      devShortAddr = NLME_GetShortAddr( ); 
      uint8 Data[2];
      uint8 data[2];
      uint8 i;
      uint8 short_index;
      uint8  index_value_node ;
      switch ( pkt->clusterId )
      {
      case GENERICAPP_CLUSTERID_BROCAST:
        osal_memcpy( neighbor_addr, pkt->cmd.Data, pkt->cmd.DataLength);
        //        HalUARTWrite(0,neighbor_addr, sizeof(neighbor_addr) );
        break;
        
        //     ��������·���¼�
      case GENERICAPP_CLUSTERID1:     
        rssi_buff[5] = asc_16[pkt->srcAddr.addr.shortAddr/4096];
        rssi_buff[6] = asc_16[pkt->srcAddr.addr.shortAddr%4096/256];
        rssi_buff[7] = asc_16[pkt->srcAddr.addr.shortAddr%256/16];
        rssi_buff[8] = asc_16[pkt->srcAddr.addr.shortAddr%16];
        rssi_buff[9] = ':';
        pkt->rssi = 0xff - pkt->rssi;
        rssi_buff[10]='-';
        rssi_buff[11]=pkt->rssi/10 + 0x30;
        rssi_buff[12]=pkt->rssi%10 + 0x30;
        parentShortAddr=pkt->srcAddr.addr.shortAddr;
        osal_start_timerEx( GenericApp_TaskID,
                           GENERICAPP_SEND_MSG_EVT2,
                           20);
        break;
        
        //����Э��������·���¼�����Ϣ
      case GenericApp_POINT_TO_POINT_CLUSTERID:
        
        Order_Rssi[10][13]=0;
        Order_count=0;//�ɼ��������ݽ���ͳ���ж�
        neighbor_count=0;//������0��ʼ
        Re_notify=21;//����ͬһ��·���ٴε���
        Re_notify_temp=21;//����ͬһ��·���ٴε���
        Re_notify_count=0;//����ͬһ��·�ɱ���������������εļ���
        send_count=0;
        osal_stop_timerEx( GenericApp_TaskID, //���յ�19������û�д�����ʱ�¼���ʱ�򽫶�ʱ��ȡ��
                          GENERICAPP_SEND_MSG_EVT);
        osal_stop_timerEx( GenericApp_TaskID, //���յ�19������û�д�����ʱ�¼���ʱ�򽫶�ʱ��ȡ��
                          GENERICAPP_SEND_MSG_EVT2);
        osal_stop_timerEx( GenericApp_TaskID, //���յ�19������û�д�����ʱ�¼���ʱ�򽫶�ʱ��ȡ��
                          GENERICAPP_SEND_MSG_EVT3);
        osal_stop_timerEx( GenericApp_TaskID, //���յ�19������û�д�����ʱ�¼���ʱ�򽫶�ʱ��ȡ��
                          GENERICAPP_SEND_MSG_EVT4);
        osal_stop_timerEx( GenericApp_TaskID, //���յ�19������û�д�����ʱ�¼���ʱ�򽫶�ʱ��ȡ��
                          GENERICAPP_SEND_MSG_EVT5);
        
        osal_memcpy( neighbor_addr, pkt->cmd.Data, pkt->cmd.DataLength);//����Э�����������������ݣ���������ʱ����·�ɽڵ���豸�̵�ַ
        if (neighbor_addr[40]=='0' && neighbor_addr[41]=='0'||neighbor_addr[41]=='1')
        {
          neighbor_count=15;
          contanst =20;
        }
        else if(neighbor_addr[40]=='0' && neighbor_addr[41]=='8'||neighbor_addr[41]=='9')
        {
          neighbor_count=10;
          contanst =15;
        }
        else if (neighbor_addr[40]=='1' && neighbor_addr[41]=='8'||neighbor_addr[41]=='9')
        {
          neighbor_count=0;
          contanst =5;
        }
        else if (neighbor_addr[40]=='1' && neighbor_addr[41]=='0'||neighbor_addr[41]=='1')
        {
          neighbor_count=5;
          contanst =10;
        }
        else 
        {
          index_value_node = (neighbor_addr[40] - 0x30)*10+(neighbor_addr[41] - 0x30);
          if (index_value_node>0 && index_value_node<10)
          {
              neighbor_count= 10;
              contanst =17;
          }
          else
          {
              neighbor_count= 0;
              contanst = 7;
          }
    
        }
        index_array_limit = contanst -neighbor_count;
        neighbor_count_index = neighbor_count;
        osal_start_timerEx( GenericApp_TaskID,
                           GENERICAPP_SEND_MSG_EVT3,//����·�ɵ���·��
                           20);
        break;
        
        
        //·�ɽڵ���ջ㼯������Ϣ  
      case ROUTE_POINT_TO_POINT_CLUSTERID:
        osal_stop_timerEx( GenericApp_TaskID, //���յ�19������û�д�����ʱ�¼���ʱ�򽫶�ʱ��ȡ��
                          GENERICAPP_SEND_MSG_EVT4);
        for (uint8 kk = 0;kk<index_array_limit;kk++)
        { 
            short_index = neighbor_count_index + kk;
         
          neighbor_shortaddr=((neighbor_addr[short_index*2]&0x00FF)<<8)|(neighbor_addr[short_index*2+1]);
          if (neighbor_shortaddr == pkt->srcAddr.addr.shortAddr)
          {
            Order_Rssi_index= kk;
            break;
          }
        }
    //       if (Order_Rssi[Order_Rssi_index][0] != 0 && Order_Rssi[Order_Rssi_index][1] != 0 && Order_Rssi[Order_Rssi_index][2] != 0 && Order_Rssi[Order_Rssi_index][3] != 0 )
    //          {
    //            osal_memcpy( Order_Rssi[Order_Rssi_index], pkt->cmd.Data, 13);  
    //            Re_notify_count =0;//������������
    //          }
    //          else
    //          {
                osal_memcpy( Order_Rssi[Order_Rssi_index], pkt->cmd.Data, 13);  
                Re_notify_count =0;//������������
                neighbor_count++; 
    //          }
          if(neighbor_count<contanst)
          {
            osal_start_timerEx( GenericApp_TaskID,
                               GENERICAPP_SEND_MSG_EVT3,
                               20 );
          }
          else
          {
            for(int index_i = 0; index_i<index_array_limit; index_i++)
            {
              
              if(Order_Rssi[index_i][0] == 0 &&Order_Rssi[index_i][1]==0 && Order_Rssi[index_i][2] ==0 &&Order_Rssi[index_i][3] ==0)
              {
                 if (index_i == 0 )
                 {
                   if ( Order_Rssi[index_i+1][0] != 0)
                   {
                     osal_memcpy( Order_Rssi[Order_Rssi_index], Order_Rssi[index_i+1], 13);  
                   } 
                   else
                   {
                     Order_Rssi[Order_Rssi_index][0] = asc_16[0];;
                     Order_Rssi[Order_Rssi_index][1] = asc_16[0];
                     Order_Rssi[Order_Rssi_index][2] = asc_16[0];
                     Order_Rssi[Order_Rssi_index][3] = asc_16[0];
                     Order_Rssi[Order_Rssi_index][4] = ':';
                     Order_Rssi[Order_Rssi_index][5] = asc_16[0];
                     Order_Rssi[Order_Rssi_index][6] = asc_16[0];
                     Order_Rssi[Order_Rssi_index][7] = asc_16[0];
                     Order_Rssi[Order_Rssi_index][8] = asc_16[0];
                     Order_Rssi[Order_Rssi_index][9] = ':';
                     Order_Rssi[Order_Rssi_index][10]='-';
                     Order_Rssi[Order_Rssi_index][11]=asc_16[0];
                     Order_Rssi[Order_Rssi_index][12]=asc_16[0];
                   }
                 }
                 else
                 {
                   osal_memcpy( Order_Rssi[Order_Rssi_index], Order_Rssi[index_i-1], 13);  
                 }
                   
              }
            }
            send_count=0;
            osal_start_timerEx( GenericApp_TaskID,
                               GENERICAPP_SEND_MSG_EVT5,
                               10 );
          }
    
        
        //    }
        
        
        //         HalUARTWrite(0,Order_Rssi[i], 13);
        //         HalUARTWrite(0,"\n",1 );
        break; 
      }
    }
    
    /*********************************************************************
    * @fn      GenericApp_SendTheMessage
    *
    * @brief   Send "devshortaddr" message.
    *
    * @param   none
    *
    * @return  none
    */
    static void GenericApp_SendTheMessage( void )
    {
      uint8 data[2];
      data[0] = HI_UINT16(devShortAddr);  
      data[1] =  LO_UINT16(devShortAddr);
      if ( AF_DataRequest( &GenericApp_DstAddr, &GenericApp_epDesc,
                          GENERICAPP_CLUSTERID,
                          2,
                          data,
                          &GenericApp_TransID,
                          AF_DISCV_ROUTE, AF_DEFAULT_RADIUS ) == afStatus_SUCCESS )
      {
        // Successfully requested to be sent.
        //HalUARTWrite(0,data, 2 );
      }
      else
      {
        // Error occurred in request to send.
      }
    }
    
    
    /*********************************************************************
    * @fn      GenericApp_SendRouteMessage
    *
    * @brief   Send "devshortaddr" message.������·��
    *
    * @param   none
    *
    * @return  none
    */
    static void GenericApp_SendRouteMessage( void )
    {
      
      uint8 data[2];
      data[0] = HI_UINT16(devShortAddr);  
      data[1] =  LO_UINT16(devShortAddr);
      if ( AF_DataRequest( &Point_To_Point_DstAddr, &GenericApp_epDesc,
                          GENERICAPP_CLUSTERID1,
                          2,
                          data,
                          &GenericApp_TransID,
                          AF_SKIP_ROUTING, AF_DEFAULT_RADIUS ) == afStatus_SUCCESS )
      {
        
      }
      else
      {
      }
    }
    
    #if defined( IAR_ARMCM3_LM )
    /*********************************************************************
    * @fn      GenericApp_ProcessRtosMessage
    *
    * @brief   Receive message from RTOS queue, send response back.
    *
    * @param   none
    *
    * @return  none
    */
    static void GenericApp_ProcessRtosMessage( void )
    {
      osalQueue_t inMsg;
      
      if ( osal_queue_receive( OsalQueue, &inMsg, 0 ) == pdPASS )
      {
        uint8 cmndId = inMsg.cmnd;
        uint32 counter = osal_build_uint32( inMsg.cbuf, 4 );
        
        switch ( cmndId )
        {
        case CMD_INCR:
          counter += 1;  /* Increment the incoming counter */
          /* Intentionally fall through next case */
          
        case CMD_ECHO:
          {
            userQueue_t outMsg;
            
            outMsg.resp = RSP_CODE | cmndId;  /* Response ID */
            osal_buffer_uint32( outMsg.rbuf, counter );    /* Increment counter */
            osal_queue_send( UserQueue1, &outMsg, 0 );  /* Send back to UserTask */
            break;
          }
          
        default:
          break;  /* Ignore unknown command */
        }
      }
    }
    #endif
    
    
    //�㲥�㼯������Դ
    void GenericApp_SendPointToPointMessage( void )
    {
      rssi_buff[0] = asc_16[devShortAddr/4096];
      rssi_buff[1] = asc_16[devShortAddr%4096/256];
      rssi_buff[2] = asc_16[devShortAddr%256/16];
      rssi_buff[3] = asc_16[devShortAddr%16];
      rssi_buff[4] = ':';
      //uint8 data[5]={'5','5','5','5','5'};
      Point_To_Point_DstAddr.addr.shortAddr = parentShortAddr;       //��������
      if( AF_DataRequest( &Point_To_Point_DstAddr,
                         &GenericApp_epDesc,
                         ROUTE_POINT_TO_POINT_CLUSTERID,
                         13,
                         rssi_buff,
                         &GenericApp_TransID,
                         AF_SKIP_ROUTING, AF_DEFAULT_RADIUS ) == afStatus_SUCCESS )
      {
        
        //    osal_memset(rssi_buff,0,sizeof(rssi_buff));
        
      }
      else
      {}
    }
    
    
    
    void GenericApp_SendPointToPointToCoordMessage( void )
    {
      char     theMessageData[13];
      Point_To_Point_DstAddr.addr.shortAddr = ((neighbor_addr[neighbor_count*2]& 0x00FF)<<8)|(neighbor_addr[neighbor_count*2+1]); //���µ㲥
      theMessageData[0] = asc_16[Point_To_Point_DstAddr.addr.shortAddr/4096];
      theMessageData[1] = asc_16[Point_To_Point_DstAddr.addr.shortAddr%4096/256];
      theMessageData[2] = asc_16[Point_To_Point_DstAddr.addr.shortAddr%256/16];
      theMessageData[3] = asc_16[Point_To_Point_DstAddr.addr.shortAddr%16];
      theMessageData[4] = ':';
      theMessageData[5] = asc_16[devShortAddr/4096];
      theMessageData[6] = asc_16[devShortAddr%4096/256];
      theMessageData[7] = asc_16[devShortAddr%256/16];
      theMessageData[8] = asc_16[devShortAddr%16];
      theMessageData[9] = ':';
      theMessageData[10] = 'E';
      theMessageData[11] = 'R';
      theMessageData[12] = 'R';
      //uint8 data[5]={'5','5','5','5','5'};
      Point_To_Point_DstAddr.addr.shortAddr = 0x0000;       //��������
      if( AF_DataRequest( &Point_To_Point_DstAddr,
                         &GenericApp_epDesc,
                         GenericApp_POINT_TO_POINT_CLUSTERID1,
                         (byte)osal_strlen( theMessageData ) + 1,
                         (byte *)&theMessageData,
                         &GenericApp_TransID,
                         AF_DISCV_ROUTE, AF_DEFAULT_RADIUS ) == afStatus_SUCCESS )
      {
        //HalUARTWrite(0,theMessageData, (byte)osal_strlen( theMessageData ) + 1 );
        osal_memset(theMessageData,0,13);
      }
      else
      {}
    }
    /*********************************************************************
    */
    void GenericApp_SendPointToPointToCoordMessage1( void )
    {
      //   char     theMessageData[30];
      //osal_memcpy(theMessageData,Order_Rssi[neighbor_count],13);
      //uint8 data[5]={'5','5','5','5','5'};
      Point_To_Point_DstAddr.addr.shortAddr = 0x0000;       //��������
      if( AF_DataRequest( &Point_To_Point_DstAddr,
                         &GenericApp_epDesc,
                         GenericApp_POINT_TO_POINT_CLUSTERID1,
                         (byte)osal_strlen( route_send_coor ) + 1,
                         (byte *)&route_send_coor,
                         &GenericApp_TransID,
                         AF_DISCV_ROUTE, AF_DEFAULT_RADIUS ) == afStatus_SUCCESS )
      {
        //HalUARTWrite(0,theMessageData, (byte)osal_strlen( theMessageData ) + 1 );
        osal_memset(route_send_coor,0,sizeof(route_send_coor));
      }
      else
      {}
    }
    
    void GenericApp_RouteToCoordMessage( void )
    {
      // for(uint8 i=0;i<contanst;i++)
      //{
      
      Point_To_Point_DstAddr.addr.shortAddr = 0x0000;       //��������
      //  osal_memcpy(send_data,Order_Rssi[i],13);
      if( AF_DataRequest( &Point_To_Point_DstAddr,
                         &GenericApp_epDesc,
                         GenericApp_POINT_TO_POINT_CLUSTERID,
                         osal_strlen(send_data),
                         send_data,
                         &GenericApp_TransID,
                         AF_DISCV_ROUTE, AF_DEFAULT_RADIUS ) == afStatus_SUCCESS )
      {
        osal_memset(send_data,0,sizeof(send_data));
      }
      else
      {}
      
    }
    
    
    
    void GenericApp_Receive( void )
    {
      //����б����Ƿ��յ���ͬ�ķ���Դ
      
      for(int j=0;j<contanst;j++)
      {
        if((Order_Rssi[j][5] != asc_16[devShortAddr/4096])||( Order_Rssi[j][6] != asc_16[devShortAddr%4096/256])||( Order_Rssi[j][7] != asc_16[devShortAddr%256/16])||( Order_Rssi[j][8] != asc_16[devShortAddr%16]))   //�����еġ�3����4��Ϊ·�ɵ���Դ��ַ �������ж�����ͬһ��Դ �����еĻ�ľ���յ����������ڵ��ٴ���ѯһ��
        {
          Re_notify=j;
          if(Order_count==(contanst-1))
          {
            Order_count--;//��ͳ�Ƶ�ֵɾ��1 
          }
          //osal_memset(Order_Rssi[j],0,sizeof(Order_Rssi[j]))
          osal_start_timerEx( GenericApp_TaskID,
                             GENERICAPP_SEND_MSG_EVT3,
                             20 );
          break;
        }
        if(j==(contanst-1))
        {
          Order_count=0;
          osal_start_timerEx( GenericApp_TaskID,
                             GENERICAPP_SEND_MSG_EVT5,
                             20 );
          
        }
      }
    }
    
    
    

  • 你減少一下這些array的大小試試

    //RSSI 
    uint8 rssi_buff[13];
    uint16 devShortAddr;//扢掘傻華硊
    uint16 parentShortAddr;
    ZLongAddr_t devExtAddr;
    uint8 neighbor_count=0;
    uint8 neighbor_count_index=0;
    uint8 neighbor=0;
    uint16 neighbor_shortaddr;//邁懈傻華硊
    uint8 neighbor_addr[42];
    uint8 data_Shortaddr[2];//蟈繚桶傻華硊
    uint8 Order_Rssi[10][13]=0;//湔揣珨跺悜遠粒摩隙懂腔RSSI腔硉
    uint8 Order_Rssi_index ;
    uint8 index_array_limit;
    char route_send_coor[30];
    

  • 你好,改成多少合适,我试了好像还是没用
  • 改小到你編譯不會產生xdata的問題
  • 您好,按照这个改已经不会报错了,但是我不知道这样行不行

  • 不会报错就是行了吧