Z-STACK开发者指南___最新翻译
Zstack入门教程
Zstack入门教程第一步:安装Zstack从TI官方网站上下载的Zstack为:swrc072c.zip,我想这个压缩包大家都认识。
解压之后为:ZStack-CC2430-1.4.3.exe文件。
这个安装文件大家都会了。
默认安装路径为:C:\Texas Instruments\ZStack-1.4.3。
安装之后在C:\Texas Instruments\ZStack-1.4.3目录下有各PDF 文档为:Getting Started Guide CC2430.pdf,不用多说,这个肯定是要看的。
既然把它放到这么前面,说明它是入门中的入门文档。
下面就简单介绍下这个文档:1、介绍了安装ZStack-CC2430-1.4.3.exe需要的硬件软件条件:需要电脑、操作系统为Windows 2000或Windows XP。
至于更高或更低版本的本人没有尝试。
2、讲了安装流程。
这个有点多余了,这年月哪个有电脑的没有安装上百上千次的软件啊?但是需要强调的是安装路径----默认就好!3、接下来就是让我们看的第一个文档为:Start->Programs->Texas Instruments->ZStack-1.4.3->Z-Stack User’s Guide,既然让我看我就来看看这个文档!!第二步:Z-Stack 用户指导这个文档的更新时间为:2007年12月21日----应该还是比较新的版本。
由于本人英文的却有限,就不翻译了,浏览一遍,把大概意思说下就可以了:1、介绍1.1、适用范围本文档适用于CC2430ZigBee开发板----CC2430ZDK。
2、产品包描述(TI提供的CC2430ZDK工具包)2.1、安装包内容这个就是上面提到的的ZStack-CC2430-1.4.3.exe安装之后的所有内容了。
说白了就是包含Zstack开发所需要的所有软件和文档资料等。
2.2、开发板介绍两块SmartRF04EB 评估版,每个都可以用于CC2430EM评估模块。
ZStack V3.10.0 日志服务器 使用教程说明书
3. 验证日志服务器
文档版本:V3.10.0
5
日志服务器 使用教程 / 3 典型场景实践
配置完成后,在日志服务器中输入以下命令,查看是否已正常获取管理节点日志: cat /var/log/test.log
如图 3: 获取管理节点日志所示: 图 3: 获取管理节点日志
如上所述,日志服务器已成功接收到管理节点日志信息,日志服务器配置生效。
云主机(VM Instance)
运行在物理机上的虚拟机实例,具有独立的IP地址,可以访问公共网络,运行应用服务。
镜像(Image)
云主机或云盘使用的镜像模板文件,镜像模板包括系统云盘镜像和数据云盘镜像。
文档版本:V3.10.0
7
日志服务器 使用教程 / 术语表
云盘(Volume)
云主机的数据盘,给云主机提供额外的存储空间,共享云盘可挂载到一个或多个云主机共同使用。
如图 1: 配置syslog server所示: 图 1: 配置syslog server
2. 在云平台创建日志服务器 在ZStack私有云主菜单,点击平台管理 > 日志服务器按钮,进入日志服务器界面,点击添加 日志服务器按钮,参考以下内容进行配置:
• 名称:设置日志服务器名称 • 简介:可选项,可留空不填 • IP地址:输入日志服务器的IP地址
注意事项 • 需要设置日志级别与日志服务器的配置完全一致,才能正常接收日志信息,日志级别支持设 置LOCAL0-9,仅为了匹配日志服务器,无高低之分。 • 需确保云平台管理节点与日志服务器的连通性。 • 配置成功后,管理节点的全部日志均会发送至日志服务器,不区分DEBUG、INFO、ERROR等 输出级别。 • 仅admin/平台管理员支持设置日志服务器。
描述Z-Stack协议栈中原语通信方式并举例说明
描述Z-Stack协议栈中原语通信方式并举例说明Z-Stack是一个通信协议栈,特别设计用于无线个人局域网(WPAN)中的网络通信。
在Z-Stack协议栈中,原语通信是一种基本的通信方式,它被广泛应用于实现各种网络功能和通信需求。
本文将深入探讨Z-Stack协议栈中原语通信方式,并通过举例说明其应用。
让我们了解一下什么是原语通信。
在通信领域,原语通信是指将通信过程分解为多个原子级别操作的方式。
每个原子操作都是具有明确功能和定义的通信操作,通过将这些原子操作组合使用,可以构建复杂的通信功能。
在Z-Stack协议栈中,各个原语通信操作被封装为接口,为开发人员提供了使用这些操作来实现不同的通信需求的能力。
在Z-Stack协议栈中,常见的原语通信方式包括以下几种:1. 数据发送原语(Data Send Primitive):这是一种用于在Z-Stack 协议栈中发送数据的原始操作。
开发人员可以使用该原语通过指定目标设备、目标端口等参数来发送数据。
开发人员可以使用Data Send Primitive操作将数据包发送到指定的无线设备。
2. 数据接收原语(Data Receive Primitive):这是一种用于在Z-Stack协议栈中接收数据的原始操作。
开发人员可以使用该原语监听指定端口,并在数据到达时接收并处理数据。
开发人员可以使用Data Receive Primitive操作来接收从其他设备发送过来的数据包。
3. 路由原语(Routing Primitive):这是一种用于在Z-Stack协议栈中进行路由操作的原始操作。
开发人员可以使用该原语来管理数据包的路由路径,并控制数据包在网络中的传递。
开发人员可以使用Routing Primitive操作来选择最佳的路由路径以确保数据包能够正确传输到目标设备。
4. 邻居表原语(Neighbor Table Primitive):这是一种用于在Z-Stack协议栈中管理邻居设备信息的原始操作。
Z-stack协议栈开发指南
路由
Z-Stack 采用无线自组网按需平面距离矢量路由协议 AODV,建立一个 Hoc 网络,支持移动节点,链接失败和数据丢失,能够自组织和自修复。当一个 Router 接受到一个信息包之后,NMK 层将会进行以下的工作:首先确认目的地,如果目 的地就是这个 Router 的邻居,信息包将会直接传输给目的设备;否则,Router 将会确认和目的地址相应的路由表条目,如果对于目的地址能找到有效的路由表 条目,信息包将会被传递到该条目中所存储的下一个 hop 地址;如果找不到有效 的路由表条目,路由探测功能将会被启动,信息包将会被缓存直到发现一个新的 路由信息。
协调器(Coordinator)首先在某个频段发起一个网络,网络频段的定义放 在 DEFAULT_CHANLIST 配置文件里。如果 ZDAPP_CONFIG_PANID 定义的 PAN ID 是 0xFFFF(代表所有的 PAN ID),则协调器根据它的 IEEE 地址随机确定一个 PAN ID。 否则,根据 ZDAPP_CONFIG_PANID 的定义建立 PAN ID。当节点为 Router 或者 End Device 时,设备将会试图加入 DEFAULT_ CHANLIST 所指定的工作频段。如果 ZDAPP_CONFIG_PANID 没有设为 0xFFFF,则 Router 或者 End Device 会加入 ZDAPP_CONFIG_PANID 所定义的 PAN ID。
ZigBee End Device 不会执行任何路由函数,它只是简单的将信息传送给前 面的可以执行路由功能的父设备。因此,如果 End Device 想发送信息给另外一 个 End Device,在发送信息之间将会启动路由探测功能,找到相应的父路由节 点。
(Z-Stack Developer’s Guide)外文翻译
Z-Stack Developer’s Guide1. Introduction1.1 PurposeThis document explains some of the components of the ZigBee stack and their functioning. It explains the configurable parameters in the ZigBee stack and how they may be changed by the applicationdeveloper to suite theapplication requirements.1.2 ScopeThis document describes concepts and settings for the z-Stack Release v1.4.1. This is a ZigBee-2006 compliantstack.1.3 AcronymsAF Application FrameworkAIB APS Information BaseAPI Application Programming InterfaceAPS Application Support Sub-LayerAPSDE APS Date EntityAPSME APS Management EntityASDU APS Service Datagram UnitMSG MessageNHLE Next Higher Layer EntityNWK NetworkPAN Personal Area NetworkZDO ZigBee Device Object1.4 Reference DocumentsZigBee Specification, R13, ZigBee Alliance document number 053474r13ZB.ZStack API (F8W-2006-0021)2. ZigBeeA ZigBee network is a multi-hop network with battery-powered devices. This means that two devices that wish toexchange data in a ZigBee network may have to depend on other intermediate devices to be able to successfully doso. Because of this cooperative nature of the network, proper functioning requires that each device (i) performspecific networking functions and (ii) configure certain parameters to specific values. The set of networkingfunctions that a device performs determines the role of the device in the network and is called a device type. The setof parameters that need to be configured to specific values, along with those values, is called a stack profile.2.1 Device TypesThere are three logical device types in a ZigBee network – (i) Coordinator (ii) Router and (iii)End-device. AZigBee network consists of a Coordinator node and multiple Router and End-device nodes. Note that the device type does not in any way restrict the type of application that may run on the particular device.An example network is shown in the diagram above, with the ZigBee coordinator ( in black ), the routers ( in red ) and the end devices ( white ).2.1.1 CoordinatorThis is the device that “starts” a ZigBee network. It is the first device on the networ k. The coordinator node choosesa channel and a network identifier ( also called PAN ID ) and then starts the network.The coordinator node can also be used, optionally, to assist in setting up security and application-level bindings inthe network.Note that the role of the Coordinator is mainly related to starting up and configuring the network. Once that isaccomplished, the Coordinator behaves like a Router node ( or may even go away ). The continued operation of thenetwork does not depend on the presence of the Coordinator due to the distributed nature of the ZigBee network.2.1.2 RouterA Router performs functions for (i) allowing other devices to join the network (ii) multi-hop routing (iii) assisting incommunication for its child battery-powered end devices.In general, Routers are expected to be active all the time and thus have to be mains-powered. A special mode of network operation, called “Cluster Tree”, allows Routers to operate on a periodic duty cycle and thus enables them to be battery-powered.2.1.3 End-deviceAn end-device has no specific responsibility for maintaining the network infrastructure, so it can sleep and wake upas it chooses. Thus it can be a battery-powered node.Generally, the memory requirements (especially RAM requirements) are lower for an end-device. Notes:In z-stack v1.4.1, the device type is usually determined at compile-time via compile options (ZDO_ COORDINATORand RTR_NWK). All sample applications are provided with separate project files to build each device type.It is possible to create an image with both Coordinator and Router functionality and choose the device type atruntime. See the SOFT_START compile option for more details.2.2 Stack ProfileThe set of stack parameters that need to be configured to specific values, along with those values, is called a stackprofile. The parameters that comprise of the stack profile are defined by the ZigBee Alliance.All devices in a network must conform to the same stack profile (i.e., all devices must have the stackprofileparameters configured to the same values).The ZigBee Alliance has defined a stack profile for the ZigBee-2006 specification with the goal of promotinginteroperability. All devices that conform to this stack profile will able to work in a network with devices from othervendors that also conform to it.If application developers choose to change the settings for any of these parameters, they can do so with the caveatthat those devices will no longer be able to interoperate with devices from other vendors that choose to follow the ZigBee specified stack profile. Thus, developers of “closed networks” may choo se to change the settings of the stack profile variables. These stack profiles are called “network-specific” stack profile.The stack profile identifier that a device conforms to is present in the beacon transmitted by that device. Thisenables a device to determine the stack profile of a network before joining to it. The“network-specific” stack profile has an ID of 0 while the ZigBee-2006 stack profile has ID of 1. The stack profile is configured by theSTACK_PROFILE_ID parameter in nwk_globals.h file.3. Addressing3.1 Address typesZigBee devices have two types of addresses. A 64-bit IEEE address (also called MAC address or Extended address)and a 16-bit network address (also called logical address or short address).The 64-bit address is a globally unique address and is assigned to the device for its lifetime. It is usually set by themanufacturer or during installation. These addresses are maintained and allocated by the IEEE. More information onhow to acquire a block of these addresses is available at/regauth/oui/index.shtmlThe 16-bit address is assigned to a device when it joins a network and is intended for use while it is on the network.It is only unique within that network. It is used for identifying devices and sending data within the network.3.2 Network address assignmentZigBee uses a distributed addressing scheme for assigning the network addresses. This scheme ensures that allassigned network addresses are unique throughout the whole network. This is necessary so that there is no ambiguity about which device a particular packet should be routed to. Also, the distributed nature of the addressing algorithmensures that a device only has to communicate with its parent device to receive a unique network-wide address.There is no need for network-wide communication for address assignment and this helps in scalability of thenetwork.The addressing scheme requires that some parameters are known ahead of time and are configured in each routerthat joins the network. These are the MAX_DEPTH, MAX_ROUTERS andMAX_CHILDREN parameters. Theseare part of the stack profile and the ZigBee-2006 stack profile has defined values for these parameters(MAX_DEPTH = 5, MAX_CHILDREN = 20,MAX_ROUTERS = 6).The MAX_DEPTH determines the maximum depth of the network. The coordinator is at depth 0 and its child nodesare at depth 1 and their child nodes are at depth 2 and so on. Thus the MAX_DEPTH parameter limits how “long”the network can be physically.The MAX_CHILDREN parameter determines the maximum number of child nodes that a router (or coordinator)node can possess.The MAX_ROUTERS parameter determines the maximum number of router-capable child nodes that a router (orcoordinator) node can possess. This parameter is a subset of the MAX_CHILDRENparameter and the remaining(MAX_CHILDREN – MAX_ROUTERS) address space are for end devices.If developer wishes to change these values, they need to follow following steps:First it must be ensured that the new values for these parameters are legal. Since the total address space is limited toabout 216, there are limits on how large these parameters can be set to. The Cskip.xls file that is distributed in therelease (in the Projects\zstack\Tools folder) can be used to verify this. After entering the values for the parametersinto the spreadsheet, an error message will be given if the values are not legal.After choosing legal values, the developer needs to ensure not to use the standard stack profile and instead set it tonetwork-specific (i.e. change the STACK_PROFILE_ID in “nwk_globals.h” to NETWORK_SPECIFIC). Then the MAX_DEPTH parameter in “nwk_globals.h” may be set to the appropriate value.In addition, the array’s CskipChldrn and CskipRtrs must be set in the nwk_globals.c f ile. These arrays are populatedwith the values for MAX_ CHILDREN and MAX_ ROUTERS value for the firstMAX_DEPTH indices followedby a zero value.3.3 Addressing in z-stackIn order to send data to a device on the ZigBee network, the application generally uses theAF_DataRequest()function. The destination device to which the packet is to be sent of type afAddrType_t (defined in “ZComDef.h”).typedef struct{union{uint16 shortAddr;} addr;afAddrMode_t addrMode;byte endPoint;} afAddrType_t;Note that in addition to the network address, the address mode parameter also needs to be specified. The destinationaddress mode can take one of the following values (AF address modes are defined in “AF.h”)typedef enum{afAddrNotPresent = AddrNotPresent,afAddr16Bit = Addr16Bit,afAddrGroup = AddrGroup,afAddrBroadcast = AddrBroadcast} afAddrMode_t;The address mode parameter is necessary because, in ZigBee, packets can be unicast, multicast or broadcast. Aunicast packet is sent to a single device, a multicast packet is destined to a group of devices and a broadcast packet isgenerally sent to all devices in the network. This is explained in more detail below.3.3.1 UnicastThis is the normal addressing mode and is used to send a packet to a single device whose networkaddress is known.The addrMode is set to Addr16Bit and the destination network address is carried in the packet3.3.2 IndirectThis is when the application is not aware of the final destination of the packet. The mode is set to AddrNotPresent and the destination address is not specified. Instead, the destination is looked up from a“binding table” that resides in the stack of the sending device. This feature is called So urce binding (see later sectionfor details on binding).When the packet is sent down to the stack, the destination address is looked up from the binding table and used. Thepacket is then treated as a regular unicast packet. If more than one destination device is found, a copy of the packetis sent to each of them.In previous versions of ZigBee (ZigBee04), there was an option to store the binding table on the coordinator. In thatcase, the sending device would send the packet to the coordinator which would then redirect the packet to theeventual destination that is found in its binding table. This optional feature is called Coordinator Binding.3.3.3 BroadcastThis address mode is used when the application wants to send a packet to all devices in the network. The addressmode is set to AddrBroadcast and the destination address can be set to one of the following broadcast addresses:NWK_BROADCAST_SHORTADDR_DEVALL (0xFFFF) – the message will be sent to all devices in the network(includes sleeping devices). For sleeping devices, the message is held at its parent until the sleeping device polls forit or the message is timed out (NWK_INDIRECT_MSG_TIMEOUT inf8wConfig.cfg).NWK_BROADCAST_SHORTADDR_DEVRXON (0xFFFD) – the message will be sent to all devices that have thereceiver on when idle (RXONWHENIDLE). That is, all devices except sleeping devices. NWK_BROADCAST_SHORTADDR_DEVZCZR (0xFFFC) – the message is sent to all routers( including thecoordinator ).3.3.4 Group AddressingThis address mode is used when the application wants to send a packet to a group of devices. The address mode isset to afAddrGroup and the addr.shortAddr is set to the group identifier.Before using this feature, groups have to be defined in the network [see the aps_AddGroup() in the ZStack APIdoc].Note that groups can also be used in conjunction with indirect addressing. The destination address found in thebinding table can be either a unicast or a group address. Also note that broadcast addressing is simply a special caseof group addressing where the groups are setup ahead of time. Sample code for a device to add itself to a group with identifier 1:aps_Group_t group;// Assign yourself to group 1group.ID = 0x0001;[0] = 0; // This could be a human readable stringaps_AddGroup( SAMPLEAPP_ENDPOINT, &group );3.4 Important Device AddressesAn application may want to know the address of its device and that of its parent. Use the following functions to get this device’s address (defined in ZStack API Doc):• NLME_GetShortAddr() –returns this device’s 16 bit network address.• NLME_GetExtAddr() –returns this device’s 64 bit extended address.Use the following functi ons to get this device’s parent’s addresses (defined in ZSta ck API Doc). Note that the term“Coord” in these functions does not refer to the Zigbee Coordinator, but inst ead to the device’s parent (MAC Coordinator):• NLME_GetCoordShortAddr() – returns this d evice’s parent’s 16 bit short address.• NLME_GetCoordExtAddr() –returns this device’s parent’s 64 bit extended address.4. BindingBinding is a mechanism to control the flow of messages from one application to another application (or multipleapplications). In the Zigbee 2006 release, the binding mechanism is implemented in all devices and is called sourcebinding.Binding allows an application to send a packet without knowing the destination address, the APS layer determinesthe destination address from its binding table, and then forwards the message on to the destination application (ormultiple applications) or group.Notice: This is a change from the Zigbee 1.0 release, which stored all of the binding entries on coordinator. Now,all the binding entries are stored on the device that is sending the data.4.1 Building a Binding TableThere are 3 ways to build a binding table:Zigbee Device Object Bind Request – a commissioning tool can tell the device to make a binding record.• Zigbee Device Object End Device Bind Request – 2 devices can tell the coordinator that they would like tosetup a binding table record. The coordinator will make the match up and create the binding table entries inthe 2 devices.• Device Application – An application on the device can build or manage a binding table.4.1.1 Zigbee Device Object Bind RequestAny device or application can send a ZDO message to another device (over the air) to build a binding record for thatother device in the network. This is called Assisted Binding and it will create a binding entry for the sending device.4.1.1.1 The Commissioning ApplicationAn application can do this by calling ZDP_BindReq() [defined in ZDProfile.h] with 2 applications (addresses andendpoints) and the cluster ID wanted in the binding record. The first parameter (target dstAddr) is the short address of the binding’s source address (where the binding record will be stored). Make sure you have the feature enabled in ZDConfig.h [ZDO_BIND_UNBIND_REQUEST].You can use ZDP_UnbindReq() with the same parameters to remove the binding record.The target device will send back a Zigbee Device Object Bind or Unbind Response message which the ZDO codewill parse and notify ZDApp.c by calling ZDApp_BindRsp() or ZDApp_UnbindRsp() with the status of theaction.For the Bind Response, the status returned from the coordinator will be ZDP_SUCCESS,ZDP_TABLE_FULL orZDP_NOT_SUPPORTED.For the Unbind Response, the status returned from the coordinator will be ZDP_SUCCESS,ZDP_NO_ENTRY orZDP_NOT_SUPPORTED.4.1.1.2 Zigbee Device Object End Device Bind RequestThis mechanism uses a button press or other similar action at the selected devices to bind within a specific timeoutperiod. The End Device Bind Request messages are collected at the coordinator within the timeout period and aresulting Binding Table entry is created based on the agreement of profile ID and cluster ID. The default end devicebinding timeout (APS_DEFAULT_MAXBINDING_TIME) is 16 seconds (defined in nwk_globals.h), but can bechanged if added to f8wConfig.cfg.The sample applications used in the “User’s Guide” are examples of an End Device Bind implementation (pressingSW2 on each device).You’ll notice that all sample applications have a function that handles key events [for example, TransmitApp_HandleKeys() in TransmitApp.c]. This function callsZDApp_SendEndDeviceBindReq() [in ZDApp.c], which gathers all the information for the application’s endpoint and calls ZDP_EndDeviceBindReq() [ZDProfile.c] to send the message to the coordinator. Or, as inSampleLight and SampleSwitch, ZDP_EndDeviceBindReq() is called directly with only the cluster IDsrelevant to the lamp On/Off functions.The coordinator will receive [ZDP_IncomingData() in ZDProfile.c] and parse[ZDO_ProcessEndDeviceBindReq() in ZDObject.c] the message and callZDApp_EndDeviceBindReqCB() [in ZDApp.c], which calls ZDO_MatchEndDeviceBind() [ZDObject.c]to process the request.When the coordinator receives 2 matching End Device Bind Requests, it will start the process of creating sourcebinding entries in the requesting devices. The coordinator follows the following process, assuming matches werefound in the ZDO End Device Bind Requests:1. Send a ZDO Unbind Request to the first device. The End Device Bind is toggle process, so the unbind is sentfirst to remove an existing bind entry.2. Wait for the ZDO Unbind Response, if the response status is ZDP_NO_ENTRY, send a ZDO Bind Request tomake the binding entry in the source device. If the response status is ZDP_SUCCESS, move on to the clusterID for the first device (the unbind removed the entry – toggle).3. Wait for the ZDO Bind Response. When received, move on to the next cluster ID for the first device.4. When the first device is done, do the same process with the second device.5. When the second device is done, send the ZDO End Device Bind Response messages to both the first andsecond device.4.1.1.3 Device Application Binding ManagerAnother way to enter binding entries on the device is for the application to manage the binding tablefor itself.Meaning that the application will enter and remove binding table entries locally by calling the following bindingtable management functions (ref. ZStack API Document – Binding Table Management section):• bindAddEntry() – Add entry to binding table• bindRemoveEntry() – Remove entry from binding table• bindRemoveClusterIdFromList() – Remove a cluster ID from an existing binding table entry• bindAddClusterIdToList() – Add a cluster ID to an existing binding table entry• bindRemoveDev() – Remove all entries with an address reference•bindRemoveSrcDev() – Remove all entries with a referenced source address •bindUpdateAddr () – Update entries to another address•bindFindExisting () – Find a binding table entry•bindIsClusterIDinList() – Check for an existing cluster ID in a table entry•bindNumBoundTo() – Number of entries with the same address (source or destination) •bindNumOfEntries() – Number of table entries•bindCapacity() – Maximum entries allowed•BindWriteNV() – Update table in NV.4.1.2 Configuring Source BindingTo enable source binding in your device include the REFLECTOR compile flag in f8wConfig.cfg. Also inf8wConfig.cfg, look at the 2 binding configuration items (NWK_MAX_BINDING_ENTRIES &MAX_BINDING_CLUSTER_IDS). NWK_MAX_BINDING_ENTRIES is the maximum number of entries in thebinding table and MAX_BINDING_CLUSTER_IDS is the maximum number of cluster IDs in each binding entry.The binding table is maintained in static RAM (not allocated), so the number of entries and the number of clusterIDs for each entry really affect the amount of RAM used. Each binding table entry is 8 bytes plus(MAX_BINDING_CLUSTER_IDS * 2 bytes). Besides the amount of static RAM used by the binding table, thebinding configuration items also affect the number of entries in the address manager.5. Routing5.1 OverviewA mesh network is described as a network in which the routing of messages is performed as a decentralized,cooperative process involving many peer devices routing on each others’ behal f.The routing is completely transparent to the application layer. The application simply sends data destined to anydevice down to the stack which is then responsible for finding a route. This way, the application is unaware of thefact that it is operating in a multihop network.Routing also enables the “self healing” nature of ZigBee networks. If a particular wir eless link is down, the routingfunction will automatically find a new route that avoids that particular broken link. This greatly enhances thereliability of the wireless network and is one of the key features of ZigBee.5.2 Routing protocolThe ZigBee implementation uses a routing protocol that is based on the AODV (Ad hoc On demand DistanceVector) routing protocol for ad hoc networks. Simplified for use in sensor networks, the ZigBee routing protocolfacilitates an environment capable of supporting mobile nodes, link failures and packet losses.When a router receives a unicast packet, from its application or from another device, the NWK layer forwards itaccording to the following procedure. If the destination is one of the neighbors of the router (including its childdevices), the packet will be transmitted directly to the destination device. Otherwise, the router will check its routingtable for an entry corresponding to the routing destination of the packet. If there is an active routing table entry forthe destination address, the packet will be relayed to the next hop address stored in the routing entry. If an activeentry can not be found, a route discovery is initiated and the packet is buffered until that process is completed.ZigBee end-devices do not perform any routing functions. An end-device wishing to send a packet to any devicesimply forwards it to its parent device which will perform the routing on its behalf. Similarly, when any devicewishes to send a packet to an end-device and initiate route discovery, the parent of the end-device responds on itsbehalf.Note that the ZigBee address assignment scheme makes it possible to derive a route to any destination based on itsaddress. In z-stack, this mechanism is used as an automatic fallback in case the regular routing procedure cannot beinitiated (usually, due to lack of routing table space).Also in z-stack, the routing implementation has optimized the routing table storage. In general, a routing table entryis needed for each destination device. But by combining all the entries forend-devices of a particular parent with theentry for that parent device, storage is optimized without loss of any functionality.ZigBee routers, including the coordinator, perform the following routing functions (i) route discovery and selection(ii) route maintenance (iii) route expiry.5.2.1 Route Discovery and SelectionRoute discovery is the procedure whereby network devices cooperate to find and establish routes through thenetwork. A route discovery can be initiated by any router device and is always performed in regard to a particulardestination device. The route discovery mechanism searches all possible routes between the source and destinationdevices and tries to select the best possible route.Route selection is performed by choosing the route with the least possible cost. Each node constantly keeps track of"link costs" to all of its neighbors. The link cost is typically a function of the strength of the received signal. By adding up the link costs for all the links along a route, a “route cost” is derived for the whole route. The routing algorithm tries to choose the route with the least “route cost”.Routes are discovered by using request/response packets. A source device requests a route for a destination addressby broadcasting a Route Request (RREQ) packet to its neighbors. When a node receives an RREQ packet it in turn. rebroadcasts the RREQ packet. But before doing that, it updates the cost field in the RREQ packet by adding thelink cost for the latest link. This way, the RREQ packet carries the sum of the link costs along all the links that ittraverses. This process repeats until the RREQ reaches the destination device. Many copies of the RREQ will reachthe destination device traveling via different possible routes. Each of these RREQ packets will contain the total routecost along the route that it traveled. The destination device selects the best RREQ packet and sends back a RouteReply (RREP) back to the source.The RREP is unicast along the reverse routes of the intermediate nodes until it reaches the original requesting node.As the RREP packet travels back to the source, the intermediate nodes update their routing tables to indicate theroute to the destination.Once a route is created, data packets can be sent. When a node loses connectivity to its next hop (it doesn’t receive a MAC ACK when sending data packets), the node invalidates its route by sending an RERR to all nodes thatpotentially received its RREP. Upon receiving a RREQ, RREP or RERR, the nodes update their routing tables.5.2.2 Route maintenanceMesh networks provide route maintenance and self healing. Intermediate nodes keep track of transmission failuresalong a link. If a link is determined as bad, the upstream node will initiate route repair for all routes that use thatlink. This is done by initiating a rediscovery of the route the next time a data packet arrives for that route. If theroute rediscovery cannot be initiated, or it fails for some reason, a route error (RERR) packet is sent back to sourceof the data packet, which is then responsible for initiating the new route discovery. Either way the route getsreestablished automatically.5.2.3 Route expiryThe routing table maintains entries for established routes. If no data packets are sent along a route for a period oftime, the route will be marked as expired. Expired routes are not deleted until space is needed. Thus routes are notdeleted until it is absolutely necessary. The automatic route expiry time can be configured in "f8wconfig.cfg". SetROUTE_EXPIRY_TIME to expiry time in seconds. Set to 0 in order to turn off route expiry feature.5.3 Table storageThe routing functions require the routers to maintain some tables.5.3.1 Routing tableEach ZigBee router, including the ZigBee coordinator, contains a routing table in which the device storesinformation required to participate in the routing of packets. Each routing table entry contains the destinationaddress, the next hop node, and the link status. All packets sent to the destination address are routed through the nexthop node. Also entries in the routing table can expire in order to reclaim table space from entries that are no longerin use.Routing table capacity indicates that a device routing table has a free routing table entry or it already has a routingtable entry corresponding to the destination address. The routing table size is configured in "f8wconfig.cfg". SetMAX_RTG_ENTRIES to the number of entries in the (set to at least 4). See the section on Route Maintenance forroute expiration details.5.3.2 Route discovery tableRouter devices involved in route discovery, maintain a route discovery table. This table is used to store temporaryinformation while a route discovery is in progress. These entries only last for the duration of the route discoveryoperation. Once an entry expires it can be used for another route discovery operation. Thus this value determines themaximum number of route discoveries that can be simultaneously performed in the network. This value isconfigured by setting theMAX_RREQ_ENTRIES in "f8wconfig.cfg".5.4 Routing Settings Quick Reference6. Portable DevicesEnd devices, in Zigbee 2006, are automatically portable. Meaning that when an end device detects that its parent isn’t responding (out of range or incapacitated) it will try to rejoin the network (j oining a new parent). There areno setup or compile flags to setup this option.The end device detects that a parent isn’t responding either through polling (MAC data requests) failures and/orthrough data message failures. The sensitivity to the failures (amount of consecutive errors) is controlled by MAX_POLL_FAILURE_RETRIES, which is changeable in f8wConfig.cfg (the higher the number – the lesssensitive and the longer it will take to rejoin).When the network layer detects that its parent isn’t responding, it will callZDO_SyncIndicationCB(), which will initiate a “rejoin”. The rejoin process will firstorphan-scan for an existing parent, then scan for a potentialparent and rejoin (network rejoin command) the network with the potential parent.In a secure network, it is assumed that the device already has a key and a new key isn’t issued to the device.。
ZStack介绍 (1)
03
五分钟在线无缝升级
可持续更新的私有云产品
新功能 新技术 新体验 • • • 一键升级,无需任何配置,升级过程简单 无缝升级,跨版本直接升级,一步到最新 在线升级,无需停止云主机,业务不中断
管理节点升级中
云主机网络连通性测试
版权所有@2017 上海云轴信息科技有限公司 保留一切权利
没机器、资源不够用! 要等两天给你装! 资源不够,搞不了!
企业上云的心路历程
要不要上云?
乱
xxxStack、xxxCloud、xxxSphere、xxx云 90% 基于OpenStack、Docker 创业企业、ISV、IT大企业、运营商
下周要搞大促活动!
怎么又要采购新设备? 咱们的方案能不能打包产品输出?
数十家全球500强企业私有云 架构oudStack核心架构师、微软中国Azure核心架构师、阿里云核心架构师、 OpenStack网络诊断模块负责人…
版权所有@2017 上海云轴信息科技有限公司 保留一切权利
01
拥有多项资质认证和荣誉
ZStack
一键部署
无缝升级 整体功能一次性授权 单管理节点1~10,000 可以利旧 核心开源 支持 支持
Openstack
安装复杂 无法升级 不可控 通常10~500 通常厂商绑定硬件出货 社区开源、厂商闭源 原生不支持 支持 不支持 支持
VMware
安装容易,但分产品安装 升级复杂,多组件分步骤升级 授权分组件,价格昂贵 通常规模较小 可以利旧 闭源 不支持 不支持 支持 不支持
传统基础架构
• 资源利用率低,项目之间无法复用 • 烟囱架构,横向扩展困难 • 缺乏统一的管理,效费比低,无法衡量
ZigBee2006入门_3
ZigBee入门之第二章Z-Stack 简介指导Z-Stack 指导 1首先来看看 Z-Stack 的结构。
第一次打开工程印象最深刻的就是左边一排文件夹,如图所示。
其实这个还是很容易理解的: APP(Application Programming):应用层目录,这是用户创建各种不同工程的区域,在这个目录中包含了应用层的内容和这个项目的主要内容,在协议栈里面一般是以操作系统的任务实现的。
HAL(Hardware (H/W) Abstraction Layer):硬件层目录,包含有与硬件相关的配置和驱动及操作函数。
MAC:MAC 层目录,包含了 MAC 层的参数配置文件及其 MAC 的 LIB 库的函数接口文件。
MT(Monitor Test):实现通过串口可控各层,于各层进行直接交互。
(这个很重要哦)NWK(ZigBee Network Layer):网络层目录,含网络层配置参数文件及网络层库的函数接口文件,APS 层库的函数接口OSAL(Operating System (OS) Abstraction Layer):协议栈的操作系统。
Profile:AF(Application work)层目录,包含 AF 层处理函数文件。
Security:安全层目录,安全层处理函数,比如加密函数等。
Services:地址处理函数目录,包括着地址模式的定义及地址处理函数。
Tools:工程配置目录,包括空间划分及 ZStack 相关配置信息。
ZDO(ZigBee Device Objects):ZDO 目录。
ZMac: MAC 层目录,包括 MAC 层参数配置及 MAC 层 LIB 库函数回调处理函数。
ZMain:主函数目录,包括入口函数及硬件配置文件。
Output:输出文件目录,这个 EW8051 IDE 自动生成的。
那么知道各个文件夹大概是什么功能,分布在 ZIGBEE 的哪一层,那么在以后的工作中无论是查询某些功能函数还是修改某些功能函数,甚至是添加或删除某些功能函数就能顺利的找到在什么地方了,当然要想真的顺利还需要花更多的时间熟悉这个协议栈了!了解Z-Stack 结构后那么就能看看它的功能。
ZStack V2.6.0 SPICE协议 使用指南说明书
图 3: zstaak-cli设置QXL显卡设置
• 使用UI设置QXL显卡 在ZStack系统菜单栏点击设置 > 全局设置按钮,然后在全局设置界面,更改显卡类型为qxl ,点击确定按钮保存。如图 4: 使用UI设置QXL显卡所示:
图 4: 使用UI设置QXL显卡
Spice协议 使用指南
产品版本:ZStack 2.6.0 文档版本:V2.6.0
Spice协议 使用指南 / 版权声明
版权声明
版权所有©上海云轴信息科技有限公司 2018。保留一切权利。 非经本公司书面许可,任何单位和个人不得擅自摘抄、复制本文档内容的部分或全部,并不得以任 何形式传播。 商标说明 ZStack商标和其他云轴商标均为上海云轴信息科技有限公司的商标。 本文档提及的其他所有商标或注册商标,由各自的所有人拥有。 注意 您购买的产品、服务或特性等应受上海云轴公司商业合同和条款的约束,本文档中描述的全部或部 分产品、服务或特性可能不在您的购买或使用范围之内。除非合同另有约定,上海云轴公司对本文 档内容不做任何明示或暗示的声明或保证。 由于产品版本升级或其他原因,本文档内容会不定期进行更新。除非另有约定,本文档仅作为使用 指导,本文档中的所有陈述、信息和建议不构成任何明示或暗示的担保。
2. 设置QXL显卡 ZStack云主机支持三种显卡类型:cirrus,vga,QXL,在使用Spice协议时推荐使用QXL显 卡,能够让Windows虚拟机图形页面更加流畅。以下是修改QXL的两种方法: • 使用zstack-cli设置QXL显卡模式:
[root@localhost ~]# zstack-cli UpdateGlobalConfig category=vm name=videoType value=qxl
Zstack OSAL详解
Zstack OSAL详解2010-08-16 13:33Zstack OSAL详解1. void osal_start_system( void )λ所有应用程序,无论是自己写的最简单的测试程序还是复杂的OSAL操作系统,都必须从main( )来入口。
所谓的OS操作系统,我们不妨这样想像:自己写一个最简单的main( ),里面就一句打印“Hello, World”.如果需要加入Key, LED这样的输入输出功能,那么就需要扩充main( ),加入Key, LED的驱动,如果要实现多线程调度,就要加入Timer驱动等等。
其实操作系统就是这么来的,简单吧:)。
一般在OS中都会有个死循环,在这个循环中去处理各种各样的事件。
在Zstack OSAL中,这个死循环就存在于osal_start_system()这个函数中。
下面来详细分析在这个死循环中到底在做哪些事情。
2. OSAL的“心跳”λ在OSAL的死循环中,各个事件只是在某些特定的情况下发生,如果OSAL一刻不停去轮询去处理这些应用程序,迟早会累死(热量,功耗,寿命…),这样做是完全没有必要的。
所以这里就引入了心跳的概念,也就是OS的时钟节奏。
在Zstack OSAL中这个节奏定义为1ms, 由8 bits HW_TIMER4来控制,当然这些都可以由程序员来修改,后面就以系统的默认值来讲述。
在void InitBoard( byte level )这个函数中有下面这段代码就是在定义系统的心跳Timer。
HalTimerConfig (OSAL_TIMER,HAL_TIMER_MODE_CTC, HAL_TIMER_CHANNEL_SINGLE,HAL_TIMER_CH_MODE_OUTPUT_COMPARE,OnboardTimerIntEnable,Onboard_TimerCallBack);在OSAL的Timer定义好了以后,就要启动Timer, 至于如何启动Timer, 请自行查阅2430 Spec, 我这里想说的是,在一步步跟踪源码到死循环开始,都没有发现启动OSAL Timer的代码,最后通过观察Timer相关的控制寄存器,发现,在网络层初始化函数nwk_init( taskID++ )执行完毕后Timer启动了,也就是说在网络层初始化函数中有启动Timer 的语句,因为网络层初始化是不开源的,无从去看源代码验证,总之,Timer启动了就好。
手把手教你在CC2430---Z-StacK 中建立自己的任务
#if defined (HAL_KEY_SW_6_ENABLE) if (!(HAL_KEY_SW_6_PORT & HAL_KEY_SW_6_BIT)) /* Key is active low */ { keys |= HAL_KEY_SW_6; } #endif #if defined (HAL_KEY_SW_5_ENABLE) if (HAL_KEY_SW_5_PORT & HAL_KEY_SW_5_BIT) /* Key is active high */ { keys |= HAL_KEY_SW_5; } #endif ………….. 调用 HalAdcRead()得出操纵杆的值,是通过 AD 进来了模拟电压值 得出; /* Invoke Callback if new keys were depressed */ if (keys && (pHalKeyProcessFunction)) { (pHalKeyProcessFunction) (keys, HAL_KEY_STATE_NORMAL); //回调函数 } } 该 函 数 读 出 按 键 值 keys, 并 执 行 了 回 调 函 数 (pHalKeyProcessFunction) (keys, HAL_KEY_STATE_NORMAL); pHalKeyProcessFunction 是 在 void HalKeyConfig (bool interruptEnable, halKeyCBack_t cback) 里 面 pHalKeyProcessFunction = cback;进行赋函数指针的,这样我们就进入回调函 数了 (7)我们来看一下回调函数: void OnBoard_KeyCallback ( uint8 keys, uint8 state ) //回调函数 { uint8 shift; // shift key (S1) is used to generate key interrupt // applications should not use S1 when key interrupt is enabled shift = (OnboardKeyIntEnable == HAL_KEYБайду номын сангаасINTERRUPT_ENABLE) ? false : ((keys & HAL_KEY_SW_6) ? true : false); if ( OnBoard_SendKeys( keys, shift ) != ZSuccess )//ZFailure,如果不成 功则执行下面 { // Process SW1 here if ( keys & HAL_KEY_SW_1 ) // Switch 1 { } ………………… } } 回调函数里面又调用了 OnBoard_SendKeys( keys, shift )。
zstack完整资料
\ZigBee\南京\cc2530模块资料(天线杆版本)\cc2530模块资料(天线杆版本)\相关的学习文档\Zstack OSAL详解.pdf\ZigBee\南京\cc2530模块资料(天线杆版本)\cc2530模块资料(天线杆版本)\相关的学习文档\zigbee技术实践教程.pdf\ZigBee\z-stack\Z-Stack_API.pdf配置cc2530的第2功能时,不需要配置方向寄存器,否则可能出错hal_key.c下的HalKeyConfig()函数中/* Rising/Falling edge configuratinn */HAL_KEY_JOY_MOVE_ICTL &= ~(HAL_KEY_JOY_MOVE_EDGEBIT); /* Clear the edge bit */ /* For falling edge, the bit must be set. */#if (HAL_KEY_JOY_MOVE_EDGE == HAL_KEY_FALLING_EDGE)HAL_KEY_JOY_MOVE_ICTL |= HAL_KEY_JOY_MOVE_EDGEBIT;#endif有错,应将HAL_KEY_JOY_MOVE_ICTL改为PICTL1ZigBee协议架构1.1ZigBee简介Zigbee是IEEE 802.15.4协议的代名词。
根据这个协议规定的技术是一种短距离、低功耗的无线通信技术。
这一名称来源于蜜蜂的八字舞,由于蜜蜂(bee)是靠飞翔和“嗡嗡”(zig)地抖动翅膀的“舞蹈”来与同伴传递花粉所在方位信息,也就是说蜜蜂依靠这样的方式构成了群体中的通信网络。
其特点是近距离、低复杂度、自组织、低功耗、低数据速率、低成本。
主要适合用于自动控制和远程控制领域,可以嵌入各种设备。
Zigbee是一种新兴的短距离、低速率、低功耗无线网络技术,它是一种介于无线标记技术和蓝牙之间的技术提案。
ZStack OSAL中文说明
1.概述OSAL (Operating System Abstraction Layer),翻译为“操作系统抽象层”。
在基于ZigBee协议的应用开发中,应用程序框架中包含了最多240个应用程序对象。
如果我们把一个应用程序对象看做为一个任务的话,那么应用程序框架将包含一个支持多任务的资源分配机制。
于是OSAL便有了存在的必要性,它正是Z-Stack为了实现这样一个机制而存在的。
OSAL就是以实现多任务为核心的系统资源管理机制。
所以OSAL与标准的操作系统还是有很大的区别的。
简单而言,OSAL实现了类似操作系统的某些功能,但并不能称之为真正意义上的操作系统。
2.OSAL的API接口函数名称功能描述void osal_nv_init() 初始化FLASH存储器uint8 osal_init_system() 初始化操作系统void osal_mem_init() 初始化内存分配系统void osalTimerInit() 初始化定时器void osalInitTasks() 初始化系统任务void osal_start_system() 进入操作系统void osal_run_system() 运行操作系统void osalTimeUpdate() 操作系统时间更新void Hal_ProcessPoll() 硬件层检查2.1 消息管理功能(1)uint8 * osal_msg_allocate( uint16 len ):申请一个指定长度的消息缓存区,该函数调用void *osal_mem_alloc( uint16 size )函数实现,从堆中申请存储空间。
(2)uint8 osal_msg_deallocate( uint8 *msg_ptr ):接收到消息的任务处理完成后释放消息的缓存空间。
(3)uint8 osal_msg_send( uint8 destination_task, uint8 *msg_ptr ):发送消息到指定任务,将消息放入队列,并把任务的相应事件标志置位。
ZStack开发流程
系统初始化
执行操作系统
Main()函数所在的位置:
ZSEG int main( void ) {
osal_int_disable( INTS_ALL );
// 关闭所有中断
HAL_BOARD_INIT();
// 初始化系统时钟
zmain_vdd_check();
// 检查芯片电压是否正常
zmain_ram_init();
//提取需要处理的任务中的事件
tasksEvents[idx] = 0;
// 清除本次任务的事件
HAL_EXIT_CRITICAL_SECTION(intState); //退出临界区
events = (tasksArr[idx])( idx, events ); //通过指针调用任务处理函数
HAL_ENTER_CRITICAL_SECTION(intState); //进入临界区
//任务优先级由高向低依次排列,高优先级对应 taskID 的值反而小
macTaskInit( taskID++ ); //macTaskInit(0),用户不需考虑
nwk_init( taskID++ );
//nwk_init(1),用户不需考虑
Hal_Init( taskID++ );
//Hal_Init(2),用户需考虑
4)为设备的安全性提供支持; 5)信道接入方式采用免冲突载波检测多址接入(CSMA-CA )机制; 6)处理和维护保护时隙( GTS )机制; 7)在两个对等的 MAC 实体之间提供一个可靠的通信链路。
网络层(NWK)
ZigBee 协议栈的核心部分在网络层。网络层主要实现节点加入或离开网络、
ZStack全线产品介绍
简单 Simple
弹性 Scalable
健壮 Strong
智能 Smart
让每一家企业都拥有自己的云
版权所有@ 2020 本人保留一切权利
1
公司概述
目录
Content
2Байду номын сангаас
产品介绍
3
行业案例
版权所有@ 2020 本人保留一切权利
01 关于ZStack(云轴科技)
标准化服务目录 屏蔽底层不同资源平台的差异性,以标准化的方 式呈现云主机、云数据库、云存储等资源;
精细化运维管理 对各类型资源进行计量计费,预算设置、成本统 计分析,有效成本控制;
版权所有@ 2020 本人保留一切权利
02 ZStack CMP多云管理平台应用场景
ZStack CMP应用场景
总部
ZStack+ZStack CMP
需求挑战
• 短时间内批量创建500台,并能够在短时间内进行资源回收; • 某国外知名虚拟化厂商创建时间超过3小时; • 某国外知名OpenStack云服务商创建时间1小时40分钟,但存在
12-20台云主机创建失败;
方案与收益
• 采用ZStack本地存储部署方案,管理业务双千兆网络环境; • 利用ZStack高并发API处理能力,创建500台云主机仅耗时2分41秒; • 极大程度提高了公安三所技术人员的运维效率;
ZStack CMP能够提高企业多云IT资源运维效率、优化企业IT运营成本, 从而提升企业IT管理效率,助力企业数字化转型。
统一的资源管理 支持ZStack、ZStack Mini、阿里云以及其他第 三方云平台的接入,统一管理各类云资源;
ZStack云端私有云解决方案技术建议书
ZStack云端私有云解决方案技术建议书技术建议书:ZStack云端私有云解决方案一、背景介绍ZStack作为一家领先的云计算解决方案提供商,致力于为企业提供高效可靠的私有云解决方案。
本建议书旨在提出ZStack云端私有云解决方案的技术建议,为企业的云计算需求提供专业的指导和建议。
二、核心优势- 高度可定制性:ZStack云端私有云解决方案支持灵活的模块化设计,可以根据企业需求进行定制和扩展,确保系统完全适应企业的业务需求。
高度可定制性:ZStack云端私有云解决方案支持灵活的模块化设计,可以根据企业需求进行定制和扩展,确保系统完全适应企业的业务需求。
- 安全可靠性:ZStack云端私有云解决方案采用最新的安全技术和措施,保证数据的安全性和可靠性,确保企业数据不受侵犯和丢失。
安全可靠性:ZStack云端私有云解决方案采用最新的安全技术和措施,保证数据的安全性和可靠性,确保企业数据不受侵犯和丢失。
- 高性能和可伸缩性:ZStack云端私有云解决方案利用先进的虚拟化技术和分布式架构,提供高性能和可伸缩性,为企业提供稳定、高效的云计算服务。
高性能和可伸缩性:ZStack云端私有云解决方案利用先进的虚拟化技术和分布式架构,提供高性能和可伸缩性,为企业提供稳定、高效的云计算服务。
三、关键功能特点1. 虚拟化技术支持:ZStack云端私有云解决方案支持主流的虚拟化技术,如KVM、ESXi等,为企业提供可靠的虚拟化环境,实现资源的合理利用和灵活调度。
虚拟化技术支持:ZStack云端私有云解决方案支持主流的虚拟化技术,如KVM、ESXi等,为企业提供可靠的虚拟化环境,实现资源的合理利用和灵活调度。
2. 自动化管理工具:ZStack云端私有云解决方案提供强大的自动化管理工具,可实现对虚拟机、网络、存储等资源的自动化管理和监控,提高管理效率和运维成本的降低。
自动化管理工具:ZStack云端私有云解决方案提供强大的自动化管理工具,可实现对虚拟机、网络、存储等资源的自动化管理和监控,提高管理效率和运维成本的降低。
GameSnacks 开发者指南说明书
GameSnacks Developer Guide(external)For questions, please contact:**************************Last updated: 2/24/2021GameSnacks Game RequirementsCore Gameplay OnlyGameSnacks games should be a continuous experience of core gameplay. The following should be removed from GameSnacks games:●Advertising and sponsorships●Sharing prompts (e.g. "Click to tweet your score.")Snackable GamesGameSnacks games should be●Easy to learn: a wide range of users should be able to learn how to play in less than 30seconds. Games that require some domain knowledge(e.g., a chess tactics game) are acceptable. Include in-game instructions and onboarding where appropriate.●Fast-paced: the user should be able to earn a score within 15 seconds.●Without text: aside from the instructions, the game itself should not rely on text that theuser has to read in order to succeed.○If there is any text, the text should be in English.○When possible, use symbols and visual tutorials instead of text. For example: show a finger making an action instead of using text to describe the action.Using the gamesnacks.js APIWe provide an JavaScript API that games use to check audio status, report scores, and report gameOver events. It's called "gamesnacks.js" Include it with:<scriptsrc="https:///assets/js/gamesnacks.js"></script>This is a small script that allows games to plug in to the GameSnacks API. We recommend including it after your HTML, but before your other javascript.API TesterWe provide an API Tester tool which allows developers to verify if their games are correctly integrating with GameSnacks APIs. It can be used to verify locally-running games. It's located at https:///demo/test.Score APIGameSnacks keeps track of score data for high scores and other features.When the user's score changes, you should use the sendScore function in the API like this:// var score = users current scoreGAMESNACKS.sendScore(score)For games that traditionally don't show scores, e.g.puzzle games, please use this API to send an incrementing score upon the completion of each level. There is no need to show this score in the game UI.GameOver APIGameSnacks also uses "game over" events for competitions,ads and other features. It should be triggered on failure outcomes, e.g. when the user dies or was unable to complete a level. Game Over events should also be triggered when the user restarts, the user exits a level, the user clicks the home button to go back to the main menu, or other similar events that cause the session to end. You should use the gameOver function in the API like this:GAMESNACKS.gameOver()LevelComplete APIFor games with levels, triggered when a level is successfully completed by the user. Pass in a number representing the index of the level in the overall level ordering. Levels should be indexed starting from 1.●Even if your game doesn't have traditional "levels",call this API if your game hasdiscreet ordered success milestones that are natural stopping points. For example: inthis balls game, call levelComplete on every successful user fling.●If your levels are unordered, call this api with a level of 0. E.g. in this fishing game, callGAMESNACKS.levelComplete(0) at the end of every fishing round.●Some games don't have levels which is okay, e.g.this reversi game.Use the levelComplete API like this:// var level = index of level completed by userGAMESNACKS.levelComplete(level)Audio APIGameSnacks games should use this audio API so that GameSnacks can provide consistent volume controls. There are two ways to integrate with the audio API: a getter method and a PubSub method.// Getter method. Returns a boolean of whether audio is enabled. GAMESNACKS.isAudioEnabled()// PubSub method. Accepts a callback function that will be called// with a boolean value of the new value of isAudioEnabled whenever// it changes.GAMESNACKS.subscribeToAudioUpdates(callback);Audio getter methodIf using the getter method, you can call the getter at any time to see if audio is enabled. You should check before each sound effect.if (GAMESNACKS.isAudioEnabled()) {playSoundEffect();}Audio PubSub methodOptionally, instead of checking the getter method before each sound effect, you can check it once at the beginning of the game, and then subscribe to changes. This is suitable for things like background music.if (GAMESNACKS.isAudioEnabled()) {playBackgroundMusic();}GAMESNACKS.subscribeToAudioUpdates((isAudioEnabled)=> {if (isAudioEnabled) {playBackgroundMusic();} else {stopPlayingBackgroundMusic();}});GameReady APIGameSnacks games should call gameReady() as soon as the main menu (*NOT* loading screen) is both displayed and interactive. This may,for instance, be used to hide GameSnacks loading screens or indicators. At this point the game, or at least the first level, should be loaded.GAMESNACKS.gameReady()Rewarded Ads APIsImplement this section if creating rewarded ads games on GameSnacksRewards must not have value outside of your app, they must not have (or be easily exchanged for) monetary value, and must not be saleable or exchangeable for goods and services, and you should not encourage accidental clicks on ads or reward prompts.GAMESNACKS.rewardedAdOpportunitySteps1.When the user reaches a point in the game with reward potential (common examples aremain menu and end-game screen), call rewardedAdOpportunity()to notify GameSnacks.Pass in callbacks to trigger game behavior as it relates to the ad.2.If conditions are met, GameSnacks will call beforeReward(),at which point the gameshould render UI to the user indicating they can watch an ad for a reward. Don't renderrewarded UI before this, as there may not be an ad available.3.If the user clicks into rewarded ad UI, call showAdFn().Always call the most recentshowAdFn. Previous showAdFn callbacks are invalidated on every beforeReward call.4.GameSnacks will call beforeBreak() shortly after,at which point the game should pauseand mute while the ad plays.5.adComplete() or adDismissed() will be called next,depending on whether the userwatched the entire ad. If adComplete() is called,give the user a reward.6.afterBreak() will always be called regardless of if the user watched the ad to completion.Here you should unpause and unmute the game.GAMESNACKS.rewardedAdOpportunity({beforeReward,beforeBreak,adComplete,adDismissed,afterBreak}: {// Show reward UI. Call showAdFn() if clicked.beforeReward: (showAdFn: () =>any) =>any,// Mute and pause the game.beforeBreak: () =>any,// Player watched the ad to completion. Give them the reward.adComplete: () =>any,// Player dismissed the ad before it finished.adDismissed: () =>any,// Unmute and unpause the game.afterBreak: () =>any,});Sandboxed iframe restrictionsGameSnacks games should function in a sandboxed iframe with the following properties. The API Tester will verify this.<iframesandbox="allow-scripts allow-forms allow-same-origin"src="<your-game-url>"></iframe>GameSnacks games should not use web features restricted by the above iframe sandbox parameters, including:●Modals such as window.alert()●Popups●Top-level window navigation●The Pointer Lock APISaving ProgressFor games with level progression, long-term progress,collectables, etc. you should use localStorage to save the state of the game. When the user opens the game for subsequent sessions, it should load any saved progress. It is ok if the game state isn’t exactly the same (e.g. characters don’t have to be in the exact position),but if the user gets to level 6, the game should start the user in level 6 again.Examples●Saving unlocked skins, characters●Saving unlocked levels●Saving collectables●Saving high score (if high score is in the UI)●Saving other in-game achievementsExamples of games that do not require saving progress●https:///embed/games/tower_v2●https:///embed/games/timberguy●https:///embed/games/cakesliceninjaNo external scripts or serversGameSnacks games should not rely on anything (no images,assets, sounds, scripts, etc.) that is outside of the zip file (other than gamesnacks.js).In addition, you may not make calls to any external servers for any purpose. If your game needs an external server, please contact us for next steps.CompatibilityGames should function well in the environments listed below. Adding platform-specific control schemes is encouraged (e.g., ability to use arrow keys on desktop.) Games will be shown in portrait orientation. Landscape support is not required.●Mobile: iOS and Android. Chrome, Firefox, and Safari.●Desktop: Chrome, Firefox, and Safari.Size and EfficiencyGameSnacks games are played in countries with slower internet, so smaller game bundle sizes are important! GameSnacks games should be as lightweight as possible. Please compress all images and minify scripts to reduce bundle size. If possible, defer loading of assets needed for later levels until they are needed.PerformanceGameSnacks games run on a wide variety of devices,and so to maintain a great user experience, we require that they can still play well on lower end devices. Specifically:During gameplay*, 95% of frames must run at 30 fps or faster (i.e. under 33.3 ms/frame) on a Samsung Galaxy J2 equivalent phone.* It is OK if the framerate is lower on menus and loading screensSplash page for the game (added 2/12/2021)Each game should have a game specific splash page that appears while the game is loading. This can be a static screen or include an animated spinning wheel or loading bar. The splashshould include the logo for the game or use the game’s app icon (1:1 ratio). The Splash page goes away automatically when the game has loaded.Side tiles for portrait-only orientation (added 2/12/2021)Games that are locked in portrait are ok as along as they have a tiled background that shows on desktop. The objective is to add an intentional look to the sides of the game rather than black or grey. The tiled background can be used for the loading screen if desired.Side bar tile tips:●File size - Keep file size under 10K or smaller.●Dimensions - The height and width of the tile can vary, as long as the tile repeats and thesize is under 10K.●Graphics - The tile should support the graphics of the game keeping in mind, the morecomplex the design the larger the file may be.●Color - Color the tile with a darker shade found in the game. Also, select a base color forunde the tile for slow-loading pages.●Example from Free Kick with side tile:●AssetsThe following are the minimum set of assets to include when submitting a game to GameSnacks.●Please see the GameSnacks Thumbnail Guide before creating assets. Assets shouldfollow these guidelines.●App icon○Needs to work at all sizes, sometimes as small as60x60. Looking for an iconic representation of the game. Do not include logos in app icons.■[ ]1:1 App icon 512x512●Thumbnails○Includes a logo, character(s), game parts, etc■[ ]4:3 Wide 1,1024x768■[ ]16:9 Wide 2, 1024x576■[ ]2:3 Tall,683x1024●Layers○We ask that you provide the artwork for your “4:3Wide 1, 1024x768” thumbnail size as a composite image AND as separated files with transparent backgrounds.Most thumbs can be separated into 3 layers, although sometimes a 4th layer isneeded. The logo should be included in one of the layers.■[ ]Foreground objects on transparent■[ ]Logo on it’s own layer on transparent■[ ]Midground objects on transparent■[ ]Background flat with a solid fill●An example of all delivered asset files:○gamename-app-icon.png○gamename-thumb-wide1.png○gamename-thumb-wide2.png○gamename-thumb-tall.png○gamename-layer-fore.png○gamename-layer-logo.png○gamename-layer-mid.png○gamename-layer-bg.pngFile StructureWhen submitting a game to GameSnacks, the root directory should contain the following:●index.html: the root html document that loads the game.●Game assetsFile DeliveryFirst, convert the game directory into a ZIP file.Submit the ZIP file via email to**************************and********************。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Z-STACK开发者指南宇宸工作室翻译能力有限,翻译难免有错误请及时联系我们QQ:6247587732014.08.291引言1.1目的本文档介绍了一些德州仪器ZigBee协议栈及其功能的组件。
它说明了在ZigBee协议栈的配置参数,以及它们如何可能由应用程序开发人员改变,以适应应用的要求。
1.2适用范围本文档介绍了德州仪器的Z-Stack™发布的概念和设置。
这是一个ZigBee-2007协议栈兼容的ZigBee和ZigBee PRO协议栈的配置文件。
1.3缩略语AF应用框架AES高级加密标准AIB APS信息库API应用程序接口APS应用支持子层APSDE应用支持子层日期实体APSME应用支持子层管理实体ASDU应用支持子层服务数据单元CCM*增强型反CBC-MAC运行模式(Enhanced counter with CBC-MAC mode of operation)EPID扩展的PAN IDMSG消息NHLE下一个更高层实体NIB网络信息基础NWK网络PAN私有网络SE智能能源ZDO ZigBee设备对象1.4参考文献1]ZigBee规范,R17,ZigBee联盟的文档数量053474r17ZB。
[2]的Z-Stack的API(SWRA195)2.ZigBeeZigBee网络是一种由电池供电的多跳网络设备。
这意味着要在ZigBee网络交换数据的两个设备可能必须依赖于其他中间设备,以便能够成功地这样做。
因为网络的这种协同性,正常运行要求每个设备(ⅰ)执行特定的网络功能以及(ii)配置确定的参数的特定值。
所述一组联网功能的装置进行确定的装置的作用在网络中,被称为设备类型。
该组需要被配置为特定的值,随着那些值的参数,被称为栈信息。
2.1设备类型有一个ZigBee网络中三个逻辑设备类型-(一)协调器(II)路由器及(iii)终端设备。
一个ZigBee网络由一个协调器节点和多个路由器和终端设备节点。
请注意,设备类型不以任何方式限制可能运行的特定设备上的应用类型。
例如上方网络图所示,与ZigBee协调器(黑),路由器(红色)和终端设备(白色)。
2.1.1协调器这是一个“启动”ZigBee网络的设备。
它是在网络上的第一装置。
协调器节点将扫描在现有网络中的RF环境,选择一个信道和网络标识符(也称为PAN ID),然后启动网络。
协调器节点也可以有选择的在网络中协助建立安全和应用程序级的绑定。
需要注意的是,协调器的作用主要涉及启动和配置网络。
一旦完成,协调器就像一个路由器节点(甚至可能会消失)。
由于ZigBee网络的分布式特性,网络的持续操作不依赖于协调器的存在.2.1.2Router路由器执行功能(一)允许其他设备加入网络(二)多跳路由(三)协助其由电池供电的子终端设备通信.一般情况下,如果希望路由器始终有效,则必须由主电源供电.2.1.3End-device一个终端设备没有维护网络基础设施,所以它可以休眠,唤醒,因为它选择的具体责任。
因此,它可以是一个电池供电的节点.通常,对终端设备的存储器的要求(特别是RAM的要求)要低点。
.注意事项:在Z-Stack中,设备类型通常是在通过编译选项(ZDO_COORDINATOR和RTR_NWK)编译时确定的。
所有的示例应用程序提供单独的项目文件来构建每个设备类型。
2.2堆栈配置文件该组堆叠参数需要被配置为特定的值,连同上面的设备类型的值,被称为堆栈配置文件。
组成该堆栈信息的参数是由ZigBee联盟定义的。
在一个网络中的所有设备都必须符合相同的堆栈配置文件(即所有设备必须配置为相同的值的堆栈配置文件参数)。
ZigBee联盟已经定义了ZigBee-2007规范,Zigbee和紫蜂PRO两个不同的协议栈配置文件,旨在促进相互操作。
所有符合本协议栈配置文件的设备将能够在网络中工作,与其他厂商的设备也符合它.如果应用程序开发人员选择来更改这些参数的设置,他们可以与有条件的,就是这些设备将不再能够进行交互操作与选择遵循指定的ZigBee协议栈配置文件来自其他厂商的设备做的。
因此,“关闭网络”的开发者可能会选择改变堆栈分布变量的设置。
这些堆栈配置文件被称为“网络特定的”堆栈配置文件。
符合堆栈配置文件的标识符呈现在设备发送的信号中。
这使得装置能够连接到它之前,确定一个网络堆栈信息。
特定网络配置文件有ID为0,而ZigBee协议栈配置文件有ID为1和一个ZigBee PRO协议栈配置有ID为2。
堆栈配置文件被配置在在nwk_globals STACK_PROFILE_ID参数的.h文件。
通常情况下,1个文件(例如ZigBee PRO协议)的设备连接网络时使用相同的配置文件。
如果1个文件(例如ZigBee PRO协议)的路由器连接使用不同的配置文件(例如ZigBee-2007)的网络,它将加入一个非休眠的终端设备。
1个文件(例如ZigBee PRO协议)的终端设备始终处于一个不同的配置文件的网络终端设备。
3.Addressing3.1地址类型ZigBee设备有两种类型的地址。
一个64位IEEE地址(也称为MAC地址或扩展地址)和一个16位的网络地址(也称为逻辑地址或短地址)。
64位的地址是全局唯一的地址和分配在该装置的生命周期中。
它通常是由制造商或安装期间设置。
这些地址被保存并且由IEEE分配。
可在/regauth/oui/index.shtml.如何获得这些地址块的详细信息。
16位地址是分配给设备的时候加入网络,并打算使用它。
它是唯一在网络内。
用于标识网络中的设备和发送数据。
3.2网络地址分配3.2.1树寻址ZigBee2007使用一个分布式的解决方案来分配网络地址。
这个方案保证了所有分配的网络地址是在整个网络中是唯一的。
这是必要的,这样是没有歧义的设备特定的数据包应该被路由到。
此外,该解决算法的分布式特性确保了设备只与其父设备接收一个唯一的网络范围内的地址进行通信。
没有必要对分配地址的网络范围内的通信,这有助于在网络的可扩展性。
寻址方案要求某些参数是需要提前告知的,并且被配置于每个加入网络的路由器。
这些是MAX_DEPTH,MAX_ROUTERS和MAX_CHILDREN参数。
这些是堆栈信息和ZigBee的2007堆叠配置文件的一部分定义了这些参数的值(MAX_DEPTH=5,MAX_CHILDREN=20,MAX_ROUTERS=6)。
该MAX_DEPTH确定网络的最大深度。
协调器是在深度0和它的子节点是在深度1和他们子节点是在深度2等。
因此,MAX_DEPTH参数限制了“长”的网络可以是物理性地。
该MAX_CHILDREN参数确定的路由器(或协调器)节点可以具有子节点的最大数目。
该MAX_ROUTERS参数确定的路由器(或协调器)节点可具有路由器功能的子节点的最大数目。
此参数是MAX_CHILDREN参数的一个子集,其余(MAX_CHILDREN-MAX_ROUTERS)项是用于连接终端设备。
如果开发者想改变这些值,就需要遵循以下步骤:1、首先,它必须确保这些参数的新值是合法的。
由于总的地址空间被限制为约二的十六次方,这些参数可以被设置为限制的有多大。
2、选择合法的值之后,开发人员需要确保不使用标准的协议栈配置文件,而不是将它设置为网络专用(即改变STACK_PROFILE_ID在“nwk_globals.h”到NETWORK_SPECIFIC),因为值是从所定义的值不同ZigBee配置。
然后在“nwk_globals.h”的MAX_DEPTH参数可以被设置为适当的值。
3、此外,阵列的CskipChldrn和CskipRtrs必须设置在nwk_globals.c文件来。
这些阵列填充的第一个MAX_DEPTH指数后跟一个零值MAX_CHILDREN和MAX_ROUTERS值的值。
3.2.2随机寻址ZigBee PRO采用的是随机(随机)解决方案来分配网络地址。
该解决方案会随机分配给新设备短地址,然后使用设备在网络中的其他部分,以确保没有重复的地址。
当设备连接时,它就会接受到一个来自其父节点产生的随机的地址。
新的网络节点然后产生一个“设备声明”(其中包含了新的短地址和它的扩展地址)发送到网络的其余部分。
如果有其他设备使用相同的短地址,在网络中的一个节点(路由器)将发送一个广播“网络状态-地址冲突”到整个网络,并与冲突的短地址的所有设备将改变其短地址。
当冲突的设备改变他们的地址,他们发出自己的“设备声明”,以检查他们的新地址在网络中的冲突.终端设备不参加“地址冲突”。
他们的父节点替他们检查。
如果“地址冲突”发生在终端设备,其父节点将声明终端设备是“重新加入响应”消息来改变终端设备的短地址和终端设备发出一个“设备声明”,以检查他们的新地址在网络中的冲突状况。
当收到“设备声明”时,关联和绑定表更新为新的短地址,路由表的信息不更新(新路由必须建立)。
如果父节点确定“设备声明”涉及到它的终端设备的一个子节点,但它并不能直接从子节点来了,父节点会认为子节点转移到另一个父节点。
3.3Z-Stack的寻址为了将数据发送到设备的ZigBee网络上,应用程序通常使用AF_DataRequest()函数。
信息包被发送到目标设备的类型是afAddrType_t(在“ZComDef.h”的定义)。
typedef struct{union{uint16shortAddr;ZLongAddr_t extAddr;}addr;afAddrMode_t addrMode;byte endPoint;}afAddrType_t;需要注意的是,除了网络地址,该地址模式参数也需要被指定。
目的地址模式可以采取下列值之一(AF地址模式被定义在“AF.h”)。
typedef enum{afAddrNotPresent=AddrNotPresent,afAddr16Bit=Addr16Bit,afAddr64Bit=Addr64Bit,afAddrGroup=AddrGroup,afAddrBroadcast=AddrBroadcast}afAddrMode_t;地址模式参数是必要的,因为,在ZigBee中,数据包可以单播,组播或广播。
单播数据包被发送到一个单一的设备,组播数据包被发往一组设备和广播数据包通常被发送到网络中的所有设备。
这将在下面更详细地解释。
3.3.1单播这是正常的寻址模式和用于将数据包发送到一个单一的装置,它的网络地址是已知的。
该addrMode设为Addr16Bit和目的网络地址在数据包中携带。
3.3.2间接这是当应用程序不知道数据包的最终目的地。
该模式被设置为AddrNotPresent和未指定的目标地址。
相反,目标是从“绑定表”驻留在发送设备的堆叠抬头。