power-lan / cayenne-lpp
PHP Cayenne LPP encoder and decoder
v1.2.0
2020-06-10 10:26 UTC
Requires
- php: ^7.0
Requires (Dev)
- phpunit/phpunit: ^6.5
- squizlabs/php_codesniffer: ^3.5
This package is auto-updated.
Last update: 2024-12-10 20:11:04 UTC
README
This library can encode and decode data stream for LoraWan and SigFox devices which use Cayenne LPP encoding.
Encoder exemple
$encoder = new CayenneLPP\Encoder;
$encoder->addTemperature(0, 20.0);
$encoder->addTemperature(1, 21.0);
$buffer = $encoder->getBuffer();
$size = $encoder->getSize();
Decoder exemple
The decoder implements the Countable
interface.
It's allow to known how many dataset are in the binary stream.
$decoded = new CayenneLPP\Decoder(hex2bin('00860070013AFFFF' . '0186FFFF0070013A'));
$nbChannels = count($decoded);
The decoder implements Iterator
interface.
Each item are array which contains the data channel index, the data type, and the data decoded.
$decoded = new CayenneLPP\Decoder(hex2bin('00860070013AFFFF' . '0186FFFF0070013A'));
$nbChannels = count($decoded);
foreach ($decoded as $data) {
$channel = $data['channel'];
$type = $data['type'];
$data = $data['data'];
}