AF_DataRequest()函数说明

论坛 期权论坛 脚本     
匿名技术用户   2021-1-6 23:45   740   0


原型:

  afStatus_t AF_DataRequest( afAddrType_t *dstAddr, endPointDesc_t *srcEP,
                             uint16 cID, uint16 len, uint8 *buf, uint8 *transID,
                             uint8 options, uint8 radius );

参数说明:

*dstAddr :发送目的地址+端点地址(端点号)和传送模式

*srcEP :源(答复或确认)终端的描述(比如操作系统中任务ID等)源EP
cID :被Profile指定的有效的集群号
len :发送数据长度
*buf :发送数据缓冲区
*transID : 任务ID号
options :有效位掩码的发送选项
radius :传送跳数,通常设置为AF_DEFAULT_RADIUS
其中

1、afAddrType_t *dstAddr af地址类型
typedef struct
{
  union
  {
    uint16      shortAddr;//短地址
    ZLongAddr_t extAddr;
  } addr;
  afAddrMode_t addrMode;//传送模式 <wbr>
  uint8 endPoint;//端点号 <wbr>
  uint16 panId;  // used for the INTER_PAN feature
} afAddrType_t;</wbr></wbr>

2、endPointDesc_t *srcEP 端点描述
typedef struct
{
  uint8 endPoint;//端点号
  uint8 *task_id;  // Pointer to location of the Application task ID.(调用任务的ID)
  SimpleDescriptionFormat_t *simpleDesc;//简单的端点描述
  afNetworkLatencyReq_t latencyReq;
} endPointDesc_t;

3、SimpleDescriptionFormat_t 简单描述格式
typedef struct  
{  
 byte          EndPoint;       //端口号  
 uint16        AppProfId;      //应用规范ID  
 uint16        AppDeviceId;    //应用设备ID  
 uint8         AppDevVer:4;    //应用设备版本号  4bit 这里使用的是位域  
 uint8         Reserved:4;             // AF_V1_SUPPORT uses for AppFlags:4.  
 uint8         AppNumInClusters;    //输入簇包含的命令个数  
 cId_t        *pAppInClusterList;  //输入簇列表  可有<span style='line-height: 18px; font-family: Consolas,"Courier New",Courier,mono,serif; background-color: rgb(248, 248, 248);'>GENERICAPP_MAX_CLUSTERS个输入命令</span>  
 uint8         AppNumOutClusters;   //输出簇包含的命令个数  
 cId_t        *pAppOutClusterList;//输出簇列表  可有<span style='line-height: 18px; font-family: Consolas,"Courier New",Courier,mono,serif; background-color: rgb(248, 248, 248);'>GENERICAPP_MAX_CLUSTERS个输出命令</span>  
} SimpleDescriptionFormat_t; 

4、uint16 cID
ClusterID--具体应用串ID
5、uint8 options
发送模式选项有如下选项
#define AF_PREPROCESS                      0x04   // Will force APS to callback to preprocess before calling NWK layer
#define AF_LIMIT_CONCENTRATOR              0x08
#define AF_ACK_REQUEST                     0x10
#define AF_DISCV_ROUTE                     0x20   // This option is no longer used, and will be taken out later
#define AF_EN_SECURITY                     0x40
#define AF_SKIP_ROUTING                    0x80

6、uint8 radius
传输跳数或传输半径,默认值为10

对于非广播消息,有两种基本的消息重试类型:端到端的确认(APS ACK)和单级确认(single hop acknowledgement)(MAC ACK)。MAC ACK默认情况下是一直打开的,通常能够充分保证网络的高可靠性。为了提供附加的可靠性,同时使发送设备能够得到数据包已经被发送到目的地的确认,可以使用APS ACK。

APS acknowledgement在APS层完成,是从目标设备到源设备的一个消息确认系统。源设备将保留这个消息知道目标设备发送一个APS ACK消息表明它已经收到了消息。对于每个发出的消息可以通过调用函数AF_DataRequest()的选项来使能/禁止来禁止这个功能。这个选项区域是一个位映射选项,对于将要发送的消息的选项区域或上(OR)AF_ACK_REQUEST就可以使能APS ACK。消息重试(如果APS ACK消息没有收到)的次数和重试之间的时间间隔的配置项在f8wConfig.cfg文件中。APSC_MAX_FRAME_RETRIES是APS层在放弃发送数据之前,没有收到APS ACK确认重新发送消息的次数。APSC_ACK_WAIT_DURATION_POLLED是重新发送之间的时间间隔。

APS ACK 数据确认命令在应用层event-loop函数中,通过AF_DATA_CONFIRM_CMD进行处理,原始AF层函数为afDataConfirm( uint8 endPoint, uint8 transID, ZStatus_t status )。

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP