cc2530 Serial Communication Process

Source: Internet
Author: User

//serial port sending and receiving processMain://Main function->osal_init_system ();//Operating System Initialization->osalinittasks ();//Task Initialization-->zdapp_init (taskid++);//after the function is initialized, the coordinator establishes the network and the terminal joins the network-->zdoinitdevice (0);//Device Initialization-->zdapp_networkinit (Extendeddelay);//Network Initialization-->osal_start_timeex (....., Zdo_network_init,..)//Send Message-->zdapp_event_loop ()//Events-->zdo_startdevice ((uint8) Zdo_config .......)//Start Device-nlme_networkdiscoveryrequest () set up a network-->ZDO_NETWORKFORMATIONCONFIRMCB ()//give ZdO layer hair astounding information-osal_set_event (.., zdo_network_start) Start Network event Coordinator-->zdapp_networkstartevt ();//Handling Network boot Events-->osal_set_event (..., zdo_state_change_evt);//Set Network status change events-->zdapp_event_loop ();//Network Change event function-->zdapp_sendmsg (....., zdo_nwk_disc_cnf,...);//terminals, routers,-->zdapp_processosalmsg ()//request to join-->ZDO_JOINCONFIRMCB ()//Terminal devices join the network-zdapp_sendmsg (..., zdo_nwk_join_ind,..); Zdo_nwk_join_ind event to ZDO layer-zdapp_processosalmsg ()-->zdapp_processnetworkjoin ();//Device Join Network-->osal_set_event (..., zdo_state_change_evt);//Terminal Equipment-->nlme_startrouterequest (0,0,false);//Routers-osal_set_event (..., zdo_router_start); ->osal_start_system ();//at this point the operating system is started, and the operating system is constantly detected whether there are events, and then jump to executewhat does the afincomingmsgpacket_t structure describe in ZigBee??typedefstruct{osal_event_hdr_t hdr; /*osal Message Header*///Osal message HeaderUInt16 groupId;/*Message ' s group ID-0 if not set*///Message Group IDUInt16 Clusterid;/*Message ' s cluster ID*///Message Family IDafaddrtype_t srcaddr;/*Source Address, if endpoint is Stubaps_inter_pan_ep, it's an interpan message*///Source Address TypeUInt16 macdestaddr;/*MAC Header Destination short address*///Mac Physical AddressUint8 EndPoint;/*Destination Endpoint*/ //Destination EndpointUint8 Wasbroadcast;/*TRUE If network destination was a broadcast address*///Broadcast AddressUint8 linkquality;/*The link quality of the received data frame*/ //link quality for receiving data framesUint8 correlation;/*The raw correlation value of the received data frame*///receives raw related values for the data frame. Int8 Rssi;/*The received RF power in units dBm*///the RF power received. Uint8 Securityuse;/*deprecated*///deprecatedUInt32 timestamp;/*receipt timestamp from MAC*///The time stamp is received. afmsgcommandformat_t cmd;/*Application Data*/Application Data} afincomingmsgpacket_t; //Wireless packet format structuretypedefstruct{uint8Event; Uint8 status;} osal_event_hdr_t;//Generalized MSG Command Formattypedefstruct{uint8 transseqnumber;              UInt16 datalength; //Number of bytes in TransdataUint8 *Data;} afmsgcommandformat_t; Halledblink (Hal_led_1,0, -, -);//0 is the number of flashes, but 0 means that it is flashing, not flashing, 50 is 50%, is the half of the light. 500 is the cycle, that is 0.5s. set up the network, join the network Process Analysis Coordinator node: in 1-TenExperiment 8 Network communication Experiment 2 multicast communication while(MSGPKT) {Switch(MSGPKT->HDR.Event)      {       CaseZdo_state_change://after setting up the network, set the eventGenericapp_nwkstate= (devstates_t) (msgpkt->hdr.status);//???????       if(Genericapp_nwkstate==dev_zb_coord)//When the node is initialized to the coordinator, perform the following{halledblink (hal_led_2,0, -, -);//LED2 FlashingAps_addgroup (Genericapp_endpoint,&genericapp_group);//after establishing the network, join the group. Osal_start_timerex (Genericapp_taskid,send_to_all_event, the); } router node: in 1-TenExperiment 8 Network communication Experiment 2 multicast communication while(MSGPKT) {Switch(MSGPKT->HDR.Event)        {      CaseZdo_state_change://after joining the network, join the familyGenericapp_nwkstate= (devstates_t) (msgpkt->hdr.status);//device type of the Read node      if(genericapp_nwkstate==dev_router) {Aps_addgroup (Genericapp_endpoint,&genericapp_group);//Join the group      }         Break; End node:1-5Experiment 4 serial Communication 2 while(MSGPKT) {Switch(MSGPKT->HDR.Event)        {       Casezdo_state_change:genericapp_nwkstate= (devstates_t) (msgpkt->hdr.status);//device type of the Read node      if(genericapp_nwkstate==Dev_end_device) {          //Use the Osal_set_envent () function to set the Send_data_event event when the interrupt node joins the network, and when the event occurs, execute the event handler functionOsal_set_event (genericapp_taskid,send_data_event);//??????????????????????????       }         Breakand the genericapp_nwkstate above is devstates_t genericapp_nwkstate;//Save node State[CPP] View plain copytypedefenum{dev_hold,//Initialized-not started automaticallyDev_init,//Initialized-not connected to anythingDev_nwk_disc,//discovering PAN ' s to joinDev_nwk_joining,//joining a PANDev_nwk_rejoin,//rejoining a PAN, only for end devicesDev_end_device_unauth,//Joined But isn't yet authenticated by Trust CenterDev_end_device,//Started as device after authenticationDev_router,//Device joined, authenticated and is a routerDev_coord_starting,//Started as Zigbee CoordinatorDev_zb_coord,//Started as Zigbee CoordinatorDev_nwk_orphan//Device has lost information on its parent. } devstates_t; At first, the Genericapp_init () function will be genericapp_nwkstate=Dev_init. Then go through which steps to Dev_zb_coord, Dev_router, Dev_end_device for the above three cases. TI protocol stack is semi-open source, the network layer code is not open source. The ZdO running on Port 0 is responsible for communication between the application-level user program and the network layer. The building process of the network layer is implemented by ZdO. The application layer receives the Zdo_state_change message after the network is established. Use the following statement to read the status of the current network. Genericapp_nwkstate= (devstates_t) (msgpkt->hdr.status);//device type of the Read node

cc2530 Serial Communication Process

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.