munisense / zigbee
Zigbee帧编码/解码库
v2.4.1
2014-08-12 11:57 UTC
Requires
- php: >=5.4.0
Requires (Dev)
- phpunit/phpunit: 4.1.*
README
PHP库,用于编码和解码ZigBee帧
此库包含映射到各种ZigBee帧的类。这些类可以通过字节数组或使用getter/setter和静态构造函数来构造。
使用库
安装
使用此库的最简单方法是将它作为依赖项添加到项目的 composer.json 文件中。
"require": {
"munisense/zigbee": "~2.4",
}
然后运行 composer update
并将 vendor/autoload.php
包含到您的项目文件中,如果尚未包含。
使用ZigBee库解包ZigBee帧
此库可用于将ZigBee帧(例如编码为base64字符串)解包到对象模型。
$input = base64_decode("AP8AAAA=");
$frame = new Munisense\Zigbee\ZCL\ZCLFrame($input);
echo $frame;
给出
ZCLFrame (length: 5)
|- FrameControl : 0b00000000
| |- FrameType : Profile Wide (0x00)
| |- ManufIdPres : Not Present (0x00)
| |- Direction : Server->Client (0x00)
| `- DefaultResp : Enabled (0x00)
|- TransactionId : 0x8e
|- CommandId : Read Attributes
|- Payload (length: 2)
`- Munisense\Zigbee\ZCL\General\ReadAttributesCommand (count: 1, length: 2)
`- AttributeId: 0x0000
使用ZigBee库打包ZigBee帧
还可以使用对象构建ZigBee帧,并提取实际帧有效载荷以发送到ZigBee网络。
$zcl = ReadAttributesCommand::construct([
AttributeIdentifier::construct(0x02),
AttributeIdentifier::construct(0x0809)
]);
$output = $zcl->getFrame();
运行测试
要运行测试,您需要安装phpunit。不要像使用Composer(和Packagist)的项目要求一样下载库,而是应该有一个库的克隆。确保您已运行 composer install
。
之后,每次您想要运行测试时,只需在根目录中调用 phpunit
即可。
Travis持续集成
修订历史
2.4.0
添加ZDP发现命令
- ExtendedSimpleDescReq和Rsp命令
- UserDescConf和Set命令
添加ZDP网络命令
- MgmtBindReq, MgmtCacheReqCommand
- MmtLqiReq和Rsp命令,带有NeighborDescriptor结构
- MmtRtgReq和Rsp命令,带有RoutingDescriptor结构
2.3.0
进行了一些小的代码组织更改,并添加了更多的ZDP发现功能。
- 将MuniZigbeeException重命名为ZigbeeException
- 删除了Munisense特定的帧
- 添加了节点描述符+命令
- 添加了电源描述符+命令
- 添加了用户描述符+命令
2.2.0
添加了以下ZDP命令
- ActiveEP Req和Rsp
- IEEEAddr Req和Rsp
- NodeDesc Req
- NWKAddr Req和Rsp
- PowerDesc Req
- SimpleDesc Req和Rsp
许可
Copyright 2014 Munisense BV
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://apache.ac.cn/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.