0.1.0 • Published 3 years ago

@smtmt2021/wsun-adaptor v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

License: MIT Node.js CI

WSUN Adaptor Interface

It provides an interface to WSUN adaptor, and act as PaC in order to access a remote PAA coordinator.

+-------------------------------------------+
|                 Your Apps                 |
+-------------------------------------------+
|       >>> WSUN Adaptor Interface <<<      |
+-------------------------------------------+
|                          |  UDP  |  PANA  |
|        WSUN Adaptor      | IPv6 / 6LoWPAN |
|                          |  IEEE802.15.4  |
+-------------------------------------------+
                       :
+-------------------------------------------+
|         A smart meter of your home        |
+-------------------------------------------+

Usage

// Let's start!
const adaptor = WsunGetAdaptor('a model name of adaptor, e.g. BP35A1');
// find and connect a remote PAA coordinator
const descriptor = 
  await adaptor.open('/dev/serialport', {id: 'your id', password: 'your password'});
// make a socket to communicate with remote devices
const socket = adaptor.createSocket();
// wait for messages from remote devices
socket.on('message', (msg, rinfo) => {
  console.log(`received ${msg.toString()} from ${rinfo.address}`);
});
await socket.bind(3610);
// send a message to a remote device
await socket.send(Buffer.from('1081...', 'hex'), 3610, descriptor.addr);
// end of communication
await socket.close();
await adaptor.close();

Test

  • npm test
  • open ./coverage/lcov-report/index.html to see the coverage.

Debug

  • Specify following environment variables (e.g. export DEBUG=wsun/adaptor) to display debug information;
File or moduleEnvironment variable
src/wsun-bp35a1.tswsun/adaptor
src/wsun-socket.tswsun/socket
wsun-adaptor-mockwsun/robot
serialporte.g. serialport/stream

Build

  • npm run build

Supported adaptor

Model nameManufacturer
BP35A1ROHM

License