Frame type Security
enabled Frame
pending Ack
request Intra-
PAN Reserved Dest
addressing mode Reserved Source
addressing mode
帧类型为3位,规定了四种帧类型,分别为信标帧、数据帧、应答帧和控制帧,定义如表4.2所示。
表4.2 帧类型定义
帧类型b2b1b0 描述
000 Beacon
001 Data
010 Acknowledgment
011 MAC command
100-111 Reserved
此次设计中命令帧格式为:
CC2520_PSDU[1]=(PAN_ID_COMPRESSION<<6)|(ACKNOWLEDGMENT_REQUEST<<5)|(FRAME_PENDING<<4)|(SECURITY_ENABLE<<3)|(FRAME_TYPE_DATA<<0);
CC2520_PSDU[2]=(SOURCE_ADDRESSING_MODE<<6)|(FRAME_VERSION<<4)|(DEST_ADDRESSING_MODE<<2);
CC2520_PSDU[3] = SEQUENCE_NUMBER;
CC2520_PSDU[4] = CC2520_Destination_PANID[0];
CC2520_PSDU[5] = CC2520_Destination_PANID[1];
CC2520_PSDU[6] = CC2520_Destination_IEEEAddr[0];
CC2520_PSDU[7] = CC2520_Destination_IEEEAddr[1];
CC2520_PSDU[8] = CC2520_Destination_IEEEAddr[2];
CC2520_PSDU[9] = CC2520_Destination_IEEEAddr[3];
CC2520_PSDU[10] = CC2520_Destination_IEEEAddr[4];
CC2520_PSDU[11] = CC2520_Destination_IEEEAddr[5];
CC2520_PSDU[12] = CC2520_Destination_IEEEAddr[6];
CC2520_PSDU[13] = CC2520_Destination_IEEEAddr[7];
CC2520_PSDU[14] = CC2520_Source_PANID[0];
CC2520_PSDU[15] = CC2520_Source_PANID[1];
CC2520_PSDU[16] = CC2520_Source_IEEEAddr[0];
CC2520_PSDU[17] = CC2520_Source_IEEEAddr[1];
CC2520_PSDU[18] = CC2520_Source_IEEEAddr[2];
CC2520_PSDU[19] = CC2520_Source_IEEEAddr[3];
CC2520_PSDU[20 ] = CC2520_Source_IEEEAddr[4];
CC2520_PSDU[21] = CC2520_Source_IEEEAddr[5];
CC2520_PSDU[22] = CC2520_Source_IEEEAddr[6];
CC2520_PSDU[23] = CC2520_Source_IEEEAddr[7];
为了提高数据传输的可靠性,避免丢帧,Zigbee采用了载波侦听多址/冲突避免的信道接入方式和完全握手协议[24-25],数据传递过程如下图4.3所示。
图 4.3 Zigbee通信协议
在非信标使能的模式下,MAC层采用CSMA/CA机制还负责帧传输的时间分配。在CSMA/CA机制中,每个节点在启动数据传输前进行信道侦听(也即进行空闲信道评估)以减少同时传输的概率[26-27]。如果找到了空闲信道则启动数据传输过程。当节点察觉存在冲突,它将停止传输并在等待一个随机时间之后在进行数据重传。 STM32F103X家用环境温湿度监测装置的设计(9):http://www.751com.cn/zidonghua/lunwen_6025.html