README
Adeunis codecs
TypeScript project for JavaScript/Node.js library of Adeunis codecs.
This document explains how to modify, compile and package the library. For beginners, developments can be done directly on generated JavaScript files (no compilation).
Prerequisites
A Node.js + npm environment is required to start developments:
- Node.js 14.x, JavaScript runtime
- npm, package manager for JavaScript (shipped with Node.js)
A knowledge of TypeScript language is also recommended.
Getting started
Go to project folder and install dependencies:
npm install
Project structure
bin/ library entry point
dist/ compiled .js files and static files
|- lib.public.js library file
src/ project .ts source code
|- core/ core module (singleton services)
|- demo/ basic demo pages that use lib.public.js
|- products/ products folder
| |- drycontacts/ drycontacts module (Dry Contact)
| |- 0x40.parser.spec.ts parser unit tests file for dc 0x40 frame
| |- 0x40.parser.ts parser file for dc 0x40 frame
| +- ... additional frame handlers
| |- pulse/ pulse module
| |- temp/ temp module
| +- ... additional products
|- shared/ shared module
|- decoder.ts decoder entry point
|- encoder.ts encoder entry point
+- cli.ts CLI entry point
lib.public.js
is the generated standalone library file used in demonstration web page.
Main tasks
Task automation is based on NPM scripts.
Tasks | Description |
---|---|
npm start | Build library (see npm run build ) |
npm test | Run unit tests once |
npm run lint | Lint code |
npm run build | Build project as single .js file |
npm run build:lib | Build library as standalone single .js file |
npm run build:cli | Build CLI as CommonJS module |
npm run build:test | Build tests as CommonJS modules |
npm run pack:exe | Package codec library into .exe file (Windows x64) |
npm run pack:linux | Package codec library fo linux (Linux x64) |
npm run docs | Display project documentation |
Annex
Product / Codec type association table
Product | Reference | APP FW version | Min codecs lib | Codec type to select |
---|---|---|---|---|
Analog / Analog PWR | 8180BA, 8181BA, ARF8201AA, ARF8200AA | 1.3.x | 1.3.0 | analog |
Breath | 8377AA, 8377CA | 2.4.x | 1.6.0 | breath |
Comfort | 8275AA, 8275CA | < 2.1.0 | 0.4.2 | comfort |
Comfort2 | 8275AA, 8275CA | >= 2.1.x | 1.4.0 | comfort2 |
Comfort CO2 | 8373AA, 8373CA | 2.2.x | 1.5.0 | comfortCo2 |
Dry Contacts | 8170BA, 8171BA | 1.3.x | 0.4.2 | dc or drycontacts (since lib 1.4.0) |
Dry Contacts 2 | 8170BA, 8171BA | 2.1.x | 1.4.0 | drycontacts2 |
DeltaP | 8283AA, 8283CA | 1.5.x or 2.0.x | 1.0.0 | deltap |
Motion | 8276AA, 8276CA | 1.5.x | 1.0.0 | motion |
Motion 2 | 8276AA, 8276CA | 2.0.x | 1.2.0 | motion |
Pulse / Pulse ATEX | 8230AA, 8230CA, 8230GA, 8230HA | 1.2.x | 0.4.2 | pulse |
Pulse 3 / Pulse 3 ATEX | 8230AA, 8230CA, 8230GA, 8230HA | 2.0.x | 1.1.0 | pulse3 |
Pulse 4 / Pulse 4 ATEX | 8230AA, 8230CA, 8230GA, 8230HA | 2.1.x | 1.4.0 | pulse4 |
Pulse 4 NB-IoT | 8335AA | 2.0.x | 0.4.2 | pulse4nbiot |
Repeater Sigfox | 8168AA | 2.x.x | 0.4.2 | repeater |
Temp / Temp 2S | 8180BA, 8181BA, 8180BA2, 8181BA2 | 1.3.x | 0.4.2 | temp |
Temp 3 / Temp 2S 3 | 8180BA, 8181BA 8180BA2, 8181BA2 | 2.0.x | 1.1.0 | temp3 |
Temp 4 / Temp 2S 4 | 8180BA, 8181BA, 8180BA2, 8181BA2 | 2.1.x | 1.4.0 | temp4 |
Temp 4 / Temp 2S 4 IP68 | 8180BCA, 8181BCA, 8180BCB, 8181BCB | 2.1.x | 1.4.0 | temp4 |
TIC CBE/LINKY MONO | 8250AA | 1.4.x | 1.3.0 | ticCbeLinkyMono |
TIC CBE/LINKY TRI | 8250AA | 1.4.x | 1.3.0 | ticCbeLinkyTri |
TIC PME-PMI | 8250AA | 1.4.x | 1.4.0 | ticPmePmi |
Please note that :
- RTU firmware version has no impact on the codec
type
to select - Bundles use the same
type
than the standard product
codec CLI
More information here.
Source code generation
To get version from package.json, do global npm run build
Quick demo (HTML pages)
Basic demo pages are available in generic\src\demo\ directory
You can also visit the demonstration web page
adeunis codecs in NPM repository
NPM package is available here : https://www.npmjs.com/package/@adeunis/codecs
Example to use it:
Create an empty directory
npm_demo
and go into itInitialize npm project :
npm init
(accept all default choices)Install adeunis codecs :
npm i @adeunis/codecs
Install additional package if necessary :
npm i @types/node
Create a file named
demo.ts
:
const codec = require('@adeunis/codecs');
// All product types are defined in DecoderProducts enum (src/shared/product.enum.ts)
const productType = 'analog';
const payloadValue = '42500110000002100000';
let payloadResult;
console.log(`Decoding ${productType} frame => ${payloadValue}`);
const decoder = new codec.Decoder();
// Configure the decoder for the appropriate device
decoder.setDeviceType(productType);
// Decode the given payload
let parserResult = decoder.decode(payloadValue);
// Incompatible frame and product
if (parserResult.error) {
payloadResult = 'decoding issue';
} else {
// Display result
payloadResult = JSON.stringify(parserResult, null, 2);
}
console.log(payloadResult);
- Compile .ts file :
tsc demo.ts
- Execute demo :
node demo.js