Analysis and summary of Afregister function call in task initialization in Zstack-osal

Source: Internet
Author: User

First look at the following several structures, defined in the AF.h file

typedef struct{  uint8          EndPoint;                Endpoint/port/terminal number 1-240  uint16         appprofid;               Supported profile ID, config file id  uint16         appdeviceid;             Supported Device ID  uint8          appdevver:4;             Version of the device description executed  uint8          reserved:4;              Af_v1_support uses for appflags:4.  Uint8          appnuminclusters;        The number of input clusters supported by the terminal  cid_t         *pappinclusterlist;       Pointer to input cluster ID (input cluster) list  uint8          appnumoutclusters;       The number of input clusters supported by the terminal  cid_t         *pappoutclusterlist;      Pointer to output cluster ID (output) List} simpledescriptionformat_t;//simple descriptor
typedef struct{  uint8 endPoint;                             Terminal number  uint8 *task_id;                             Pointer to location of the application task ID. Task ID pointer  simpledescriptionformat_t *simpledesc;      The simple descriptor is the structure body  afnetworklatencyreq_t latencyreq defined above;           Must be assigned a value of NOLATENCYREQS} endpointdesc_t;//Terminal descriptor
typedef struct _EPLIST_T {  struct _eplist_t *nextdesc;   The next node or the next terminal entry  endpointdesc_t *epdesc;       Terminal/endpoint/port descriptor, which includes a simple descriptor  PDESCCB  PFNDESCCB;           Don ' t use the If this function pointer is NULL. callback function  afapsf_config_t apsfcfg;  Eep_flags Flags;              Terminal flag, Eep_flags is an enumeration type that contains two variables eep_allowmatch=1,eep_notused=2} eplist_t;//Terminal List entry descriptor
afregister Function Parsing

afstatus_t afregister (endpointdesc_t *epdesc) {/* Find out if this endpoint already exists */if (  Affindendpointdesclist (Epdesc->endpoint))//Look for duplicate endPoint.  {return afstatus_invalid_parameter; }/* does not exist, then call afregisterextended, Register * registration succeeded (NOT NULL) return Afstatus_success * registration failed (NULL) return Afstatus_mem_fail */return ((Null = = Afregisterextended (Epdesc, NULL))? afstatus_mem_fail:afstatus_success);} 
eplist_t *afregisterextended (endpointdesc_t *epdesc, PDESCCB descfn) {/  * open a Terminal entry node */  eplist_t *EP = osal_mem_ Alloc (sizeof (eplist_t));  if (ep! = NULL)  {    ep->nextdesc = eplist;     The nextdesc of this node points to the head node of the terminal entry, that is, the chain header interpolation method    eplist = EP;               Re-point the head of the list of terminal entries to the last inserted node    ep->epdesc = Epdesc;       Assigned the terminal descriptor member    EP->PFNDESCCB = DESCFN    in the terminal entry structure by describing the endpoint in the parameter. The callback function is assigned a value of NULL    Ep->apsfcfg.framedelay = apsf_default_interframe_delay;//#define Apsf_default_ Interframe_delay    ep->apsfcfg.windowsize = apsf_default_window_size;     #define APSF_DEFAULT_WINDOW_SIZE       1    ep->flags = Eep_allowmatch;  Default to allow Match Descriptor. Assignment to 1  }  return EP;
Summarize:


Zstask-osal all the terminals in a terminal list entry, and they are all strung on a linked table, with the global eplist struct pointer pointing to the last registered Terminal list entry structure. A task is an application, that is, a terminal, call the Afregister function in the task initialization function, we only need to pass a terminal descriptor endpointdesc_t, All before calling the Afregister function, you need to initialize the terminal descriptor endpointdesc_t, initialize the terminal number, initialize the task ID pointer, initialize the simple descriptor, and so on.



Analysis and summary of Afregister function call in task initialization in Zstack-osal

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.