In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
Solemnly declare: the following article is suitable for children's shoes who are beginners in Zigbee. Please skip it.
1 reason:
I have heard of Zigbee technology in my work, but I just know that it is a wireless communication technology, but the specific technical details and use are not very clear. Unexpectedly, a project needs to use Zigbee technology, so it's time to take a good look at what Zigbee is. Write down some of my understanding of Zigbee technology here.
2 what is Zigbee?
Zigbee is a wireless communication technology. Wireless, as its name implies, is a way of communication through radio waves (such as WIFI, mobile phone) as a carrier of information. Communication refers to the need for communication between one device and another. People need to communicate with each other, and communication requires the use of language, then there may be grammar in this language. To put it bluntly, both sides have to understand what the other is saying. If one only knows Chinese and the other only knows English, then the two of them may need an interpreter to communicate. The same is true between devices, which need to follow certain rules. Both devices are required to send and receive messages in accordance with this regulation, and this provision is the agreement. For Zigbee communication technology, it is the Zigbee protocol. In fact, there are two major aspects of computer technology, one is the computer itself (advances in hardware technology), and the other is the communication between different devices. As far as we human beings are concerned, one is a human problem, and the other is a social problem. Having said so much nonsense, the following is a summary: Zigbee communication is a way of communication between devices and devices, which specifies what physical medium is needed to transmit information, what the format of the information is like, who sends the message first, what to do if the message is interfered in the process of transmission, what to do if the other party does not receive it, and so on.
Forget it, let's take a look at the official definition: ZigBee is a low-power LAN protocol based on the IEEE802.15.4 standard. According to international standards, ZigBee technology is a short-distance, low-power wireless communication technology.
Also attach the differences and contact diagrams among Zigbee, WIFI and bluetooth:
3 say hello to Zigbee (get a familiar face)
Let's make an analogy between Zigbee communication and human communication, and then explain how Zigbee achieves communication between different devices by constantly asking questions. As mentioned earlier, Zigbee is generally used for LAN communication (some students raised their hands, "what is a LAN?" That classmate, put your hand down first, holding up the tired "" local area network is a local network, that is to say, a small area network, like you need different devices to communicate at home, you can use Zigbee technology "" We all use Internet to surf the Internet and chat, which is based on the TCP/IP protocol. TCP/IP can form a local area network or an Internet ") Let's take the communication between your family as an example of analogy. Suppose the following scenario: there are three people in your family, you, your father and mother | there are 3 Zigbee devices in the analogy Zigbee network. Now you probably know how I'm going to talk about this Zigbee.
64 bit MAC address (globally unique address)
Oops, our goal is to allow Zigbee devices to communicate with each other. So the first question in front of us is how to ensure the uniqueness of Zigbee devices. In your family, you must know your father and mother, and your father and mother should also know you. How do you know Mom and Dad? Now I'll give you 1s thinking time. Well, you remember the height, appearance and other characteristics of your father and mother. In other words, father and mother have certain physical features, and it is rare for them to look exactly the same. Now the medical theory is that DNA is different, so everyone is different. For people, DNA is the only sign of you on earth. What is the basis for determining the uniqueness of Zigbee devices? it is easy to say that Zigbee devices are made by us humans, and we can artificially assign them a unique address. Here's what I think. Check the information (wait 5 minutes). ). The physical address that uniquely identifies the Zigbee device is a string of digits of the 64bit, such as 000124B00028B679, where the preceding 24bit represents the company code and the latter 40bit represents the address field. These addresses need to be applied to the IEEE committee.
16 bit network address (used to identify a device within the Zigbee network)
You may think that when I am at home, I can usually tell them apart by just saying "Dad" and "Mom". I can only identify the person I am looking for without having to look at their height, appearance and other features every time. Is there any other way to uniquely identify Zigbee devices within a given Zigbee network? I think there is. After forming a network between Zigbee devices, each device will be assigned a short address of 16bit, and the devices can communicate through this short address. Within the local area network, the scope is smaller, and a shorter address can be used to distinguish between different devices.
Zigbee network establishment, equipment joining
In your family, your father, mother and you all have different roles. Have time to find out your household registration book, the household registration book is generally numbered (in the upper left corner or upper right corner of the household registration book). Your father may be the head of household, and you are the child of your parents (isn't that nonsense? I just want you to know that different people have different roles in the family. Then you may want to ask, what are the roles in Zigbee devices and what do different roles do? Zigbee devices are divided into three roles: Coordinator, Router and Enddevice. Coordinator is responsible for establishing the Zigbee network and assigning a unique ID to the Zigbee network (they are all called the ID,PANID). Router can join the network established by Coordinator, and it can forward data, that is, as a data relay, to extend the wireless communication distance of the Zigbee. Enddevice is a terminal device. If you join the Zigbee network, you can only receive and send data.
Take a picture of the Zigbee family:
Figure 2: Zigbee network topology diagram
* your mother wants you to come home for dinner!
You are at home with your father and mother. You are tired from playing games. Think of something. You can choose the following ways to communicate with your father and mother.
1: just raise your voice and shout, "I'm hungry, hurry up and make me something to eat." In this case, both father and mother heard it, and there may be the following situation: a, my father was busy and replied, "I'm busy, looking for your mother", and my mother replied, "I'll make you an egg fried rice." B, Mom and Dad replied together: "good boy, we will cook for you", and then there is a love scene of parents cooking together. C, Mom and Dad are busy, back to "Bear Boy, playing games all day, still have the face to say hungry, cook for yourself, and we have to watch TV series." of course, in this case, you can consider whether you are paid for the phone bill. But then again, when you shout at the top of your voice, there is actually a more professional communication term, radio. Yes, one of the ways of communication between Zigbee devices is broadcasting. One device broadcasts, and other devices in the network can hear it.
Popularize the broadcast address knowledge specified by Zigbee:
0xFFFF-this is a broadcast address that broadcasts devices across the network
0xFFFD-if the destination address is set to this address in the command, then only the devices that are open for reception are broadcast
0xFFFC-broadcast to coordinator and router
0xFFFE-if the destination address is this address, the application layer will not specify the target device, but will read the binding table through the protocol stack to obtain the short address of the corresponding target device
In addition, both 0x0000 and 0xFFF8 are valid destination addresses. Each address is just a target device.
2: quietly walked up to his mother and said to her alone, "Mom, I'm hungry." In this case, it is very likely that Dad's cooking is really terrible. Like this, it is a peer-to-peer communication mode in Zigbee. In this way, both sides of the communication have to specify the destination address.
3: agree on a code with your father and cough loudly three times. In this way, you don't have to think about trivial things like the original address and the destination address. As long as you send out this code, dad will know what you want and what you want to eat. Clever ah, this trick, but this also depends on my father's mood at that time. In Zigbee, this is called Bonding. After the two sides of the communication are bound, they do not need too much information when they communicate, as long as they send a code, the corresponding function can be completed.
Knowledge domain VS Endpoint
From the above description, we know that the device short address is used to identify a Zigbee device. It is just like you, your father and your mother at home. Different titles mean different people. However, another problem surfaced, that is, children and adults have different life experiences and fields of knowledge. You call your son (6 years old) and say to him, "son, mother is not at home. Shall we go to KFC this afternoon?" No, no, no. "Yes," the son replied happily. The two sides communicated happily. In the following scene, you think, "son, did you know that a pointer variable in C language is a variable that stores a memory address?" The son looked dazed. "?" . Make up for the rest of the scene. The above story tells us that both sides can communicate happily, and the content of the exchange needs to be understood by both sides. There is a concept similar to this in Zigbee communications, called Endpoit, where there can be many Endpoit on a Zigbee device. Let's go back to the last picture.
In this example, there are two switches on the left (possibly installed in the corridor), the two switches share a Zigbee node "Z1" (equivalent to two keys on the development board, which should be understandable), and they control the three light bulbs on the right (also connected to the same node-"Z2"). The key1 of Z1 controls the lamp1 of Z2, while key2 controls the lamp2 and lamp3 of Z2.
There are several unseen concepts in the picture above: cluster ID, Binding Table, and actually a profile, attribute. Let's talk about what these things are.
Binding Table had better understand that, as mentioned above, in order to facilitate communication, we can establish a binding relationship. The short addresses, Endpoit and other information of both sides of the binding relationship are stored in Binding Table.
Profile ID, this is the application ID number assigned by the Zigbee organization, such as 0x0001 for wireless switches, ox0002 for smart meters, 0x0003 for universal remote controls, and so on. In this case, the ID number is specially used as an electric light switch. Why would you do that? This reflects the meaning of the "standard". Devices with different manufacturers' functions can be used with each other with this ID, and the switch of Zhengtai can also control the lights of Philips.
Endpoint, the name seems to be easily misunderstood, thinking that it is the serial number of the device, but it is not. In this example, Z1 has two Endpoint of key1/key2, which do different things. It corresponds to 240 different "sub-applications" in the same "application", in which endpoint 0 is reserved with "ZDO" and cannot be occupied. If you are familiar with TCP/IP, you may feel that Endpoit and port (port number) have some similarities.
Cluster ID, what do you call this? Call it information cluster ID. My understanding is, "what kind of information is this?" there must be a correspondence between the sender and the receiver, but we can decide how to divide this "class". For example, in this example, I can say that Cluster ID=1 stands for one switch and Cluster ID=2 for continuous flicker. Or define Cluster ID=1 for point-to-point control, Cluster ID=2 for full control, etc.
Attribute, in the Zigbee protocol stack, every standard profile (such as HA, the application layer specification for smart home) defines a lot of Cluster ID, and each Cluster ID has some prescribed attribute and actions.
What? It's too hard to understand. Well, let's take a life example.
Take the friendly dormitory, which is popular for freshmen, as an example:
Eight people in the male dormitory constitute the development board A, and eight people in the female dormitory constitute the development board B.
The eight people in the men's dormitory are the eight EndPoint on the development board A.
Men's dormitory 5 people like to study, 3 like to play, divided into two groups with different behavior hobbies, that is, two Profile.
Female dormitory 8 people 3 like to study, 2 like to play, the remaining 4 like to eat, divided into three groups, that is, three Profile.
Profile = 0x0010; Profile = 0x0011; Profile = 0x0012
At the end of the above definition, let's look at the binding process:
A male student (playful) called the female dormitory and said he wanted to go out to play. 6 of the 8 female students refused directly because of their different hobbies (different Profile values). One of the remaining two girls refused because she hated the male classmate (there was no sign of the male classmate in mind), and the other girl had a crush on the boy (her mind was filled with any goodwill of the male classmate, ready at any time.), so the binding is successful.
In this way, the boy will dial the girl's cell phone directly.
Assuming that the boy ranks third, it does not necessarily require the girl to rank third as well.
4 Summary:
I've been talking nonsense for a long time. I don't know if you can see this place. The content discussed above also basically covers the concepts that beginners are most confused and want to understand most.
5 Zigbee protocol stack structure
The layered design idea is adopted in the design of Zigbee protocol stack. Or the previous picture:
As you can see, Physical (PHY) Layer and MAC Layer are defined by IEEE 802.15.4.
Schematic diagram of Zigbee communication in hierarchical mode:
In 802.15.4 and Zigbee protocols, the concept of "primitive" is used to describe the service between two adjacent layers, and the function call or information transfer between layers can be expressed by primitives. Although, in the whole system, there are many different layers, but the communication mode between layers is very similar. For example, PHY, MAC and NWK layers all provide data services for their upper level, and the mechanism of requesting data service is similar: the upper layer requests transmission to the subordinate through D-SAP, and the subordinate returns the status to the superior after the transmission is successful.
It is because of this similarity that the approach of "service primitive" is particularly important. Each primitive either executes an instruction or returns the result of a previous instruction. The primitive also runs the required parameters with instructions.
The figure above describes the general ways in which a layer provides services to its upper layers. As shown in the figure, there are four types of primitives: request, indication, response, and confirmation. In other words, all services in the 802.15.4 and Zigbee standards can be classified as one of the above four primitives. The primitive is described in the following format:
(note: since most of the readers of this article are current or future software engineers, the four primitives are directly expressed in English.)
.request
.indication
.response
.confirm
First of all, the Number1 layer requests a service from the N layer using the request primitive. For example, if the MAC layer requests a MPDU transport service from the PHY layer, it must apply for a PD-Data.request primitive from the PHY layer.
Layer N sends an indication primitive to its service users (often layer 1) to indicate an event that is important to layer 1. For example, if the PHY layer receives a set of data and needs to pass the data to the MAC layer, it generates a PD_Data.indication primitive to the MAC layer to pass the data to it.
If the indication primitive asks for a response, then the Number1 layer emits a response primitive. It is worth noting that there are no response primitives in the PHY and NWK layers, but only in the MAC and APL layers.
The confirm primitive is issued by layer N, which is used to finally confirm that the request service of the original layer 1 application has been completed. For example, in the above example, after the data is sent, the PHY layer tells the MAC layer that the transfer has been completed successfully.
Note: this article is only an easy-to-understand way to let the reader understand the basic concepts of the primitive. If the reader needs to understand the details of the primitive provided at each layer, please read the 802.15.4 and Zigbee protocol documents directly.
When ZigBee devices are working, different tasks are performed at different levels, and the tasks to be performed are completed through the services of the layer. The service of each layer mainly performs two functions: according to its lower service requirements, it provides corresponding services for the upper layer; the other is to provide corresponding services to its lower layer according to the service requirements of the upper layer. Services are implemented through service primitives. The primitive can be regarded as the API function is the most basic operation in ZigBee, the general protocol has the program implementation of the primitive. When you develop your own system, you only need to call and set the parameters. If you want to implement the underlying details yourself, you must go deep into the primitive level in the open source protocol stack. In other words, we only need to know about the primitive, and the real developer only knows which parameters we give to the system.
6 Summary
With the above foundation, we can do experiments according to the actual experimental platform. We have a general understanding of what the Zigbee protocol is, of course, this is only from the application layer, if you only use Zigbee technology to achieve the needs of users in your project, then you can develop the application layer according to the API provided by the actual protocol stack (such as the Zigbee development platform provided by Zmuri StackQuery TI). If you want to deeply study the Zigbee protocol stack or want to learn the design idea of the Zigbee protocol stack, it is recommended to read the open source Zigbee protocol stack source code (freakz protocol stack, TinyOS, etc.).
Remember to read ZIGBEE SPECIFICATION.
Official Information: Zigbee specification
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.