z21-client 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -88,8 +88,11 @@ class EngineController {
88
88
  default:
89
89
  throw new Error("state must be \"on\", \"off\" or \"toggle\"");
90
90
  }
91
- // Set the specific function bit
92
- functionByte |= (1 << (functionNumber - 1)); // Set the bit corresponding to the function number
91
+ // Set function number in bits 0-5 per Z21 LAN protocol specification
92
+ // See: Z21 LAN Protocol v1.13, Section 4.2 (LAN_X_SET_LOCO_FUNCTION)
93
+ // DB3 byte format: bits 7-6 = switch type (00=off, 01=on, 10=toggle), bits 5-0 = function index
94
+ // Reference: https://www.z21.eu/media/Kwc_Basic_DownloadTag_Component/root-en-main_47-702/default/69bad87e/1712141518/z21-lan-protokoll-en.pdf
95
+ functionByte |= (functionNumber & 0x3F);
93
96
  // Build the command payload
94
97
  // E4 = set function command, 0x40 = LAN_X header, 0x00 = XpressNet command
95
98
  // Payload format: [0x40, 0x00, 0xE4, addrH, addrL, functionByte]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "z21-client",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "TypeScript UDP client for Roco/Fleischmann Z21 DCC command station",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",