TI中文支持网
TI专业的中文技术问题搜集分享网站

“AF_DataRequestSrcRtg()” 函数似乎有 BUG?

协议栈:Z-Stack 3.0.2

协调器:CC2538

终端:CC2530

问题描述:

1、我调用 AF_DataRequestSrcRtg() 函数,“RelayCnt”参数为 1,“RelayCnt”参数 “pRelayList” 参数为 “0xd5eb”,然后抓包看见发出去的包并没有使用“source route” 功能。

请问这是为什么?

2、请问 “AF_DataRequestSrcRtg()” 函数的 “RTG_AddSrcRtgEntry_Guaranteed()” 有什么作用?

afStatus_t AF_DataRequestSrcRtg( afAddrType_t *dstAddr, endPointDesc_t *srcEP,
uint16 cID, uint16 len, uint8 *buf, uint8 *transID,
uint8 options, uint8 radius, uint8 relayCnt, uint16* pRelayList )
{
    uint8 status;

    /* Add the source route to the source routing table */
    status = RTG_AddSrcRtgEntry_Guaranteed( dstAddr->addr.shortAddr, relayCnt,
    pRelayList );

    if( status == RTG_SUCCESS)
    {
        /* Call AF_DataRequest to send the data */
        status = AF_DataRequest( dstAddr, srcEP, cID, len, buf, transID, options, radius );
    }
    else if( status == RTG_INVALID_PATH )
    {
        /* The source route relay count is exceeding the network limit */
        status = afStatus_INVALID_PARAMETER;
    }
    else
    {
        /* The guaranteed adding entry fails due to memory failure */
        status = afStatus_MEM_FAIL;
    }
    return status;
}

Alvin Chen:

AF_DataRequestSrcRtg 是增加 source route到source routing table在调用 AF_DataRequest之前。RTG_AddSrcRtgEntry_Guaranteed就是增加一个条目进去。

Alvin Chen:

回复 Alvin Chen:

如果你增加成功则会按照 source route发送,但是也会存在你的内存不足的情况无法添加,如果你source routing table已经有了该地址,重新调用RTG_AddSrcRtgEntry_Guaranteed则会更新它

Jesse Huang:

回复 Alvin Chen:

调用 RTG_AddSrcRtgEntry_Guaranteed 保存的源路由表是保存到这里对吧:

#if defined ( ZIGBEEPRO ) || defined ( ZBIT )    rtgSrcEntry_t rtgSrcTable[MAX_RTG_SRC_ENTRIES];    uint16 rtgSrcRelayList[MAX_SOURCE_ROUTE];#endif

那什么时候会删除?还会一直保存在这的吗?

Alvin Chen:

回复 Jesse Huang:

如果这个设备一直存在就有一直有,如果它退网就会被remove掉释放空间:
ZDApp_LeaveUpdate

Jesse Huang:

回复 Alvin Chen:

那将“route record”数据上传到host保存有啥意义?最终还是会在 CC2538 里面存储路径,占用芯片内存。那还不如直接在“route record”命令里面直接调用“RTG_AddSrcRtgEntry_Guaranteed()”命令,然后再调用“AF_DataRequest()”的时候,它就会自动在“rtgSrcTable[]”里面寻找路径发出吗?

Alvin Chen:

回复 Jesse Huang:

举个简单的应用实例,你收到了很多个设备的route record通常是做一个数据库,然后进行查表比对而不是直接就去RTG_AddSrcRtgEntry_Guaranteed更新。当然你想是否上传到host还是收一个就去RTG_AddSrcRtgEntry_Guaranteed更新,这是你的自己应用决定的。

Jesse Huang:

回复 Alvin Chen:

其实我就是想减小 CC2538 内存的压力,因为子节点会有 100 多个,所以想将 “route record” 的源路由表存储到 host ,然后再调用 AF_DataRequestSrcRtg() 将其发送出去。
我在英文论坛收到 Toby Pan 的回复,他说:
RTG_AddSrcRtgEntry_Guaranteed() guarantees adding an entry into the source routing table (eg. if the table is full, this entry will replace the oldest entry in the table).
如果 “rtgSrcTable[]” 满了就会重新覆盖最旧的地址是吗?那我是不是可以将 MAX_RTG_SRC_ENTRIES 设置为 1,那么就可以实现我上面的想法了?

Alvin Chen:

回复 Jesse Huang:

100 node 2538就算你都存储也问题不大吧,除非你应用程序特别多。是会覆盖第一条目,如果你设置为1,难道你要发生送之前先从host数据库拿到去填充吗?不建议你设置为1,可能会出现其他问题。试试看就知道了,没这么操作过。

Jesse Huang:

回复 Alvin Chen:

如果调用 “RTG_AddSrcRtgEntry_Guaranteed()” 函数就只是更新源路由列表的话,那么我直接调用 “AF_DataRequest()” 也是会使用到源路由路径的咯?那上面那个建议不就不成立了?那返回状态为 “Source Route Failure” 的 “network status” 命令时,还是无法更新路径啊?

原贴:https://e2echina.ti.com/question_answer/wireless_connectivity/zigbee/f/104/t/176019

Alvin Chen:

回复 Jesse Huang:

source route failure是你的链路不对,但是不会导致发送不到设备。如果已经证明你的加入的这个source record是无效的或者错误的,就没必要非要用这个错误路径去发。

赞(0)
未经允许不得转载:TI中文支持网 » “AF_DataRequestSrcRtg()” 函数似乎有 BUG?
分享到: 更多 (0)