Implementation of terminal selection coordinator access network based on CC2430

ZigBee is a brand new, focused on low-power, low-cost, low-complexity, low-speed short-range wireless network communication technology, is also a major hot spot in embedded applications.

In recent years, ZigBee wireless data networks have been increasingly used in China. The local area network has been replaced in many places. It is actually used in building monitoring system, centralized meter reading in wireless mode, mine rescue system and home appliance control, etc. The article talks about the CC2430, a TI product used by more customers in China.

1 Question raised

In a small area, there are several coordinators with the same channel, but the PAN ID is different. When the terminal's PAN ID is set, the terminal only joins the coordinator with the same PAN ID stored on it. At present, the wireless networking project uses TI's CC2430, and the ZigBee protocol stack on it is TI's Z-STACK 1.4.3-1.2.1. Because TI's strategy is that the terminal joins one of the coordinators at random, even if a specific PAN ID has been defined on it. From a small number of experiments, CC2430 as a terminal preferentially joins the coordinator with a smaller PAN ID number. The user is generally unable to let the terminal choose, and neither the terminal scans the network nor requests the network access process to give the source code. This brings inconvenience to such practical applications.

2 Problem analysis

For the formation of the CC2430 / 2431 network, you can refer to the book "ZigBee Technology and Practice Course". The book was published by Beijing University of Aeronautics and Astronautics Press and edited by Gao Shouwei and Wu Canyang.

When the router and terminal try to join a network, they first call the NLME_NetworkDiscoveryRequest () function. This function will perform a network scan, and the result is returned by the function ZDO_NetworkDiscoveryConfirmCB (). When the network is found, it will call the NLME_OrphanJoinRequest () function to try to join the network. The result is returned by the function ZDO_JoinIndicationCB ().

Unfortunately, there is no source code for the two functions of network scanning and requesting access to the network, causing a dilemma that cannot be modified. Objectively speaking, it is often difficult to modify certain parameters on TI's ZSTACK. I had to find a way from the ZDO_NetworkDiscoveryConfirmCB () function and the ZDO_JoinIndicationCB () function that provided the source code. Check the code of ZDO_NetworkDiscoveryConfirmCB () and find that it finally calls ZDO_FinishProcessingMgmtNwkDiscReq ()

In this function, there is a special treatment for the router. The conditional compilation variable RTR_NWK represents a router-capable device. Although the coordinator can double as a router, it is only possible to execute this code with a normal router.

#if defined (RTR_NWK)
...
#endif

The code in ... retrieves the returned network information description structure to see if there is a coordinator with the same stored PAN ID. Observe ZDObject. The ZDO_StartDevice () function in the c file, when the start device mode is "Continue Again", that is, startMode == MODE_RESUME, the terminal device requests to join the network in a lone way. The resume mode actually identifies that the non-coordinator device is in a state where network scanning is complete and ready to request network access. At this point of analysis, you can come up with a way. First define a global variable bool variable p_matching that checks if there is a coordinator with the same PAN ID. Set it to FALSE during initialization.

3 Solution and actual code

For the code segment just mentioned, add the terminal to query the returned network information description structure.



In ZDApp. Modify the ZDApp_event_loop () function in c. Before calling ZDO_StartDevice (...), add a piece of code before the terminal device scans the network and requests access to the network. When the terminal and the coordinator have different PAN IDs and are in the resume mode, re-search whether there is a coordinator with the same PAN ID without requesting Renren.



This allows the terminal to have a coordinator to choose from.

Regarding how to modify the PAN ID, the following code is given (this code is common to the coordinator and terminal. _NIB is a global structure related to the network):



In addition, when the non-coordinator device is initialized, the following code should be added (gu16RecBuffLen is a custom 16-bit integer):



Through the analysis of the scanning network result processing function, the program segment in front of the scanning network and the requester network is studied. Add a logical variable to the program section to determine whether the terminal has retrieved a specific PAN ID coordinator. Finally, add a code that does not request access to the network when the coordinator of a specific PAN ID is not retrieved in the program, so as to achieve the purpose of the terminal selecting the coordinator to access the network. Through experiments, when there are several coordinators with different PAN IDs in the field, the terminal device only joins a specific coordinator.

Kara offers a wide range of illuminated and non-illuminated Rocker Switches.In this series,Rated current 6A,10A,16A,Ranging from 1 to 6 poles,with many styles of  colors and functions. Certifications include UL, CSA, TUV, CE, and more. 

Why choose us? 

 1)As  a manufacture,  all of our switch parts are made by our own factory in Ningbo. So, price is competitive.

2)We have our own UL testing lab in Taiwan, so quality can be guaranteed.

3) We can provide you with different types of rotary switches for your selection.

4) Various operating force,height and colour for one switch for your choice.

5) Safety, on-time delivery, excellent quality with competitive price.

6) MOQ: 1000pcs,mixed order acceptable, welcome trial order.

 7) OEM and ODM professional design.

8) We can provide free samples for your test.



rocker switchrocker switchrocker switch

Small-sized Rocker Switches

Small-Sized Rocker Switches,Round Rocker Switch,Small Rocker Switch,Mini Rocker Switch

Ningbo Kara Electronic Co.,Ltd. , https://www.kara-switch.com