npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bobaos.pub

v2.0.13

Published

Bobaos SDK powered by js, redis and BeeQueue

Downloads

7

Readme

bobaos.pub

Hello, friend.

This module is an update for bdsd.sock.

Improvements:

  • Using Bee-Queue and Redis as a backend for interprocess communication.
  • Clean code, there is no more mess in index.js anymore.
  • Removed unnecessary methods in protocol. No more "read value"/"read values". Now it depends on payload type. For multiple get/set/read methods payload should be array of items.
  • Support for get/set server item, parameter byte methods.

Architecture

Bobaos.Pub uses redis and bee-queue to accepts requests.

  1. It creates queue with name defined config.json/ipc.request_channel, by default it is bobaos_req.
  2. It creates queue with name defined config.json/ipc.service_channel, by default it is bobaos_service.
  3. It broadcasts events like datapoint value, server item, sdk status over channel defined in config.json, by default it is bobaos_bcast.

Request queue serves common requests like get datapoint value, etc. Service queue serves requests ping/get sdk state/reset, so, if program stuck at datapoint method, it will be possible to reset sdk.

In addition to queues, bobaos.pub listen redis pubsub channels with same names(bobaos_req/bobaos_service) for incoming request in stringified json. This feature is supported from version [email protected].

Installation

  1. Install redis, enable and start service. If needed, apply your settings.
sudo apt install redis-server
sudo systemctl daemon-reload
sudo systemctl start redis.service
  1. Install bobaos.pub package.
sudo npm i -g bobaos.pub --unsafe-perm
  1. Configure serialport, write your device (/dev/ttyS* or /dev/ttyAMA0 for RPi) to /usr/lib/node_modules/bobaos.pub/config.json.

Since version [email protected] config file ~/.config/bobaos/pub.service is used as an overriding config file. So, after first run, you will be able to modify settings from there.

  1. Create service file for systemd /etc/systemd/system/bobaos_pub.service:
[Unit]
Description=PubSub service running on nodejs
After=redis.service

[Service]
User=pi
ExecStart=/usr/bin/env bobaos-pub
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target

Reload systemd daemon, enable and start service.

sudo systemctl daemon-reload
sudo systemctl enable bobaos_pub.service
sudo systemctl start bobaos_pub.service
  1. Test it with bobaos.tool
$ sudo npm i -g bobaos.tool
$ bobaos-tool
bobaos> ping
ping: true

Protocol

bee-queue

Bee-Queue job is sent to config.ipc.request_channel with data object, consist following fields:

  • method is an API method.
  • payload depends on method. It may be datapoint id, array of ids, value, or null.

Request:

{
  "method": "get parameter byte",
  "payload": [1,2,3,4]
}

Response is processes by queue.on("job succeeded"):

{
  "method": "success",
  "payload": [1,3,5,7]
}

In case of error, method field in response will contain "error" string and payload will describe error.

redis pub/sub channels

Since version 2.0.8 this feature is supported to simplify job adding.

bobaos.pub listens request and service channels and on incoming request it add job to corresponding queue.

Only difference from bee-queue request is that request should contain response_channel field, so request sender will receive response from bobaos on that channel. This channels may be randomly generated, then subscribed, and after request was sent and response came, client may unsubscribe from this channel.

service methods

ping

payload: null

If bobaos.pub service is running, true will be returned as a response payload.

get sdk state

payload: null

Response payload: "ready"/"stopped".

reset

payload: null

get version

payload: null

Get version of bobaos.pub npm package.

baos methods

get description

payload: null/number/array of numbers

Returns descriptions for given object ids. If payload is null, return description for all configured datapoints.

Response payload example:

{
  "valid": "true",
  "id": "1",
  "length": "2",
  "dpt": "dpt9",
  "flag_priority": "low",
  "flag_communication": "true",
  "flag_read": "false",
  "flag_write": "true",
  "false": "false",
  "flag_readOnInit": "false",
  "flag_update": "true",
  "flag_transmit": "true",
  "value": "23.6",
  "raw": "DJw="
}

get value

payload: number/array of numbers

Returns values for given object ids. Sends data to BAOS via UART. When received, value is saved in redis, so can be got also by get stored value method. It is recommended to get values for multiple datapoints at once to reduce UART message count.

Response payload example:

{
  "id":1,
  "value":23.6,
  "raw":"DJw="
}

get stored value

Returns value as get value method, but without data sending by UART. Values is taken from redis database.

poll values

payload: null

Returns values for all configured datapoints. May take a while to accomplish. Response payload is the same as for get values/get stored values.

set value

payload: Object/Array of objects

Request payload object should be one of following: { id: <Number>, value: <Value> }, { id: <Number>, raw: <String> }, where raw is base64 encoded buffer.

If payload is array of objects, it is possible to combine value types, so following payload is valid:

[
  {id: 2, value: true}
  {id: 3, raw: "AA=="}
]

After values are sent to bus, bobaos.pub broadcasts them via pubsub channel bobaos_bcast.

read value

payload: number/array of numbers

get server item

payload: null/number/array of numbers

If payload is null, all server items to be returned in response.

Response payload example:

[
  {
    "id": 1,
    "value": [ 0, 0, 197, 8, 0, 3],
    "raw": "AADFCAAD"
  },
  {
    "id": 2,
    "value": [ 16 ],
    "raw": "EA=="
  },
  {
    "id": 3,
    "value": [ 18 ],
    "raw": "Eg=="
  }
]

set programming mode

payload: 1/0/true/false

get programming mode

payload: null

Response payload: true/false

get parameter byte

payload: number/array of numbers

Response payload example:

[ 0, 1, 2, 5, 7, 3]

broadcasted events

TODO

Client libraries

To write nodejs applications use bobaos.sub client library.

Basic Java library jobaos.

Help needed.

Credits

  • To people working on KNX standard
  • To Weinzierl team for great API
  • To all open source community
  • To jgs for mouse art