diff --git a/docs/BoostMoveHub.html b/docs/BoostMoveHub.html index e65398b..ad5e5c5 100644 --- a/docs/BoostMoveHub.html +++ b/docs/BoostMoveHub.html @@ -2208,7 +2208,7 @@ @@ -2427,7 +2427,7 @@ @@ -3334,7 +3334,7 @@ @@ -3455,7 +3455,7 @@ @@ -4584,7 +4584,7 @@ @@ -4755,7 +4755,7 @@ @@ -4950,7 +4950,7 @@ @@ -5273,7 +5273,7 @@ @@ -5444,7 +5444,7 @@ @@ -5639,7 +5639,7 @@ diff --git a/docs/ControlPlusHub.html b/docs/ControlPlusHub.html index 654e40c..0d37393 100644 --- a/docs/ControlPlusHub.html +++ b/docs/ControlPlusHub.html @@ -2208,7 +2208,7 @@ @@ -2427,7 +2427,7 @@ @@ -3334,7 +3334,7 @@ @@ -3455,7 +3455,7 @@ @@ -4584,7 +4584,7 @@ @@ -4755,7 +4755,7 @@ @@ -4950,7 +4950,7 @@ @@ -5273,7 +5273,7 @@ @@ -5444,7 +5444,7 @@ @@ -5639,7 +5639,7 @@ diff --git a/docs/DuploTrainBase.html b/docs/DuploTrainBase.html index 31c83ed..12c4a01 100644 --- a/docs/DuploTrainBase.html +++ b/docs/DuploTrainBase.html @@ -2585,7 +2585,7 @@ @@ -2997,7 +2997,7 @@ @@ -3118,7 +3118,7 @@ @@ -4071,7 +4071,7 @@ @@ -4242,7 +4242,7 @@ diff --git a/docs/LPF2Hub.html b/docs/LPF2Hub.html index abf5777..8f2c36b 100644 --- a/docs/LPF2Hub.html +++ b/docs/LPF2Hub.html @@ -149,7 +149,7 @@ @@ -1747,7 +1747,7 @@ @@ -1957,7 +1957,7 @@ @@ -2119,7 +2119,7 @@ @@ -2231,7 +2231,7 @@ @@ -3326,7 +3326,7 @@ @@ -3488,7 +3488,7 @@ @@ -3674,7 +3674,7 @@ @@ -3983,7 +3983,7 @@ @@ -4145,7 +4145,7 @@ @@ -4307,7 +4307,7 @@ @@ -4493,7 +4493,7 @@ diff --git a/docs/PUPHub.html b/docs/PUPHub.html index 4274b98..ade4ec4 100644 --- a/docs/PUPHub.html +++ b/docs/PUPHub.html @@ -2208,7 +2208,7 @@ @@ -2427,7 +2427,7 @@ @@ -3334,7 +3334,7 @@ @@ -3455,7 +3455,7 @@ @@ -4584,7 +4584,7 @@ @@ -4755,7 +4755,7 @@ @@ -4950,7 +4950,7 @@ @@ -5273,7 +5273,7 @@ @@ -5444,7 +5444,7 @@ @@ -5639,7 +5639,7 @@ diff --git a/docs/PUPRemote.html b/docs/PUPRemote.html index 34c8c02..4135120 100644 --- a/docs/PUPRemote.html +++ b/docs/PUPRemote.html @@ -2194,7 +2194,7 @@ @@ -2315,7 +2315,7 @@ @@ -3268,7 +3268,7 @@ @@ -3463,7 +3463,7 @@ diff --git a/docs/classes.list.html b/docs/classes.list.html index b6c7775..ee0ed23 100644 --- a/docs/classes.list.html +++ b/docs/classes.list.html @@ -509,7 +509,7 @@ @@ -680,7 +680,7 @@ @@ -875,7 +875,7 @@ @@ -1198,7 +1198,7 @@ @@ -1369,7 +1369,7 @@ @@ -1564,7 +1564,7 @@ @@ -1911,7 +1911,7 @@ @@ -2082,7 +2082,7 @@ @@ -2277,7 +2277,7 @@ @@ -2600,7 +2600,7 @@ @@ -2771,7 +2771,7 @@ @@ -2966,7 +2966,7 @@ @@ -3137,7 +3137,7 @@ @@ -3308,7 +3308,7 @@ @@ -3941,7 +3941,7 @@ @@ -4103,7 +4103,7 @@ @@ -4289,7 +4289,7 @@ @@ -4598,7 +4598,7 @@ @@ -4760,7 +4760,7 @@ @@ -4922,7 +4922,7 @@ @@ -5108,7 +5108,7 @@ @@ -5605,7 +5605,7 @@ @@ -5776,7 +5776,7 @@ @@ -5971,7 +5971,7 @@ @@ -6294,7 +6294,7 @@ @@ -6465,7 +6465,7 @@ @@ -6660,7 +6660,7 @@ @@ -6831,7 +6831,7 @@ @@ -7026,7 +7026,7 @@ diff --git a/docs/lpf2hub.js.html b/docs/lpf2hub.js.html index ece49b4..9c78452 100644 --- a/docs/lpf2hub.js.html +++ b/docs/lpf2hub.js.html @@ -98,6 +98,7 @@ const port_1 = require("./port"); const Consts = __importStar(require("./consts")); const Debug = require("debug"); const debug = Debug("lpf2hub"); +const modeInfoDebug = Debug("lpf2hubmodeinfo"); /** * @class LPF2Hub * @extends Hub @@ -253,6 +254,14 @@ class LPF2Hub extends hub_1.Hub { this._parsePortMessage(message); break; } + case 0x43: { + this._parsePortInformationResponse(message); + break; + } + case 0x44: { + this._parseModeInformationResponse(message); + break; + } case 0x45: { this._parseSensorMessage(message); break; @@ -301,6 +310,9 @@ class LPF2Hub extends hub_1.Hub { } _parsePortMessage(data) { let port = this._getPortForPortNumber(data[3]); + if (data[4] === 0x01) { + this._sendPortInformationRequest(data[3]); + } if (!port) { if (data[4] === 0x02) { const portA = this._getPortForPortNumber(data[7]); @@ -329,6 +341,48 @@ class LPF2Hub extends hub_1.Hub { this._registerDeviceAttachment(port, data[5]); } } + _sendPortInformationRequest(port) { + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x21, port, 0x01])); + } + _parsePortInformationResponse(data) { + const port = data[3]; + const count = data[6]; + const input = data.readUInt16LE(7); + const output = data.readUInt16LE(9); + modeInfoDebug(`Port ${port}, total modes ${count}, input modes ${input.toString(2)}, output modes ${output.toString(2)}`); + for (let i = 0; i < count; i++) { + this._sendModeInformationRequest(port, i, 0x00); // Mode Name + this._sendModeInformationRequest(port, i, 0x01); // RAW Range + this._sendModeInformationRequest(port, i, 0x02); // PCT Range + this._sendModeInformationRequest(port, i, 0x03); // SI Range + this._sendModeInformationRequest(port, i, 0x04); // SI Symbol + } + } + _sendModeInformationRequest(port, mode, type) { + this._writeMessage(Consts.BLECharacteristic.LPF2_ALL, Buffer.from([0x22, port, mode, type])); + } + _parseModeInformationResponse(data) { + const port = data[3]; + const mode = data[4]; + const type = data[5]; + switch (type) { + case 0x00: // Mode Name + modeInfoDebug(`Port ${port}, mode ${mode}, name ${data.slice(6, data.length).toString()}`); + break; + case 0x01: // RAW Range + modeInfoDebug(`Port ${port}, mode ${mode}, RAW min ${data.readFloatLE(6)}, max ${data.readFloatLE(10)}`); + break; + case 0x02: // PCT Range + modeInfoDebug(`Port ${port}, mode ${mode}, PCT min ${data.readFloatLE(6)}, max ${data.readFloatLE(10)}`); + break; + case 0x03: // SI Range + modeInfoDebug(`Port ${port}, mode ${mode}, SI min ${data.readFloatLE(6)}, max ${data.readFloatLE(10)}`); + break; + case 0x04: // SI Symbol + modeInfoDebug(`Port ${port}, mode ${mode}, SI symbol ${data.slice(6, data.length).toString()}`); + break; + } + } _parsePortAction(data) { const port = this._getPortForPortNumber(data[3]); if (!port) { diff --git a/docs/quicksearch.html b/docs/quicksearch.html index 3fdc451..7dd5d0c 100644 --- a/docs/quicksearch.html +++ b/docs/quicksearch.html @@ -7,7 +7,7 @@