Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jalallinux/php-cayenne-lpp
About PHP Cayenne LPP encoder and decoder
https://github.com/jalallinux/php-cayenne-lpp
Last synced: 10 days ago
JSON representation
About PHP Cayenne LPP encoder and decoder
- Host: GitHub
- URL: https://github.com/jalallinux/php-cayenne-lpp
- Owner: jalallinux
- License: mit
- Created: 2023-07-02T11:54:17.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-25T04:05:55.000Z (9 months ago)
- Last Synced: 2024-04-04T12:44:00.585Z (9 months ago)
- Language: PHP
- Homepage:
- Size: 87.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# Php [Cayenne](https://docs.mydevices.com/docs/lorawan/cayenne-lpp) Encoder & Decoder
[![Latest Stable Version](https://poser.pugx.org/jalallinux/php-cayenne-lpp/v)](https://packagist.org/packages/jalallinux/php-cayenne-lpp)
[![Latest Version on Packagist](https://img.shields.io/packagist/v/jalallinux/php-cayenne-lpp.svg?style=flat-square)](https://packagist.org/packages/jalallinux/php-cayenne-lpp)
[![Tests](https://github.com/jalallinux/php-cayenne-lpp/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/jalallinux/php-cayenne-lpp/actions/workflows/run-tests.yml)
[![Total Downloads](https://img.shields.io/packagist/dt/jalallinux/php-cayenne-lpp.svg?style=flat-square)](https://packagist.org/packages/jalallinux/php-cayenne-lpp)---
This library can encode and decode data stream for LoraWan and SigFox devices which use Cayenne LPP encoding.## Installation
You can install the package via composer:
```bash
composer require jalallinux/php-cayenne-lpp
```## Usage
### Encoder
```php
$encoder = new Encoder();
$encoder->addAnalogInput(2, 4.2)
->addRelativeHumidity(3, 32.0)
->addTemperature(4, 28.7)
->addBarometricPressure(5, 851.3)
->addAnalogOutput(6, 4.45);$hex = bin2hex($encoder->getBuffer());
/**
* RESULT
* 020201a40368400467011f05732141060301bd
*/
```### Decoder
```php
$decoder = new Decoder(hex2bin('020201a40368400467011f05732141060301bd'));
$data = $decoder->data;
/**
* RESULT
* [
* 0 => [
* "channel" => 2
* "type" => 2
* "typeName" => "analogInput"
* "data" => [
* "value" => 4.2
* ]
* ]
* 1 => [
* "channel" => 3
* "type" => 104
* "typeName" => "humidity"
* "data" => [
* "value" => 32.0
* ]
* ]
* 2 => [
* "channel" => 4
* "type" => 103
* "typeName" => "temperature"
* "data" => [
* "value" => 28.7
* ]
* ]
* 3 => [
* "channel" => 5
* "type" => 115
* "typeName" => "pressure"
* "data" => [
* "value" => 851.3
* ]
* ]
* 4 => [
* "channel" => 6
* "type" => 3
* "typeName" => "analogOutput"
* "data" => [
* "value" => 4.45
* ]
* ]
*/
```## Testing
```bash
composer test
```## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Credits
- [JalalLinuX](https://github.com/jalallinux)
- [All Contributors](../../contributors)## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.