@nicolaudiegroup/dasnet v1.2.2
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
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/dasnetBasic 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
| OpCode | Operation name | Dina 1A | Dina 2A | Siudi 11ASiudi 11BSiudi 11D | Stick 3A | Stick 5A | Siudi 10 | Stick KU1Stick KE1 | Notes |
|---|---|---|---|---|---|---|---|---|---|
| Firmware v3.0 and up | Firmware v3.0 and up | Firmware v2.0 and up | Ethernet variant only | ||||||
| 0x0000 | PollRequest | ✅ | 🧪 | 🧪 | ✅ | 🧪 | 🧪 | - | |
| 0x00c9 | PollResponse | ✅ | 🧪 | 🧪 | ✅ | 🧪 | 🧪 | - | Form factor only available since firmware DINA/SIUDI11 >= 3.00 / SIUDI10A >= 1.00 / STICK5A >= 1.00 |
| 0x001f | ReadFileRequest | ✅ | 🧪 | 🧪 | ✅ | - | - | - | |
| 0x0020 | ReadFileResponse | ✅ | 🧪 | 🧪 | ✅ | - | - | - | |
| 0x0025 | ZoneStatusRequest | - | - | - | ✅ | 🧪 | 🧪 | - | |
| 0x0025 | ZoneStatusResponse | - | - | - | ✅ | 🧪 | 🧪 | - | |
| 0x0023 | UiStatusResponse (Stick3) | - | - | - | ⚠️ | - | - | - | Datagram depends on device. Only supported as placeholder, data is not readable. Firmware v3.01 and up supported only |
| 0x0023 | UiStatusResponse (Stick 5) | - | - | - | - | ⚠️ | - | - | Datagram depends on device. Only supported as placeholder, data is not readable. |
| 0x0023 | UiStatusResponse (Dina) | ⚠️ | - | - | - | - | - | - | Datagram depends on device. Only supported as placeholder, data is not readable. |
| 0x0009 | MasterVersionRequest | 🚧 | 🚧 | 🚧 | 🚧 | 🚧 | 🚧 | - | |
| 0x0009 | MasterVersionResponse | 🚧 | 🚧 | 🚧 | 🚧 | 🚧 | 🚧 | - | |
| 0x0047 | GetSaltRequest | ✅ | 🧪 | 🧪 | ✅ | 🧪 | 🧪 | - | |
| 0x0047 | GetSaltResponse | ✅ | 🧪 | 🧪 | ✅ | 🧪 | 🧪 | - | |
| 0x0048 | AuthenticateRequest | ✅ | 🧪 | 🧪 | ✅ | 🧪 | 🧪 | - | |
| 0x0048 | AuthenticateResponse | ✅ | 🧪 | 🧪 | ✅ | 🧪 | 🧪 | - | |
| 0x0065 | ButtonRequest | - | - | - | 🚧 | 🚧 | - | - | |
| 0x0065 | ButtonResponse | - | - | - | 🚧 | 🚧 | - | - | |
| 0x006d | SimplifiedTriggerRequest | - | - | - | ✅ | 🧪 | 🧪 | - | |
| 0x006d | SimplifiedTriggerResponse | - | - | - | ✅ | 🧪 | 🧪 | - | |
| 0x010a | TriggerRequest | ✅ | 🧪 | 🧪 | - | - | - | - | |
| 0x010a | TriggerResponse | ✅ | 🧪 | 🧪 | - | - | - | - | |
| 0x010b | SceneStatusRequest | ✅ | 🧪 | 🧪 | - | - | - | - | |
| 0x010b | SceneStatusResponse | ✅ | 🧪 | 🧪 | - | - | - | - | Blackout state deprecated since firmware v4.0, use ShowStatus instead |
| 0x0128 | ShowStatusRequest | ✅ | 🧪 | 🧪 | - | - | - | - | Since firmware 4.0.0 |
| 0x0128 | ShowStatusResponse | ✅ | 🧪 | 🧪 | - | - | - | - | Since firmware 4.0.0 |
| 0x0117 | GetScenesNamesRequest | - | - | - | - | 🚧 | 🚧 | - | Since firmware 1.0.0 |
| 0x0117 | GetScenesNamesResponse | - | - | - | - | 🚧 | 🚧 | - | Since firmware 1.0.0 |
| 0x0012 | KeepAliveRequest | ✅ | 🧪 | 🧪 | - | 🧪 | 🧪 | - | Not sure about compatibility on Stick3. Should be compatible with Stick5, Siudi10, Dina, Siudi11 |
| 0x0012 | KeepAliveResponse | ✅ | 🧪 | 🧪 | - | 🧪 | 🧪 | - | Not sure about compatibility on Stick3. Should be compatible with Stick5, Siudi10, Dina, Siudi11 |
| 0x0006 | LegacySceneTrigger | - | - | - | - | - | - | ❌ | |
| 0x0000 | LegacyPollRequest | - | - | - | - | - | - | ❌ | |
| 0x0001 | LegacyPollResponse | - | - | - | - | - | - | ❌ | |
| 0x0065 | LegacyButton | - | - | - | - | - | - | ❌ | |
| 0x0066 | LegacyPowerLedStatus | - | - | - | - | - | - | ❌ | |
| 0x0067 | LegacySceneLedStatus | - | - | - | - | - | - | ❌ | |
| 0x0068 | LegacyZoneLedStatus | - | - | - | - | - | - | ❌ | |
| 0x0069 | LegacyModeLedStatus | - | - | - | - | - | - | ❌ | |
| 0x006a | LegacySliderStatus | - | - | - | - | - | - | ❌ | |
| 0x006b | LegacyAllLedsOff | - | - | - | - | - | - | ❌ | |
| 0x006c | LegacyPollLedStatus | - | - | - | - | - | - | ❌ | |
| 0x006c | LegacyPollLedStatusReply | - | - | - | - | - | - | ❌ | |
| 0x006d | LegacySceneStatus | - | - | - | - | - | - | ❌ |
6 months ago
6 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago