关于在AF层注册的具体过程

疑问:为什么每个端点描述符都需要在AF进行注册?

进行端点描述符注册的函数是 afRegister( &SampleApp_epDesc )。SampleApp_epDesc是一个
endPointDesc_t类型的结构体,endPointDesc_t结构体的具体定义如下: (AF.h)

typedef struct
{
  uint8 endPoint;  //端口号,据说可以是1-240
  uint8 *task_id;  // 任务ID,就是在osalInitTasks()里面生成的taskID++的那些
  SimpleDescriptionFormat_t *simpleDesc; //另一个结构体:简单描述符。没明白这里为什么要弄一个这个东西
  afNetworkLatencyReq_t latencyReq;  //必须赋值为noLatencyReqs  
} endPointDesc_t;

————————————————————————————————————————————

AF.h:

typedef struct
{
  uint8          EndPoint;   //跟上面那个应该是一个样的
  uint16         AppProfId;  //配置文件id?
  uint16         AppDeviceId;  //不懂
  uint8          AppDevVer:4;  //不懂
  uint8          Reserved:4;            
  uint8          AppNumInClusters; //输入簇的数量
  cId_t         *pAppInClusterList; // 输入簇列表
  uint8          AppNumOutClusters; //输出簇数量
  cId_t         *pAppOutClusterList; //输出簇列表
} SimpleDescriptionFormat_t;

————————————————————————————————————————————
然后在sampleapp.c中对这些结构体一通赋值之后,就开始调用了:
AF.c:

afRegister( &SampleApp_epDesc )
{
    if (afFindEndPointDescList(epDesc->endPoint))  // 找找这个描述符注册过没有?
  {
    return afStatus_INVALID_PARAMETER;
  }

  return ((NULL == afRegisterExtended(epDesc, NULL)) ? afStatus_MEM_FAIL : afStatus_SUCCESS); //没有的话注册一个
}

————————————————————————————————————————————
AF.c:
afFindEndPointDescList(epDesc->endPoint)
{
epList_t *epSearch; //生成一个节点

for (epSearch = epList; epSearch != NULL; epSearch = epSearch->nextDesc) //遍历跨表
{
if (epSearch->epDesc->endPoint == EndPoint)
{
break;
}
}

return epSearch;//找到了就返回epSearch,找不到就返回NULL
}
————————————————————————————————————————————

在链表里没有找到这样的端点描述符,那么就生成一个

afRegisterExtended(epDesc, NULL) //这个函数返回epList_t类型的指针;NULL是一个回调函数类型,暂时不管
{
     epList_t *ep = osal_mem_alloc(sizeof(epList_t));//申请内存

if (ep != NULL)
  {
    ep->nextDesc = epList;
    epList = ep;
    ep->epDesc = epDesc;  //链表的插入操作
    ep->pfnDescCB = descFn;  //就是参数NULL
    ep->apsfCfg.frameDelay = APSF_DEFAULT_INTERFRAME_DELAY;
    ep->apsfCfg.windowSize = APSF_DEFAULT_WINDOW_SIZE;
    ep->flags = eEP_AllowMatch;  // Default to allow Match Descriptor.
  }

————————————————————————————————————————————
现在看看epList_t长什么样:
AF.h:

typedef struct _epList_t {
  struct _epList_t *nextDesc;  //指向下一个节点的指针
  endPointDesc_t *epDesc;  //端点描述符赋值给这个参数
  pDescCB  pfnDescCB;     // Don't use if this function pointer is NULL.
  afAPSF_Config_t apsfCfg;
  eEP_Flags flags;
} epList_t;

————————————————————————————————————————————这样的话就完成了端点描述符在AF层的注册,说白了就是在链表里留个名字….
后面是不是在进行什么操作的时候要检查这个链表什么的我还不了解,后面看到了回头补充….

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值