Speaker : Chang Kai-Jia Date : 2010/5/12 ZigBee, ZDO, and ZDP Speaker : Chang Kai-Jia Date : 2010/5/12
Contents Zigbee network services ZigBee Device Object ZigBee Device Profile Device discovery services Service discovery services Binding services Management services
APSME-SAP ZigBee應用層目前只定義編號1~240的240個元件,而241~254則是保留予未來使用。另外,編號0與編號255是給予其他介面使用。ZigBee應用層的通訊基礎是由ZigBee產品供應商發展的類別(Profile)所構成,某一類別提供對ZigBee特定應用技術需求的解決方案。類別是有關啟動ZigBee元件應用的共通訊息、訊息格式,與處理動作的協定,用以產生相互運作的分散式應用,其中包括不同元件間指令傳送、數據要求,及處理指令與要求。ZigBee元件Cluster是由8bit Cluster ID所辨認,在一類別中Cluster ID是唯一的。 ZigBee應用層主要是透過應用層支援子層(APS)與網路層溝通。在APS中有APS數據個體(APSDE)與APS控管個體(APSME)兩個軟體模組。其中APSDE提供同一WPAN中不同元件間的數據傳輸服務,而APSME則提供元件間發現(Discovery)與連繫(Binding)服務,並且APSME也維護一稱為APS資訊基礎(APS Information Base, AIB)的物件數據庫。 ZigBee元件藉著送出尋問(Query)啟動發現程序(Discovery Process)來尋找周邊其他的ZigBee元件(Device Discovery),與這些元件提供的服務(Service Discovery)。ZigBee應用層使用兩種Device Discovery要求格式:即16-bit IEEE地址要求與64-bitI NWK地址要求。其中IEEE地址要求是在已知NWK地址下,以單傳(Unicast)送出,而NWK地址要求是將IEEE地址置於封包的數據負載中以廣播(Broadcast)方式送出。對應於發現要求訊息,依據要求訊息與被要求元件角色特性,可能有不同的回應。若為ZigBee一般元件,回應相關的IEEE或NWK地址;若為ZigBee網路協調器或路由器,則回應網路協調器或路由器本身的IEEE或NWK地址,及其他與網路協調器或路由器聯結的元件IEEE或NWK地址。而Service Discovery提供ZigBee元件以決定其他ZigBee元件所供應的服務,其所對應的回應種類與方式與Device Discovery類似,亦分為單傳與廣播,但詢問形式與回應內容不同。 ZigBee應用層亦提供元件間的連繫功能,即在互補的應用元件間產生邏輯連動,此連動記錄在一連繫表中,這對於有相互關係的控制元件或感測器特別有用。 在完成Device Discovery與Service Discovery後,ZigBee元件間可建立關聯,並且開始傳送指令到特定的ZigBee地址。 在定址方面有三種方式,即直接定址、間接定址,與廣播定址。ZigBee主控元件自Device Discovery與Service Discovery取得目的地元件的地址與Cluster ID,可使用直接定址。在ZigBee網路協調器連繫資料表中有直接定址的記錄,可使用APSDE透過連繫來做間接定址,這對欲節省能量與記憶體的簡易型感測元件特別有用。另外,可使用廣播定址將應用廣播給所有元件,在此狀況中,目的地的地址是16bit網路廣播地址且須設定APS時框中的廣播旗標。 在應用層中還有一個稱為ZigBee元件物件(ZigBee Device Object, ZDO)的軟體模組,做為應用物件、元件應用類別與APS間的介面。ZDO位於應用架構與APS之間,負責啟動APS、網路層與保密服務,及負責組合來自使用者的設,定資訊以決定並執行發現、保密控管、網路控管與連繫。此介面亦提供應用層中有關元件發現、連繫與保密功能的定址管理。
Zigbee network services ZigBee contains two sets of services for network commissioning and maintenance: The ZigBee Device Object (together with the ZigBee Device Profile) The ZigBee Cluster Library ZigBee Device Object (ZDO) ZigBee Device Profile (ZDP) ZigBee Cluster Library (ZCL)-Ch6 ZigBee的包含兩個項目commission(委任)和maintenance(維護)來支援網路服務
ZigBee Device Object ZDO is a specialized of application object (with profile ID 0x0000) which each node must have this to manage: Configuring, and maintaining ZigBee devices and services on the network. Keeps track of the state of the ZigBee device on and off the network. Provides an interface to the ZDP. Establish the security relationship between two nodes. Glossary
Glossary Profile ID: 16-bits(0x0000~0xFFFF) Application Pro: Each application profile addresses the needs of a specific application market. Stack Pro: Main provisions of the general nature of the network parameters.(p.154) Cluster ID: 8-bits(0x00~0xFF) Nwk_Addr_Req (Cluster Id: 0x00), according to IEEE address to refer short address. Nwk_Addr_Rsp (Cluster Id: 0x80)。Check myself address match with zdpNwkAddrReq (Cluster Id: 0x00) ,and send response. Profile:Profile ZigBee所定義的Profile有兩種: *Application Pro:針對各種不同應用情境所定義出的概略行為藍圖,如Home Control Lighting(HCL)和Home Automation(HA)。一般所稱的Profile通常是指此種Profile。 *Stack Pro:主要規定通用性的網路參數,如Network Specific、Home Controls(HC)、Building Automation(BA)、Plant Control等Stack Profile。 ZigBee已公開Profile ID的Profile為Home Controls(0x1) 、Building Automation(0x2) 、Plant Control(0x3)。但皆設定為無Beacon的Beacon Order為0xf。 原則上Application Profile中會說明可採用何種Stack Profile來作為基礎網路建構方案,如HCL中即採用HC作為網路建構方案。 ZCL:這個庫允許共同集群重用跨若干不同的功能領域,例如,同樣的照明集群可以用於任何應用程序需要照明的控制,如家庭自動化和商業樓宇自動化。 集群內的ZCL被組織成若干不同的功能領域,包括照明,HVAC(暖氣,通風,空調),測量和遙感,保安和安全,和一般。 Cluster表示法存疑p.253 一個為客戶服務,一個為服務器端服務 : zdpNwkAddrReq (Cluster Id: 0x00),根據已知的IEEE地址查詢源端的短地址 zdpNwkAddrRsp (Cluster Id: 0x80)。檢測自身的端的址是否與zdpNwkAddrReq (Cluster Id: 0x00)中的請求匹配,並產生相應的回應
在傳輸資料裡會有幾個辨別資料 - Profile ID 定義應用類別ID,每個應用程序 配置文件 解決了需要特定的應用市場。由Zigbee Alliance訂定。 - Cluster ID 所有ZigBee應用配置文件定義使用集群從ZigBee的 集群 圖書館。不同裝置所收發的互動資訊ID - Description 製造相關資訊 裝置應用資訊 應用屬性
Glossary Endpoint: Endpoint is like Socket on the same network(PAN). 8-bits addressing. Endpoints are a logical extension added to a single ZigBee radio which permits support for multiple applications, addressed by the Endpoint number (1-240) . One Application Profile described per Endpoint. Maximum of 240 Endpoints per ZigBee Device (Endpoint 0 is reserved to describe the generic device capabilities and Endpoint 255 is reserved for broadcasting to all endpoints, Endpoints 241-254 are reserved for future use) 定義Endpoint/Interface description 說明: 每一個APPLICATION OBJECT 坐在一個ENDPOINT上面。 ENDPOINT 是DEVICE NETWORK ADDRESS的延伸(我想類似於PORT吧) ENDPOINT 為0~255 (8bit) 其中0留給ZDO, 241~254保留,255用來廣播給所有的ENDPOINT。
ZigBee Device Object ZDO not only interacts with APS, but also interacts directly with the network layer. ZDO controls the network layer, telling it when to form or join a network, and when to leave, and provides the application interface to network layer management services For example, ZDO can be configured to continue attempting to join a network until it is successful, or until a user-specified number-of-retries has occurred before giving up, and informing the application of the join failure. ZigBee裝置管制物件(ZigBee Device Object, ZDO) ZDO可視為應用程式物件之一,所不同的是ZDO專門負責整體系統的管理事務,Endpoint 0只能且必定由ZDO使用,每個節點都一定有此物件。負責工作有: *定義或調整本身裝置在網路上的角色(ZC、ZR或ZED)。 *建構上層應用所需的資訊、發出或回應連結的要求。 *搜尋並探知其他網路節點可用的應用程式服務。 *起始與回應配對要求。 *建立兩網路節點間的安全性關係。
ZigBee Device Profile ZDP services include the following categories: Device discovery services Service discovery services Binding services Management services ZDP contains a set of commands for discovering various aspects about nodes in the network. ZDP有一組命令用於發現各個方面對網絡中的節點。
Device Discovery Device discovery services have a few things in common: They provide additional information about a node. They are all optional from the client side, but some server side processing is mandatory (a common subset among all ZigBee devices). They are node-wide, and do not represent any particular application, or Application Profile residing on an endpoint in the node. 他們提供更多的信息節點 它們都是可選的客戶端,服務器端處理,但有些是強制性的(一種常見的子集所有ZigBee設備)。 他們是節點範圍內,並不代表任何特定應用程序或應用程序文件駐留在一個端點的節點。 Device discovery services Service discovery services Binding services Management services
ZDP v.s Endpoint The ZigBee specification calls these “ device discovery services, ” which can be confusing because endpoints contain device IDs which really describe individual ZigBee applications running in that node. So, when you see ZDP Device Discovery, think node-wide services. (not application/endpoint specific) 針對ZDP 的Device discovery services 與endpoint作比較
Device Discovery Notice that all the ZDP services on the client side are optional. ZigBee does not require that a node be able to send NWK_addr_req , for example. But on the server side of this equation (a node receiving a NWK_addr_req and responding to it), the ZDP service is mandatory. 請注意,有關NDP灣的所有客戶端上的服務是可選的。 ZigBee的並不要求一個節點能夠發送 NWK_addr_req, 例如。但在服務器端這個方程(一節點接收NWK_addr_req和響應的),ZDP service是強制性的。
A tool may want to collect the IEEE (aka MAC) address of every node in the network (using IEEE_addr_req , for example) so all nodes in the network must support the server side ( IEEE_addr_rsp ). Use requestType 0x00 to get only the IEEE and NWK address for one node. Use the extended requestType 0x01 to get the information for the node and for all its children as well. Remember, only routers will have children. 一個工具要蒐集每一個節點的IEEE address(使用IEEE_addr_req),因此所有節點在網絡中必須支持服務器端(IEEE_addr_rsp)。 使用requestType 0x00到只得到IEEE和樹狀地址為一個節點。 使用擴展 requestType 0x01獲取信息的節點,並為所有兒童。請記住,只有路由器將有子女。
Problem: which response belongs to which request Some stack vendors have solved this problem by only allowing a single request to be issued at any one time. Other stack vendors, provide a transaction ID which correlates the request with the response. This rolling 8-bit transaction ID is sent with each request, meaning, in theory, that a single application could have up to 256 requests in flight at once. Normally, however, an application makes one or two requests, and then waits for the response. 有些廠商已經解決了這個堆棧問題只允許一個單一的請求發出的任何一次。 其他堆棧供應商,提供了一個事務 ID的關聯請求與響應 這種滾動 8位交易ID是發送的每個請求,這意味著,在理論上,一個單一的應用程序可能有多達 256個要求在飛行一次。正常情況下,但是,應用程序,使一個或兩個請求,然後等待響應。
Set up ZDP services: Use ZDP to discover which nodes to talk to in a ZigBee network. Optional ZDP services may be mandatory in the application profile. Remember to enable the optional services if they are needed by a BeeStack application. Because embedded system that are very limited by RAM and Flash (ROM), which means every byte can be precious. 使用ZDP發現該節點在交談 ZigBee網絡。 可選ZDP services可能被強制配置在應用程序配置文件。 記住,使他們的自選服務,如果需要由BeeStack堆棧的應用 由於嵌入式系統是非常有限的內存和閃存(ROM)中,這意味著每一個字節可寶貴的。所以ZDP必須要謹慎的選擇並設置
Service Discovery In addition to the services related to devices, or nodes, ZDP also contains a variety of standard services for querying the applications within those As with the device discovery services, most of the ZDP service discovery services are optional. Only a few service side responses are required. 除了服務有關的設備或節點,也包含了多種有關ZDP標準查詢服務,在這些節點上的應用 由於該設備發現服務,大部分的ZDP服務發現服務是可選的。 只有少數服務方面的反應是必需的。 Device discovery services Service discovery services Binding services Management services
Discovering and Matching Endpoints Discovering application endpoints and the services they support is a common commissioning step in ZigBee. Backing Up and Caching Discovery Information ZigBee utilizes the concepts of backing up and also caching the discovery information. 發現和匹配端點 發現端點和應用的服務,他們的支持是一種常見的調試步驟在ZigBee。 備份和緩存信息的發現 利用ZigBee的概念,並備份緩存的發現信息。
Example: Use a Discovery_store_req first to allocate the space on the discovery cache for the various items, including endpoints and simple descriptors Then use the various store commands (Simple_Desc_store_req ) to actually store the data on the cache. Using System_Server_Discovery_req , other nodes in the network can find the cache and request the sleeping node’s information using commands such as Active_EP_req . This ZDP commands: System_Server_Discover_req Find_node_cache_req Discovery_Cache_req Discovery_store_req Node_Desc_store_req Power_Desc_store_req Active_EP_store_req Simple_Desc_store_req Remove_node_cache_req 使用Discovery_store_req先分配緩存空間發現的各種項目,包括端點和簡單的描述,然後使用不同的存儲命令(例如,Simple_Desc_store_req)實際存儲數據的緩存。使用System_Server_Discovery_req,在網絡中其他節點可以找到緩存,並要求睡眠節點的信息使用命令,如Active_EP_req。
Binding Binding provides a mechanism for attaching an endpoint on one node to one or more endpoints on another node. Binding can even be destined for groups of nodes. Then, when using APSDE-DATA.request, simply use the “ indirect ” addressing mode, and the request will be sent to each endpoint or group listed in the local binding table. 綁定 在一個較高水平,具有約束力的建立過程是兩個設備之間的關係,可以溝通的一個有意義的方式,例如,該開關控制的燈。每個綁定支持一個特定的應用程序 配置文件 ,每個消息類型是由一個 群集 內的 個人資料. 綁定可以創建任何個人或團體之間的端點,如燈光,開關,具有輸入和輸出匹配簇(與同一 群集 名 )。 ZigBee設備最多可以有240個端點,因此每一個物理設備可以支持多個綁定。 Device discovery services Service discovery services Binding services Management services
Binding( cont. ) The binding table is smart, and keeps track of both the short (16-bit NwkAddr) and long (IEEE) address of a node. If a destination device has changed its short address (either due to a ZigBee End-Device moving from one parent to another in ZigBee stack profile 0x01, or due to a address conflict in ZigBee Pro), the binding table entry is updated automatically to point to that new address. 綁定表是聰明的,並保持追踪的短期(16位NwkAddr)和長期(IEEE)的地址的一個節點。 如果目標設備已經改變了短地址(或者由於 ZigBee終端設備移動到另一個從父母一方在ZigBee協議棧配置0x01,或由於解決衝突的ZigBee Pro)的,有約束力的表項會自動更新為指向這一新的地址。
Binding( cont. )
Binding( cont. ) Sender: src EP:12 Src EP:5-it would go to three destinations node 0x1234 endpoint 12 broadcast to group 0x9999 node 0x5678 endpoint 44
End_Device_Bind_req uses an optional state machine on the ZigBee Coordinator to bind or unbind two devices. This service can be useful in a “ press-the- button-on-two-nodes-to-bind-them ” operation, useful on some Home Automation products. End_Device_Bind_req使用一個可選的國家機器在ZigBee的協調員,綁定或解除綁定兩台設備。 這項服務可以發揮了“壓在按鈕上雙節點到約束他們”的行動中,一些有用的家庭自動化產品。
Binding( cont. ) Demonstrates a third-party node binding a switch to a light over-the-air. Granted, it shows the concept of ZigBee commissioning with a third-party tool. The ZDP bind commands require an IEEE address. If a node receives a ZDP bind command and it doesn’t know about the destination address, it will issue a ZDP NWK_Addr_req to find the node, because it actually needs both long and short addresses to complete the operation. 演示第三方節點綁定用無線傳輸切換到亮燈。誠然,它顯示了概念的ZigBee委託與第三方工具。 ZDP綁定的命令需要一個 IEEE地址。 如果一個節點接收到一個 BIND命令和ZDP它不知道目的地的地址,它會發出知ZDP NWK_Addr_req找到節點,因為它實際上需要長期和短期的地址來完成操作
Management Services The ZDP Management services are really handy optional services used for reading the various tables contained within ZigBee nodes, and to request certain common actions 方便可選則服務用於閱讀各種表格內所載的ZigBee節點,並請求某些公用的動作 Network Discovery Mgmt_NWK_Disc_req— implemented both to support frequency agility, which is the ability for the ZigBee network to change channels, and to help prevent PAN ID conflicts. (支援頻率靈活性,這是使ZigBee網路可以改變通道,並幫助防止PAN ID衝突) Table Management Services Mgmt_Lqi_req—the neighbor table Mgmt_Rtg_req—the routing table Mgmt_Bind_req—the (optional) binding table Informing Other Nodes to Leave the Network Mgmt_Direct_join_req —is not used much. It’s easier to simply use the network rejoin command, available through ZDO. Mgmt_permit_joining_req —can be very useful for disabling joining all throughout the network. Typically, this is the last step when commissioning a network. It closes it down to prevent other nodes getting on the network without permission.(通常,這是最後一步時,委託網絡。它關閉它,以免讓其他節點未經允許加入網路) Device discovery services Service discovery services Binding services Management services
Starting and Stopping ZigBee with ZDO ZDO_Start() gStartWithOutNvm_c gStartAssociationRejoinWithNvm_c gStartNwkRejoinWithNvm_c gStartSilentRejoinWithNvm_c ZDO_Stop() ZDO_Leave() Non-Volatile Memory(NVM): 「非揮發性記憶體」,或「非消失性記憶體」,即當 電源關掉時,資料仍然存在。 Starting without non-volatile memory (NVM) ensures that the node does not use anything it remembers from the last time it was booted and joined a network. 開始沒有非易失性存儲器(NVM)確保該節點不使用任何它記得從最後一次被啟動,並加入了一個網絡。 Association join (or rejoin) uses the MAC association commands to join the network. 參加協會(或重新加入)使用MAC association commands加入該網路 Rejoin with NVM rejoins the network using the same PAN and channel selected previously.重新加入網路用NVM並使用與之前相同的通道 The node may get a new short address. 可能會有新的short address The silent rejoin is very useful when nodes are reset after a battery change, or after a mains-powered network has reset after a power outage.當節點被重置後,更換電池,或在一個電源供電網絡斷電後復位。 The nodes do not actually say anything over the air, they simply start up and are capable of routing in a few tens of milliseconds.
Layers addressing : MAC: NWK: APS: 64bits IEEE address (long address、mac address) 16bits NWK address(short address) NWK: 16bits NWK address APS: 8bits Endpoint
Reference ZigBee: Addressing Energy Efficiency How to use the ZigBee Device Object (ZDO) What is a ZigBee Application Profile? Zigbee Alliance 新通訊 2006 年 2 月號 60 期 Zigbee Network Layer Tutorial - Part 3: Broadcasts and Neighbors AODV Design and Application of ZigBee/Ethernet Gateway in Remote Control Systems