Skip to content

Commit

Permalink
fix: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone committed Jan 19, 2024
1 parent 1e09888 commit 098b8d1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 17 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/capabilities/NodeInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ export function encodeNodeProtocolInfo(
info: NodeProtocolInfo,
isLongRange: boolean = false,
): Buffer {
// Technically a lot of these fields are reserved in Z-Wave Long Range, but the
// only thing where it really matters is the speed bitmask
// Technically a lot of these fields are reserved/unused in Z-Wave Long Range,
// but the only thing where it really matters is the speed bitmask.
const ret = Buffer.alloc(3, 0);
// Byte 0 and 2
if (info.isListening) ret[0] |= 0b10_000_000;
Expand Down
34 changes: 24 additions & 10 deletions packages/zwave-js/src/lib/controller/Controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1199,13 +1199,11 @@ export class ZWaveController
)
}`,
);
this._supportsLongRange = resp == RFRegion["USA (Long Range)"];
} else {
this.driver.controllerLog.print(
`Querying the RF region failed!`,
"warn",
);
this._supportsLongRange = false;
}
}

Expand Down Expand Up @@ -1787,7 +1785,8 @@ export class ZWaveController
};

try {
// kick off the inclusion process
// Kick off the inclusion process using either the
// specified protocol or the first supported one
const dskBuffer = dskFromString(provisioningEntry.dsk);
const protocol = provisioningEntry.protocol
?? provisioningEntry.supportedProtocols?.[0]
Expand Down Expand Up @@ -2213,9 +2212,13 @@ export class ZWaveController
|| msg
instanceof ApplicationUpdateRequestSmartStartLongRangeHomeIDReceived
) {
// the controller is in Smart Start learn mode and a node requests inclusion via Smart Start
const isLongRange = msg
instanceof ApplicationUpdateRequestSmartStartLongRangeHomeIDReceived;
// The controller is in Smart Start learn mode and a node requests inclusion via Smart Start
this.driver.controllerLog.print(
"Received Smart Start inclusion request",
`Received Smart Start inclusion request${
isLongRange ? " (Z-Wave Long Range)" : ""
}`,
);

if (
Expand All @@ -2229,11 +2232,21 @@ export class ZWaveController
}

// Check if the node is on the provisioning list
const provisioningEntry = this.provisioningList.find((entry) =>
nwiHomeIdFromDSK(dskFromString(entry.dsk)).equals(
msg.nwiHomeId,
)
);
const provisioningEntry = this.provisioningList.find((entry) => {
if (
!nwiHomeIdFromDSK(dskFromString(entry.dsk)).equals(
msg.nwiHomeId,
)
) {
return false;
}
// TODO: This is duplicated with the logic in beginInclusionSmartStart
const entryProtocol = entry.protocol
?? entry.supportedProtocols?.[0]
?? Protocols.ZWave;
return (entryProtocol === Protocols.ZWaveLongRange)
=== isLongRange;
});
if (!provisioningEntry) {
this.driver.controllerLog.print(
"NWI Home ID not found in provisioning list, ignoring request...",
Expand Down Expand Up @@ -4116,6 +4129,7 @@ supported CCs: ${
const todoSleeping: number[] = [];

const addTodo = (nodeId: number) => {
// Z-Wave Long Range does not route
if (isLongRangeNodeId(nodeId)) return;

if (pendingNodes.has(nodeId)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ export interface SetLongRangeChannelResponseOptions extends MessageBaseOptions {
responseStatus: number;
}

export class ResponseStatusMessageBase extends Message
@messageTypes(MessageType.Response, FunctionType.SetLongRangeChannel)
export class SetLongRangeChannelResponse extends Message
implements SuccessIndicator
{
public constructor(
Expand All @@ -101,14 +102,12 @@ export class ResponseStatusMessageBase extends Message
}
}

@messageTypes(MessageType.Response, FunctionType.SetLongRangeChannel)
export class SetLongRangeChannelResponse extends ResponseStatusMessageBase {}

export interface LongRangeShadowNodeIDsRequestOptions
extends MessageBaseOptions
{
shadowNodeIds: number[];
}

const LONG_RANGE_SHADOW_NODE_IDS_START = 2002;
const NUM_LONG_RANGE_SHADOW_NODE_IDS = 4;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class GetNodeProtocolInfoResponse extends Message {

if (gotDeserializationOptions(options)) {
// The context should contain the node ID the protocol info was requested for.
// Use it to determine whether the node is long range
// We use it here to determine whether the node is long range.
let isLongRange = false;
if (
isObject(options.context)
Expand Down

0 comments on commit 098b8d1

Please sign in to comment.