首页 > 代码库 > afDataReqMTU()基于 输入参数可以发送字节数的最大值
afDataReqMTU()基于 输入参数可以发送字节数的最大值
在API的手册中可以看出,
根据此函数,能读取最大有效载荷的大小;
ti论坛的解释:
The maximum payload size for an application is based on several factors. The MAC layer provides a constant payload length of 116 (can be changed in f8wConfig.cfg – MAC_MAX_FRAME_SIZE). The NWK layer requires a fixed header size, one size with security and one without security. The APS layer has a required, but variable,header size based on a variety of settings, including the ZigBee Protocol Version, APS frame control settings, etc.
Ultimately, the user does not have to calculate the maximum payload size using the aforementioned factors. The AF module provides an API that allows the user to query the stack for the maximum payload size, or the maximum transport unit (MTU). The user can call the function, “afDataReqMTU” (see “af.h”) which will return the MTU, or maximum payload size
自己实测:
int a=512; char temp[3]; afDataReqMTU_t *pafData; afDataReqMTU_t afData; afData.kvp=0; afData.aps.secure=0; *pafData=http://www.mamicode.com/afData; a=afDataReqMTU(pafData); sprintf(temp, (const char *)"%d",a); MT_UartInit (); MT_UartRegisterTaskID(task_id);//注册串口任务 HalUARTWrite(0,(unsigned char *)&temp[0],4); //发送数据
利用串口发送,数据最大载荷为99.
afDataReqMTU()基于 输入参数可以发送字节数的最大值