The APL Layer
The application (APL) layer is the highest protocol layer in a ZigBee wireless network. The ZigBee APL layer consists of three sections, shown in Figure 3.44 : the application support (APS) sublayer, ZigBee Device Objects (ZDO), and the application framework.
The application support sublayer (APS) provides an interface between the network layer (NWK) and the application layer (APL). The APS sublayer, similar to all lower layers, supports two types of services: data and management. The APS data service is provided by APS Data Entity (APSDE) and is accessed through the APSDE Service Access Point (SAP). The management capabilities are offered by APS Management Entity (APSME) and are accessed through APSME-SAP.
The APS sublayer constants and attributes start with apsc and aps , respectively. The APS attributes are contained in the APS Information Base (APS IB or AIB). The list of APS constants and attributes is provided in the ZigBee specification [3].
Network The application framework in ZigBee is the environment in which application objects are hosted to control and manage the protocol layers in a ZigBee device. Application objects are developed by manufacturers, and that is where a device is customized for various applications. There can be up to 240 application objects in a single device.
The application objects use APSDE-SAP to send and receive data between peer application objects ( Figure 3.44 ). Each application object has a unique endpoint
- - 考试资料.
- - .
address (endpoint 1 to endpoint 240). The endpoint address of zero is used for the ZDO. To broadcast a message to all application objects, the endpoint address is set to 255. Endpoint addressing allows multiple devices to share the same radio. In the light control example in Section 2.1.4, multiple lights were connected to a single radio. Each light has a unique endpoint address and can be turned on and off independently.
The ZigBee Device Objects (ZDO) provide an interface between the APS sublayer and the application framework. The ZDO contains the functionalities that are common in all applications operating on a ZigBee protocol stack. For example, it is the responsibility of the ZDO to configure the device in one of three possible logical types of ZigBee coordinator, ZigBee router, or ZigBee end device. The ZDO uses primitives to perform its duties and accesses the APS sublayer Management Entity via APSME-SAP. The application framework interacts with the ZDO through the ZDO public interface. The details of application framework, ZDO, and APS sublayer are reviewed in the following three subsections.
The Application Framework The ZigBee standard offers the option to use application profiles in developing an application. The use of an application profile allows further interoperability between the products developed by different vendors for a specific application. For instance, in a light control scenario, if two vendors use the same application profile to develop their products, the switches from one vendor will be able to turn on and turn off the lights manufactured by the other vendor. The application profiles are also referred to as ZigBee profiles.
Each application profile is identified by a 16-bit value known as a profile identifier .
- - 考试资料.
- - .
Only the ZigBee alliance can issue profile identifiers. A vendor that has developed a profile can request a profile identifier from the ZigBee alliance. The ZigBee alliance evaluates the proposed application profile and if it meets the alliance guidelines, a profile identifier will
be issued. The application profiles are named after their corresponding application use. For example, the home automation application profile provides a common platform for vendors developing ZigBee-based products for home automation use.
The general structure of an application profile is shown in Figure 3.45. The application profile consists of two main components: clusters and device descriptions. A cluster is a set of attributes grouped together. Each cluster is identified by a unique 16-bit number called a cluster identifier . Each attribute in a cluster is also identified by a unique 16bit number known as a attribute identifier . These attributes are used to store data or state values. For example, in a temperature control application, a device that acts as the temperature sensor can store the value of the current temperature in an attribute. Then another device that acts as the furnace controller can receive the value of this attribute and turn on or turn off the furnace accordingly. The application profile does not contain the cluster itself. Instead, the application profile has a list of the cluster identifiers. Each cluster identifier uniquely points to the cluster itself. The other part of an application profile is the device descriptions ( Figure 3.45 ). The descriptions provide information regarding the device itself. For example, the supported frequency bands of operation, the logical type of the device (coordinator, router, or end device), and the remaining energy of the battery are provided by the
- - 考试资料.
- - .
device descriptions. Each device description is identified by a 16-bit value. The ZigBee application profile uses the concept of descriptor data structure . In this method, instead of including the data in the application profile, a 16-bit value is kept and acts as a pointer to the location of the data. This pointer is referred to as the data descriptor . When a device discovers the presence of another device in the network, the device descriptions are transferred to provide the essential information regarding the new device. The device descriptions consist of five sections: node descriptor, node power descriptor, simple descriptor, complex descriptor, and user descriptor. The node descriptor provides information such as the node logical type and the manufacturer code. The node power descriptor determines whether the device is battery powered and provides the current level of the battery. The profile identifier and clusters are provided in the simple descriptor . The complex descriptor is an optional part of the device descriptions and contains information such as the serial number and the device model name. Any additional information regarding the device can be included as the user descriptor . The user descriptor can be up to 16 ASCII characters. For example, in a light control application, the user descriptor field of a wall switch installed in a hallway can read Hall switch .
The node descriptor fields for ZigBee-2006 are provided in Figure 3.46 . The node descriptor is a mandatory part of the device descriptions. The logical type can be ZigBee coordinator, router, or end device. The complex descriptor and user descriptor are optional and if their corresponding fields in the node descriptor are set to zero, they are not provided as part of the device descriptions. The APS flag field determines the APS
- - 考试资料.
- - .
sublayer capabilities. The frequency band (868 MHz, 915MHz, or 2.4 GHz) is specified in the frequency band field. The MAC capacity flags field is the same as the MAC capacity field presented before in Figure 3.25 . A manufacturer can request and receive a manufacturer code from the ZigBee alliance. This code is included in the node descriptor. The maximum size of the APS Sublayer Data Unit (ASDU), in octets, is specified in the maximum buffer size field. The maximum size of a single message that can be transferred to or from a node is provided in the maximum transfer size field (in octets). In ZigBeePro, the maximum incoming transfer size and maximum outgoing transfer size are two separate fields (16 bits each).
The server mask field provides information regarding the system server capabilities of this node. A server is a device that provides specific services to other devices in the network. If each bit is set to one, the device has the corresponding capability shown in Figure 3.46 . The trust center is the device trusted by devices within a network to distribute security keys for the purpose of network and end-to-end application configuration management. The security features are reviewed in Section 3.6. The primary binding table cache is a device that allows other devices to store their binding tables with it as long as it has storage space left. The binding procedure is further clarified in this subsection. The primary binding table cache can be used to back up the content of binding tables and restore them whenever necessary. A device can choose to keep its own binding table, known as a source binding table , instead of storing it with a primary binding table cache. However, any device can store a backup of the source binding table in the primary biding table cache device and recover it later if necessary.
- - 考试资料.
- - .
A ZigBee network may have a primary discovery cache device. This device is a ZigBee coordinator or router used to store the descriptors such as node descriptors and power descriptors of some other devices. An end device, for example, that sleeps for long durations can store its descriptors in the primary discovery cache device. If a device in the network tries to locate the information regarding this sleeping end device while the device is inactive, it can get the information from the primary discovery cache device instead. If a network contains sleeping ZigBee end devices, the network must have at least one primary discovery cache device.
应用层(APL)是在ZigBee无线网络协议栈中最高的一层。应用层包含三个组成部分,见下图3.44:应用支持子层(APS),ZigBee设备对象(ZDO),以及应用层框架(AF)。应用支持子层(APS)提供了网络层(NWK)和应用层(APL)之间的接口。该层和所有较低层相似,支持两种服务:数据和管理服务。APS层数据服务由APS数据实体(APSDE)通过APSDE服务接入点(APSDE-SAP)提供。管理功能由APS管理实体(APSME)通过APSME服务接入点(APSME-SAP)提供。APS子层的常量和属性分别始于apsc和aps。APS属性包含在APS信息库(APS IB或AIB)中。APS常量和属性列表由ZigBee协议栈规范提供[3]。ZigBee应用层框架(AF)是为驻扎在ZigBee设备中的应用对象控制和管理协议栈各层提供活动的环境。应用对象由制造商开发,也正是在这里定制了基于各种不同应用的
- - 考试资料.
- - .
设备。在一个设备中可以有多达240个应用对象。应用对象使用APSDE-SAP在应用对象节点之间发送和接收数据(图3.44)。每个应用对象都有一个专有的终端节点地址(端点1—端点240)。端点0用于ZDO。端点地址255被设置用来广播消息到所有的应用对象。设定终端地址允许多个设备共享同一频段。在2.1.4节的灯控制例程中,多个灯连接在同一个频段里。每个灯都有一个专用的端点地址,并且能够独立的打开或关闭。ZigBee设备对象(ZDO)提供了APS子层和应用层框架(AF)之间的接口。ZDO包含了所有运行在ZigBee协议栈上的应用所共有的功能。例如,定义设备属于ZigBee协调器、路由器或终端设备三种逻辑类型之一就是ZDO的职责。ZDO使用原语来执行它的任务,并通过APSME-SAP进入APS子层管理实体。应用层框架(AF)通过ZDO公共接口与ZDO相互作用。关于应用层框架(AF)、ZDO和APS子层的细节的详细回顾见于以下三节。
•3.5.1 应用层框架(AF)ZigBee标准提供了在开发应用时使用应用profiles的选项。应用profiles的使用使得不同开发商开发的基于某种特定应用的产品之间有更多的共同使用性。比如,在灯控制情景中,如果两个开发商使用同一个应用profiles来开发他们的产品,一个开发商制造的开关将能够打开或关闭另一个开发商制造的灯。应用profiles也是基于ZigBee profiles的。每个应用profiles都由一个被称作profile标识符的16位数值所标记的。只有ZigBee联盟能够设定profile标识符。开发商如果自行开发了一个profile,他可以向ZigBee申请一个profile标识符。ZigBee联盟评估被提议的应用profile,如果其符合联盟准则,一个新的profile标识符就会被设定。应用profiles以与其相应的应用来命名。例如,家庭自动化应用profile提供一个公共平台给开发用于家庭自动化的基于ZigBee产品的开发商们。应用profile的总体结构见图3.45。应用profile包含两个主要组成部分:簇(clusters)和设备描述(device descriptions)。簇是一组整合在一起的属性。每个簇都由称为簇标识符(cluster identifier)的唯一16位数字所标记。簇中的每个属性也由称作属性标识符(attribute identifier)的唯一16位数字所标记。这些属性用来存储数据或状态值。例如,在温度控制应用中,作为温度传感器的设备能在属性中存储当前温度数值。然后另一个作为火炉控制器的设备就能接受该属性值,并据此打开或关闭火炉。应用profile不包含簇本身,而是包含一个簇标识符列表。每个簇标识符都专一地指向该簇本身。应用profile的另一个部分是设备描述(device descriptions)(图3.45)。设备描述提供关于设备自身的信息。例如,可供使用的频率波段,设备的逻辑类型(协调器、路由器或终端设备),以及设备提供的剩余电量,都是由设备描述所提供的。每个设备描述由一个16位数值所标记。ZigBee应用profile使用描述数据结构(descriptor data structure)这一概念。正是用这一取代了包含应用profile数据的方法,一个16位数值作为指向数据所在地址的指针而被保存。该指针称为数据描述指针。当一个设备发现网络中另一个设备的出现时,设备描述就会被传送以提供关于该新设备的基本信息。设备描述由5个部分组成:节点描述(node descriptor),节点电源描述(node power descriptor),简单描述(simple descriptor),复杂描述(complex descriptor)和用户描述(user descriptor)。节点描述提供诸如节点逻辑类型和制造商编码这类信息。节点电源描述决定了设备是否由电池供电,并提供当前电量。Profile标识符和簇由简单描述提供。复杂描述是设备描述的可选部分,它包含诸如序列号和设备模型名称之类的信息。任何关于设备的附加信息都可以被用户描述所包含。用户描述可以多达16位ASCII码。例如,在灯控制应用中,安装在过道的墙上开关的用户描述区域就被读作“过道开关(Hall switch)”。ZigBee-2006的节点描述区域见图3.46。节点描述是设备描述的命令部分。逻辑类型可能是协调器、路由器或终端设备。复杂描述和用户描述是可选项,如果它们在节点描述中的相应区域被设为0,则不会作为设备描述的组成部分而被提供。APS标志区域决定了APS子层的功能。频段(868MHz, 915MHz, 或2.4 GHz) 在频段区域中被指定。MAC功能标志和之前在图3.25中显示的MAC功能区域一样。制造商可以向ZigBee联盟申请并获得一个制造商编码。该编码包含在节点描述中。8进制的APS子层数据单元(APSDU)长度极大值在长度极大值缓存区域中被指定。送往或来自节点的单个消息的长度极大值由传送极大值区域提供(8进制)。在ZigBee-Pro版本中,传送输入长度极大值和传送输出长度极大值是分离的两个区域(每个16位)。服务器掩码区域提供关于该节点系统服务功能的信息。服务器(server)
- - 考试资料.
- - .
是为网络中其它设备提供特定服务的设备。如果每一位都被置位为1,设备就拥有如图3.46所示的相关功能。信托中心(trust center)被网络中的所有设备所信任,并为网络的用途和终端-终端应用结构管理分配安全密钥。安全特征见于3.6节。初始绑定表缓存设备只要还有存储空间剩余,就允许其它设备使用该设备来存储它们的绑定表。绑定过程在这一子区域中被进一步阐明。初始绑定表缓存能用来备份绑定表目录,并能在任何必要的时候加以存储。一个设备可以选择保存被称为源绑定表的自身绑定表,而不储存初始绑定表缓存。然而,任何设备都能在初始绑定表缓存设备中存储源绑定表的备份,并且能在必要的情况下予以恢复。一个ZigBee网络也许会有一个初始发现表缓存设备。该设备是ZigBee协调器或路由器,其被用以储存诸如其它设备的节点描述和电源描述之类的各种描述。像长时间休眠这样的终端设备可以在初始发现缓存中储存它的描述。如果网络中的某设备尝试找到此正处于不活动状态的休眠终端设备的相关信息,它可以从初始发现缓存设备获得此信息以作替代。如果一个网络包含休眠中的ZigBee终端设备,则其必须拥有至少一个初始发现缓存设备。
- - 考试资料.
因篇幅问题不能全部显示,请点此查看更多更全内容