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

来源:互联网 发布:spss有mac版吗 编辑:程序博客网 时间:2024/05/14 23:11

疑问:为什么每个端点描述符都需要在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 0
原创粉丝点击