inventoresed
Version:
Z-Wave driver written entirely in JavaScript/TypeScript
51 lines (43 loc) • 1.07 kB
text/typescript
import { num2hex } from "@zwave-js/shared/safe";
export enum Protocols {
ZWave = 0,
ZWaveLongRange = 1,
}
export enum ZWaveDataRate {
"9k6" = 0x01,
"40k" = 0x02,
"100k" = 0x03,
}
export enum ProtocolDataRate {
ZWave_9k6 = 0x01,
ZWave_40k = 0x02,
ZWave_100k = 0x03,
LongRange_100k = 0x04,
}
export function protocolDataRateToString(rate: ProtocolDataRate): string {
switch (rate) {
case ProtocolDataRate.ZWave_9k6:
return "Z-Wave, 9.6 kbit/s";
case ProtocolDataRate.ZWave_40k:
return "Z-Wave, 40 kbit/s";
case ProtocolDataRate.ZWave_100k:
return "Z-Wave, 100 kbit/s";
case ProtocolDataRate.LongRange_100k:
return "Z-Wave Long Range, 100 kbit/s";
}
return `Unknown (${num2hex(rate)})`;
}
// Same as ProtocolDataRate, but with the ability to NOT specify a data rate
export enum RouteProtocolDataRate {
Unspecified = 0x00,
ZWave_9k6 = 0x01,
ZWave_40k = 0x02,
ZWave_100k = 0x03,
LongRange_100k = 0x04,
}
export const protocolDataRateMask = 0b111;
export enum ProtocolType {
"Z-Wave" = 0,
"Z-Wave AV" = 1,
"Z-Wave for IP" = 2,
}