You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 40e229e
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: .github/copilot-instructions.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,6 +68,7 @@ Implements the Z-Wave Serial API frame-level protocol (as defined by the Z-Wave
68
68
-**`ZWaveSerialPortCoordinator`** — Manages the serial port, frame send/receive channels, ACK handshake, and retransmission.
69
69
-**`Commands/`** — Each Serial API command (e.g. `SendData`, `GetInitData`, `SoftReset`) is a struct implementing `ICommand<T>` (defined in `Serial/Commands/ICommand.cs`). Commands that expect a callback implement `IRequestWithCallback<T>`.
70
70
-**`CommandId` enum** — All Serial API function IDs.
71
+
-**`CommandDataParsingHelpers`** — Internal shared utilities: `ParseCommandClasses` (CC byte list → `CommandClassInfo` records) and `ParseNodeBitmask` (bitmask → `HashSet<ushort>` node IDs).
@@ -82,7 +83,7 @@ Implements Z-Wave Command Classes (Z-Wave Application Specification). This proje
82
83
83
84
-**`Driver`** — Entry point. Implements `IDriver`. Opens serial port, manages frame send/receive, processes unsolicited requests, coordinates request-response and callback flows.
84
85
-**`Controller`** — Represents the Z-Wave USB controller. Runs identification sequence on startup.
85
-
-**`Node`** — Represents a Z-Wave network node. Implements `INode`. Handles interviews and command class discovery.
86
+
-**`Node`** — Represents a Z-Wave network node. Implements `INode`. Handles interviews and command class discovery. Node IDs are `ushort` throughout the codebase to support both classic (1–232) and Long Range (256+) nodes.
86
87
87
88
### Source Generators (`src/ZWave.BuildTools/`)
88
89
@@ -108,11 +109,12 @@ Uses `Microsoft.Extensions.Logging` with source-generated `[LoggerMessage]` attr
108
109
- Tests use **MSTest** with the `MSTest.Sdk` project SDK and the **Microsoft.Testing.Platform** runner.
109
110
- Tests run in parallel at method level.
110
111
- Serial API command tests inherit from `CommandTestBase` and use `TestSendableCommand` / `TestReceivableCommand` helper methods that verify frame structure round-tripping.
112
+
-`CommandDataParsingHelpersTests` covers the shared parsing helpers (`ParseCommandClasses`, `ParseNodeBitmask`).
111
113
- Test files mirror the source structure: `src/ZWave.Serial.Tests/Commands/` contains tests for each serial command.
112
114
113
115
## Adding New Functionality
114
116
115
-
**New Serial API Command**: Create a struct in `src/ZWave.Serial/Commands/` implementing `ICommand<T>` (and `IRequestWithCallback<T>` if it uses callbacks). Add the command ID to `CommandId` enum. Add tests in `src/ZWave.Serial.Tests/Commands/`.
117
+
**New Serial API Command**: Create a struct in `src/ZWave.Serial/Commands/` implementing `ICommand<T>` (and `IRequestWithCallback<T>` if it uses callbacks). Add the command ID to `CommandId` enum. Add tests in `src/ZWave.Serial.Tests/Commands/`. Node ID parameters are `ushort`; cast to `(byte)nodeId` when writing to the buffer. Use `CommandDataParsingHelpers` for shared parsing (node bitmasks, command class lists).
116
118
117
119
**New Command Class**: Create a class in `src/ZWave.CommandClasses/` inheriting `CommandClass<TEnum>`. Apply `[CommandClass(CommandClassId.X)]`. Define private inner structs for each command (Set/Get/Report) implementing `ICommand`. The source generator auto-registers it.
Copy file name to clipboardExpand all lines: docs/architecture.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -99,6 +99,10 @@ Each Z-Wave Serial API function is represented as a struct. These map to the fun
99
99
100
100
**`CommandId` enum** - All Serial API function IDs (e.g. `SendData = 0x13`, `GetInitData = 0x02`).
101
101
102
+
**`CommandDataParsingHelpers`** (`Commands/CommandDataParsingHelpers.cs`) - Internal shared utilities for parsing common serial API response patterns:
103
+
-`ParseCommandClasses` — Parses a CC byte list with the support/control mark into `CommandClassInfo` records.
104
+
-`ParseNodeBitmask` — Parses a node ID bitmask (each bit = one node) into a `HashSet<ushort>`. Takes a `baseNodeId` parameter (1 for classic nodes, 256+ for LR nodes).
105
+
102
106
**Communication patterns:**
103
107
-**Fire-and-forget:** Host sends a REQ with no response expected (e.g. `SoftReset`, `SendDataAbort`, `WatchdogKick`)
104
108
-**Request → Response:** Host sends a REQ, chip replies with a RES (e.g. `MemoryGetId`, `GetLibraryVersion`, `GetRoutingInfo`, `IsFailedNode`)
@@ -107,6 +111,8 @@ Each Z-Wave Serial API function is represented as a struct. These map to the fun
107
111
-**Set only:** Host sends a REQ to configure the chip with no response (e.g. `ApplicationNodeInformation`, `SetPromiscuousMode`)
108
112
-**Unsolicited request:** Chip sends a REQ without the host asking (e.g. `ApplicationCommandHandler`, `ApplicationUpdate`, `ApplicationCommandHandlerBridge`, `SerialApiStarted`)
109
113
114
+
**Node ID encoding:** All node ID parameters in the C# API are `ushort` to support both classic (1–232) and Long Range (256+) nodes. On the wire, node IDs are currently serialized as a single byte (8-bit mode, the default). The `Create()` methods cast `(byte)nodeId` when writing to the buffer.
115
+
110
116
### Command Classes (`src/ZWave.CommandClasses/`)
111
117
112
118
Implements Z-Wave Command Classes per the Z-Wave Application Specification. These are the application-level messages exchanged between Z-Wave nodes. This project references `ZWave.Protocol` but **not**`ZWave.Serial`, enabling mock driver implementations without a serial dependency.
@@ -144,6 +150,7 @@ Implements Z-Wave Command Classes per the Z-Wave Application Specification. Thes
144
150
-`IdentifyAsync()` queries the chip: home/node ID, serial API capabilities, library version, controller capabilities, supported setup subcommands, SUC node ID, and init data (node list)
145
151
- Promotes itself to SUC/SIS if none exists on the network
146
152
- Creates `Node` instances for every node in the network
153
+
- Stores nodes in a `Dictionary<ushort, Node>` keyed by node ID
147
154
148
155
**`Node`** (`Node.cs`) - Represents a Z-Wave network node. Implements `INode`.
149
156
-`InterviewAsync()` queries protocol info, requests node info, discovers command classes, then interviews each CC in topological dependency order
0 commit comments