1.2.2 • Published 6 months ago

@nicolaudiegroup/dasnet v1.2.2

Weekly downloads
-
License
AGPL-3.0-or-later
Repository
gitlab
Last release
6 months ago

DASNet

This package allows parsing and serializing DASNet requests/responses, to communicate with devices using the Nicolaudie Remote Protocol.

An implementation of the Nicolaudie Remote Protocol using DASNet is available at @nicolaudiegroup/nicolaudie-remote-protocol

Documentation

SDK references

For more information about DASNet, the Nicolaudie Remote Protocol, or to raise issues, please contact support@nicolaudiegroup.com

Getting started

Installation

First install the package

npm i @nicolaudiegroup/dasnet

Basic usage

The most basic way to use this package is to simply construct the Operation of your choice, and use it to parse a buffer or serialize to a buffer.

For more information about the available Operations, see the compatibility table below.

Serialization

Example:

import { Operations, Device } from '@nicolaudiegroup/dasnet'
import { send } from 'my-library'

// Instanciate
const request = new Operations.ZoneStatusRequest()

// Populate data (RECOMMENDED)
request.data = {
  deviceId: Device.DeviceId.Stick3A,
  zoneId: 2,
}
// OR
request.from({
  deviceId: Device.DeviceId.Stick3A,
  zoneId: 2,
}) // Serializes or parse depending on what's provided

// Serialize and use the serialized buffer
send(request.toBuffer())

The data object to serialize can also be passed directly to the constructor. The constructor of some operations might accept additional options.

An existing buffer can be provided to the toBuffer method, to avoid creating a new one.

Parsing

Example:

import { Operations } from '@nicolaudiegroup/dasnet'

// Instanciate
const response = new Operations.ZoneStatusResponse()

// Parse (RECOMMENDED)
response.read(buffer) // Returns a boolean indicating if the entire operation was read (based only on the buffer length)
// OR
response.fromBuffer(buffer) // Bypasses checks, data might be incomplete
// OR
request.from(buffer) // Serializes or parse depending on what's provided

// Use the parsed data
console.log(JSON.stringify(response.data))

The buffer to parse can also be passed directly to the constructor. The constructor of some operations might accept additional options.

Parsing a buffer containing an unknown operation

Often times, you'll receive a buffer but won't know in advance which Operation it is.

For this reason, there exists a special Operation called UnknownResponse that can be used to parse the header of the buffer, and thus determine which operation to use.

The simplest way to use UnknownResponse is using the static method infer, which automatically tries to read the provided buffer, and instantiate the correct Operation.

Example:

import { Operations } from '@nicolaudiegroup/dasnet'

// Try reading the response
const response = Operations.UnknownResponse.infer(buffer)

// If the infer method returns undefined, the buffer is not long enough to contain the required headers
if (!response) {

  throw new Error('Buffer is too short, unable to read operation headers')

}

// If the response is an instance of UnknownResponse and not a specific operation, it means it couldn't recognize the opCode
if (response instanceof UnknownResponse) {

  throw new Error(`Unsupported operation: ${response.opCode}`)

}

// After those checks, you can safely use the response and it's parsed data
console.log(JSON.stringify(response.data))

Other useful namespaces

import {
  Device, // Device related constants & utilities
  Op, // OpCodes constants & utilities
  Status, // Show/scene status constants & utilities
  Trigger, // Scene triggering constants & utilities
  Utils, // Miscellaneous utilities
} from '@nicolaudiegroup/dasnet'

Advanced usage & concepts

For more informations, check ADVANCED.md

Compatibility table

  • ✅ supported
  • 🧪 supported but untested
  • ⚠️ partial support or supported with caveats
  • 🚧 planned support
  • ❌ unsupported
  • – not compatible
OpCodeOperation nameDina 1ADina 2ASiudi 11ASiudi 11BSiudi 11DStick 3AStick 5ASiudi 10Stick KU1Stick KE1Notes
Firmware v3.0 and upFirmware v3.0 and upFirmware v2.0 and upEthernet variant only
0x0000PollRequest🧪🧪🧪🧪-
0x00c9PollResponse🧪🧪🧪🧪-Form factor only available since firmware DINA/SIUDI11 >= 3.00 / SIUDI10A >= 1.00 / STICK5A >= 1.00
0x001fReadFileRequest🧪🧪---
0x0020ReadFileResponse🧪🧪---
0x0025ZoneStatusRequest---🧪🧪-
0x0025ZoneStatusResponse---🧪🧪-
0x0023UiStatusResponse (Stick3)---⚠️---Datagram depends on device. Only supported as placeholder, data is not readable. Firmware v3.01 and up supported only
0x0023UiStatusResponse (Stick 5)----⚠️--Datagram depends on device. Only supported as placeholder, data is not readable.
0x0023UiStatusResponse (Dina)⚠️------Datagram depends on device. Only supported as placeholder, data is not readable.
0x0009MasterVersionRequest🚧🚧🚧🚧🚧🚧-
0x0009MasterVersionResponse🚧🚧🚧🚧🚧🚧-
0x0047GetSaltRequest🧪🧪🧪🧪-
0x0047GetSaltResponse🧪🧪🧪🧪-
0x0048AuthenticateRequest🧪🧪🧪🧪-
0x0048AuthenticateResponse🧪🧪🧪🧪-
0x0065ButtonRequest---🚧🚧--
0x0065ButtonResponse---🚧🚧--
0x006dSimplifiedTriggerRequest---🧪🧪-
0x006dSimplifiedTriggerResponse---🧪🧪-
0x010aTriggerRequest🧪🧪----
0x010aTriggerResponse🧪🧪----
0x010bSceneStatusRequest🧪🧪----
0x010bSceneStatusResponse🧪🧪----Blackout state deprecated since firmware v4.0, use ShowStatus instead
0x0128ShowStatusRequest🧪🧪----Since firmware 4.0.0
0x0128ShowStatusResponse🧪🧪----Since firmware 4.0.0
0x0117GetScenesNamesRequest----🚧🚧-Since firmware 1.0.0
0x0117GetScenesNamesResponse----🚧🚧-Since firmware 1.0.0
0x0012KeepAliveRequest🧪🧪-🧪🧪-Not sure about compatibility on Stick3. Should be compatible with Stick5, Siudi10, Dina, Siudi11
0x0012KeepAliveResponse🧪🧪-🧪🧪-Not sure about compatibility on Stick3. Should be compatible with Stick5, Siudi10, Dina, Siudi11
0x0006LegacySceneTrigger------
0x0000LegacyPollRequest------
0x0001LegacyPollResponse------
0x0065LegacyButton------
0x0066LegacyPowerLedStatus------
0x0067LegacySceneLedStatus------
0x0068LegacyZoneLedStatus------
0x0069LegacyModeLedStatus------
0x006aLegacySliderStatus------
0x006bLegacyAllLedsOff------
0x006cLegacyPollLedStatus------
0x006cLegacyPollLedStatusReply------
0x006dLegacySceneStatus------
1.2.2

6 months ago

1.2.2-beta.0

6 months ago

1.2.1

9 months ago

1.2.1-beta.0

9 months ago

1.2.0

9 months ago

1.2.0-beta.14

9 months ago

1.2.0-beta.13

9 months ago

1.2.0-beta.12

9 months ago

1.2.0-beta.11

9 months ago