罗菜鸟 发表于 2014-3-31 15:26
你函数用错了,函数MAC_CbackEvent接收到消息MAC_MLME_ASSOCIATE_IND才是节点入网请求。
我在// Filter out non-zigbee packets
else if(event == MAC_MLME_ASSOCIATE_IND)
判断后写的
// Filter out non-zigbee packets
if ( event == MAC_MCPS_DATA_IND )
{
uint8 fcFrameType = (pData->dataInd.msdu.p[0] & 0x03);
uint8 fcProtoVer = ((pData->dataInd.msdu.p[0] >> 2) & 0x0F);
uint8 fcReserve = (pData->dataInd.msdu.p[1] & 0xE0);
if ( (fcFrameType > 0x01) || (fcProtoVer != _NIB.nwkProtocolVersion) || (fcReserve != 0)
|| (pData->dataInd.mac.srcAddr.addrMode != SADDR_MODE_SHORT) )
{
// Drop the message
mac_msg_deallocate( (uint8 **)&pData );
return;
}
else if(event == MAC_MLME_ASSOCIATE_IND )//回调函数
{
mact[0]=pData->associateInd.deviceAddress [0]; //
mact[1]=pData->associateInd.deviceAddress [1];
mact[2]=pData->associateInd.deviceAddress [2];
mact[3]=pData->associateInd.deviceAddress [3];
mact[4]=pData->associateInd.deviceAddress [4];
mact[5]=pData->associateInd.deviceAddress [5];
mact[6]=pData->associateInd.deviceAddress [6];
mact[7]=pData->associateInd.deviceAddress [7];
}
还有这样也写过
if ( event == MAC_MCPS_DATA_IND )
{
uint8 fcFrameType = (pData->dataInd.msdu.p[0] & 0x03);
uint8 fcProtoVer = ((pData->dataInd.msdu.p[0] >> 2) & 0x0F);
uint8 fcReserve = (pData->dataInd.msdu.p[1] & 0xE0);
mact[0]=pData->dataInd.mac.dstAddr.addr.extAddr [0]; //
mact[1]=pData->dataInd.mac.dstAddr.addr.extAddr [1];
mact[2]=pData->dataInd.mac.dstAddr.addr.extAddr [2];
mact[3]=pData->dataInd.mac.dstAddr.addr.extAddr [3];
mact[4]=pData->dataInd.mac.dstAddr.addr.extAddr [4];
mact[5]=pData->dataInd.mac.dstAddr.addr.extAddr [5];
mact[6]=pData->dataInd.mac.dstAddr.addr.extAddr [6];
mact[7]=pData->dataInd.mac.dstAddr.addr.extAddr [7];
if ( (fcFrameType > 0x01) || (fcProtoVer != _NIB.nwkProtocolVersion) || (fcReserve != 0)
|| (pData->dataInd.mac.srcAddr.addrMode != SADDR_MODE_SHORT) )
{
// Drop the message
mac_msg_deallocate( (uint8 **)&pData );
return;
}
各种试了,搜了一下上面还有一个,这个函数,写了传回结果不对,正确写法是在搜一下MAC_MLME_ASSOCIATE_IND下面写是吗? 我没试过。求教正确写法。
在
if (tmp == 0)
{
return;
}
waca(mact);//uint8 waca(unsigned char wac[8]) 利用函数发送值到系统层
// MAC_MCPS_DATA_IND is very special - it is the only event where the MAC does not free *pData.
if ( event == MAC_MCPS_DATA_IND ) //另一个MAC_MCPS_DATA_IND事件
{
MAC_MlmeGetReq( MAC_SHORT_ADDRESS, &tmp );
if ((tmp == INVALID_NODE_ADDR) || (tmp == NWK_BROADCAST_SHORTADDR_DEVALL) ||
(pData->dataInd.msdu.len == 0))
{
mac_msg_deallocate( (uint8 **)&pData );
return;
}