⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mt_zdo.lst

📁 用IAR开发的ZIGBEE网络路由例子
💻 LST
📖 第 1 页 / 共 5 页
字号:
    944          
    945          #if defined ( ZDO_MGMT_LQI_REQUEST )
    946          /*********************************************************************
    947           * @fn      zdo_MTCB_MgmtLqiRspCB()
    948           *
    949           * @brief
    950           *
    951           *   Called to send MT callback response for Management LQI response
    952           *
    953           * @param  type - binding type (end device, bind, unbind)
    954           * @param  SrcAddr  - Source address
    955           * @param  Status - response status
    956           *
    957           * @return  none
    958           */
    959          void zdo_MTCB_MgmtLqiRspCB( uint16 SrcAddr, byte Status, byte NeighborLqiEntries,
    960                                      byte StartIndex, byte NeighborLqiCount,
    961                                      neighborLqiItem_t *pList )
    962          {
    963            byte *msgPtr;
    964            byte *msg;
    965            byte len;
    966            byte x;
    967            byte proVer = NLME_GetProtocolVersion();  
    968            
    969            /*Allocate a message of size equivalent to the corresponding SPI message
    970            (plus a couple of bytes for MT use)so that the same buffer can be sent by
    971            MT to the test tool by simply setting the header bytes.*/
    972          
    973            /*In order to allocate the message , we need to know the length and this
    974            has to be calculated before we allocate the message*/
    975          
    976            len = 2 + 1 + 1 + 1 + 1 + (ZDP_NEIGHBORLQI_SIZE * ZDO_MAX_LQI_ITEMS );
    977              //  SrcAddr + Status + NeighborLqiEntries + StartIndex + NeighborLqiCount
    978              //     + (maximum entries * size of struct)
    979           
    980            msgPtr = osal_mem_alloc( len );
    981          
    982            if ( msgPtr )
    983            {
    984              msg = msgPtr;
    985          
    986              //Fill up the data bytes
    987              
    988              *msg++ = HI_UINT16( SrcAddr );
    989              *msg++ = LO_UINT16( SrcAddr );    
    990              *msg++ = Status;
    991              *msg++ = NeighborLqiEntries;
    992              *msg++ = StartIndex;
    993              *msg++ = NeighborLqiCount;
    994          
    995              osal_memset( msg, 0, (ZDP_NEIGHBORLQI_SIZE * ZDO_MAX_LQI_ITEMS) );
    996          
    997              for ( x = 0; x < ZDO_MAX_LQI_ITEMS; x++ )
    998              {
    999                if ( x < NeighborLqiCount )
   1000                {
   1001                  if ( proVer == ZB_PROT_V1_0 )
   1002                  {
   1003                    *msg++ = HI_UINT16( pList->PANId );
   1004                    *msg++ = LO_UINT16( pList->PANId );
   1005                  }
   1006                  else 
   1007                  {
   1008                    osal_cpyExtAddr(msg, pList->extPANId);
   1009                    msg += Z_EXTADDR_LEN;
   1010                  }
   1011                  *msg++ = HI_UINT16( pList->nwkAddr );
   1012                  *msg++ = LO_UINT16( pList->nwkAddr );
   1013                  *msg++ = pList->rxLqi;
   1014                  *msg++ = pList->txQuality;
   1015                  pList++;
   1016                }
   1017              }
   1018          
   1019              MT_BuildAndSendZToolCB( SPI_CB_ZDO_MGMT_LQI_RSP, len, msgPtr );
   1020          
   1021              osal_mem_free( msgPtr );
   1022            }
   1023          }
   1024          #endif // ZDO_MGMT_LQI_REQUEST
   1025          
   1026          #if defined ( ZDO_MGMT_NWKDISC_REQUEST )
   1027          /*********************************************************************
   1028           * @fn      zdo_MTCB_MgmtNwkDiscRspCB()
   1029           *
   1030           * @brief
   1031           *
   1032           *   Called to send MT callback response for Management Network
   1033           *   Discover response
   1034           *
   1035           * @param  SrcAddr  - Source address
   1036           * @param  Status - response status
   1037           *
   1038           * @return  none
   1039           */
   1040          void zdo_MTCB_MgmtNwkDiscRspCB( uint16 SrcAddr, byte Status,
   1041                                  byte NetworkCount, byte StartIndex,
   1042                                  byte networkListCount, mgmtNwkDiscItem_t *pList )
   1043          {
   1044            byte *msgPtr;
   1045            byte *msg;
   1046            byte len;
   1047            byte x;
   1048            byte proVer = NLME_GetProtocolVersion();  
   1049             
   1050          
   1051            /*Allocate a message of size equivalent to the corresponding SPI message
   1052            (plus a couple of bytes for MT use)so that the same buffer can be sent by
   1053            MT to the test tool by simply setting the header bytes.*/
   1054          
   1055            /*In order to allocate the message , we need to know the length and this
   1056            has to be calculated before we allocate the message*/
   1057            if ( proVer == ZB_PROT_V1_0 )
   1058            {
   1059              len = 2 + 1 + 1 + 1 + 1 + (ZDP_NETWORK_DISCRIPTOR_SIZE * ZDO_MAX_NWKDISC_ITEMS);
   1060                //  SrcAddr + Status + NetworkCount + StartIndex + networkListCount
   1061                //     + (maximum entries * size of struct)
   1062            }
   1063            else
   1064            {
   1065              len = 2 + 1 + 1 + 1 + 1 + (ZDP_NETWORK_EXTENDED_DISCRIPTOR_SIZE * ZDO_MAX_NWKDISC_ITEMS);
   1066           
   1067            }
   1068          
   1069            msgPtr = osal_mem_alloc( len );
   1070          
   1071            if ( msgPtr )
   1072            {
   1073              msg = msgPtr;
   1074          
   1075              //Fill up the data bytes
   1076              *msg++ = HI_UINT16( SrcAddr );
   1077              *msg++ = LO_UINT16( SrcAddr );
   1078              *msg++ = Status;
   1079              *msg++ = NetworkCount;
   1080              *msg++ = StartIndex;
   1081              *msg++ = networkListCount;
   1082          
   1083              osal_memset( msg, 0, (ZDP_NETWORK_DISCRIPTOR_SIZE * ZDO_MAX_NWKDISC_ITEMS) );
   1084          
   1085              for ( x = 0; x < ZDO_MAX_NWKDISC_ITEMS; x++ )
   1086              {
   1087                if ( x < networkListCount )
   1088                {
   1089                  if ( proVer == ZB_PROT_V1_0 )
   1090                  {
   1091                    *msg++ = HI_UINT16( pList->PANId );
   1092                    *msg++ = LO_UINT16( pList->PANId );
   1093                  }
   1094                  else
   1095                  {
   1096                    osal_cpyExtAddr( msg, pList->extendedPANID );
   1097                    msg += Z_EXTADDR_LEN;
   1098                  }
   1099                  *msg++ = pList->logicalChannel;
   1100                  *msg++ = pList->stackProfile;
   1101                  *msg++ = pList->version;
   1102                  *msg++ = pList->beaconOrder;
   1103                  *msg++ = pList->superFrameOrder;
   1104                  *msg++ = pList->permitJoining;
   1105                  pList++;
   1106                }
   1107              }
   1108          
   1109              MT_BuildAndSendZToolCB( SPI_CB_ZDO_MGMT_NWKDISC_RSP, len, msgPtr );
   1110          
   1111              osal_mem_free( msgPtr );
   1112            }
   1113          }
   1114          #endif // ZDO_MGMT_NWKDISC_REQUEST
   1115          
   1116          #if defined ( ZDO_MGMT_RTG_REQUEST )
   1117          /*********************************************************************
   1118           * @fn      zdo_MTCB_MgmtRtgRspCB()
   1119           *
   1120           * @brief
   1121           *
   1122           *   Called to send MT callback response for Management Network
   1123           *   Discover response
   1124           *
   1125           * @param  SrcAddr  - Source address
   1126           * @param  Status - response status
   1127           *
   1128           * @return  none
   1129           */
   1130          void zdo_MTCB_MgmtRtgRspCB( uint16 SrcAddr, byte Status,
   1131                                  byte RtgCount, byte StartIndex,
   1132                                  byte RtgListCount, rtgItem_t *pList )
   1133          {
   1134            byte *msgPtr;
   1135            byte *msg;
   1136            byte len;
   1137            byte x;
   1138          
   1139            /*Allocate a message of size equivalent to the corresponding SPI message
   1140            (plus a couple of bytes for MT use)so that the same buffer can be sent by
   1141            MT to the test tool by simply setting the header bytes.*/
   1142          
   1143            /*In order to allocate the message , we need to know the length and this
   1144            has to be calculated before we allocate the message*/
   1145          
   1146            len = 2 + 1 + 1 + 1 + 1 + (ZDP_RTG_DISCRIPTOR_SIZE * ZDO_MAX_RTG_ITEMS);
   1147                //  SrcAddr + Status + RtgCount + StartIndex + RtgListCount
   1148                //     + (maximum entries * size of struct)
   1149          
   1150            msgPtr = osal_mem_alloc( len );
   1151          
   1152            if ( msgPtr )
   1153            {
   1154              msg = msgPtr;
   1155          
   1156              //Fill up the data bytes
   1157              *msg++ = HI_UINT16( SrcAddr );
   1158              *msg++ = LO_UINT16( SrcAddr );
   1159              *msg++ = Status;
   1160              *msg++ = RtgCount;
   1161              *msg++ = StartIndex;
   1162              *msg++ = RtgListCount;
   1163          
   1164              osal_memset( msg, 0, (ZDP_RTG_DISCRIPTOR_SIZE * ZDO_MAX_RTG_ITEMS) );
   1165          
   1166              for ( x = 0; x < ZDO_MAX_RTG_ITEMS; x++ )
   1167              {
   1168                if ( x < RtgListCount )
   1169                {
   1170                  *msg++ = HI_UINT16( pList->dstAddress );
   1171                  *msg++ = LO_UINT16( pList->dstAddress );
   1172                  *msg++ = HI_UINT16( pList->nextHopAddress );
   1173                  *msg++ = LO_UINT16( pList->nextHopAddress );
   1174                  *msg++ = pList->status;
   1175                  pList++;
   1176                }
   1177              }
   1178          
   1179              MT_BuildAndSendZToolCB( SPI_CB_ZDO_MGMT_RTG_RSP, len, msgPtr );
   1180          
   1181              osal_mem_free( msgPtr );
   1182            }
   1183          }
   1184          #endif // ZDO_MGMT_RTG_REQUEST
   1185          
   1186          #if defined ( ZDO_MGMT_BIND_REQUEST )
   1187          /*********************************************************************
   1188           * @fn      zdo_MTCB_MgmtBindRspCB()
   1189           *
   1190           * @brief
   1191           *
   1192           *   Called to send MT callback response for Management Network
   1193           *   Discover response
   1194           *
   1195           * @param  SrcAddr  - Source address
   1196           * @param  Status - response status
   1197           *
   1198           * @return  none
   1199           */
   1200          void zdo_MTCB_MgmtBindRspCB( uint16 SrcAddr, byte Status,
   1201                                  byte BindCount, byte StartIndex,
   1202                                  byte BindListCount, apsBindingItem_t *pList )
   1203          {
   1204            byte *msgPtr;
   1205            byte *msg;
   1206            byte len;       
   1207            byte x;
   1208            uint8 protoVer = NLME_GetProtocolVersion();
   1209            
   1210   

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -