z-stack bug报告:ASDU最大传输长度(附修改方案)
使用AF_DataRequest传输数据,最大能传输81个字节,超过81字节就会被自动分包。
但是从zigbee官方的技术文档中获知,APS最大载荷为82字节,此时MAC帧长度对应为127字节。
在AF.c中,找到函数afDataReqMTU,进行如下修改:
uint8 afDataReqMTU( afDataReqMTU_t* fields ) { uint8 len; uint8 hdr; if ( fields->kvp == TRUE ) { hdr = AF_HDR_KVP_MAX_LEN; } else { hdr = AF_HDR_V1_1_MAX_LEN; } len = (uint8)(APSDE_DataReqMTU(&fields->aps) - hdr) + 1; return len; }
即return len + 1,通过测试,每帧能够多发送一字节。
谢谢分享!
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.
可能是核心函数APSDE_DataReqMTU返回的值有误,应该多加一个字节。