dsc-itv2-client 1.0.13 → 1.0.17
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.
- package/package.json +1 -1
- package/src/ITV2Client.js +28 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsc-itv2-client",
|
|
3
3
|
"author": "fajitacat",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.17",
|
|
5
5
|
"description": "Reverse engineered DSC ITV2 Protocol Client Library for TL280R Communicator - Monitor and control DSC alarm panels",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"type": "module",
|
package/src/ITV2Client.js
CHANGED
|
@@ -198,12 +198,18 @@ export class ITV2Client extends EventEmitter {
|
|
|
198
198
|
this.session = new ITv2Session(this.integrationId, this.accessCode, logger);
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
+
// DEBUG: Log all incoming packets
|
|
202
|
+
this._logMinimal(`[DEBUG] RX ${data.length} bytes, state=${this.handshakeState}`);
|
|
203
|
+
|
|
201
204
|
const parsed = this.session.parsePacket(data);
|
|
202
205
|
if (!parsed) {
|
|
203
|
-
this.
|
|
206
|
+
this._logMinimal('[DEBUG] Failed to parse packet');
|
|
204
207
|
return;
|
|
205
208
|
}
|
|
206
209
|
|
|
210
|
+
// DEBUG: Log parsed command
|
|
211
|
+
this._logMinimal(`[DEBUG] Parsed cmd=${parsed.command} (${CMD_NAMES[parsed.command] || 'unknown'})`);
|
|
212
|
+
|
|
207
213
|
// Verbose logging only
|
|
208
214
|
this._log(`\n[UDP] RX from ${this.panelAddress}:${this.panelPort} (${data.length} bytes)`);
|
|
209
215
|
this._hexDump(data);
|
|
@@ -441,7 +447,7 @@ export class ITV2Client extends EventEmitter {
|
|
|
441
447
|
this._sendPacket(response);
|
|
442
448
|
|
|
443
449
|
// Send our REQUEST_ACCESS immediately (panel doesn't ACK our COMMAND_RESPONSE)
|
|
444
|
-
this.
|
|
450
|
+
this._logMinimal('[Handshake] Sending our REQUEST_ACCESS...');
|
|
445
451
|
|
|
446
452
|
// Enable encryption with SEND key
|
|
447
453
|
this.session.sendAesActive = true;
|
|
@@ -480,6 +486,15 @@ export class ITV2Client extends EventEmitter {
|
|
|
480
486
|
if (this.handshakeState === 'SENT_OPEN_SESSION') {
|
|
481
487
|
// Panel accepted our OPEN_SESSION
|
|
482
488
|
this.handshakeState = 'WAITING_REQUEST_ACCESS';
|
|
489
|
+
} else if (this.handshakeState === 'SENT_REQUEST_ACCESS') {
|
|
490
|
+
// Panel accepted our REQUEST_ACCESS - session established!
|
|
491
|
+
this.handshakeState = 'ESTABLISHED';
|
|
492
|
+
this._logMinimal(`[Handshake] Session established (Type ${this.detectedEncryptionType} encryption)`);
|
|
493
|
+
this.emit('session:established', {
|
|
494
|
+
encryptionType: this.detectedEncryptionType,
|
|
495
|
+
sendKey: this.session.derivedSendKey?.toString('hex'),
|
|
496
|
+
recvKey: this.session.pendingReceiveKey?.toString('hex')
|
|
497
|
+
});
|
|
483
498
|
}
|
|
484
499
|
}
|
|
485
500
|
|
|
@@ -502,6 +517,17 @@ export class ITV2Client extends EventEmitter {
|
|
|
502
517
|
// ==================== Notification Handlers ====================
|
|
503
518
|
|
|
504
519
|
_handleLifestyleZoneStatus(parsed) {
|
|
520
|
+
// If we receive encrypted zone data, session is established (even if we missed the final ACK)
|
|
521
|
+
if (this.handshakeState === 'SENT_REQUEST_ACCESS') {
|
|
522
|
+
this.handshakeState = 'ESTABLISHED';
|
|
523
|
+
this._logMinimal(`[Handshake] Session established (Type ${this.detectedEncryptionType} encryption)`);
|
|
524
|
+
this.emit('session:established', {
|
|
525
|
+
encryptionType: this.detectedEncryptionType,
|
|
526
|
+
sendKey: this.session.derivedSendKey?.toString('hex'),
|
|
527
|
+
recvKey: this.session.pendingReceiveKey?.toString('hex')
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
|
|
505
531
|
const data = parsed.commandData;
|
|
506
532
|
|
|
507
533
|
if (data && data.length >= 2) {
|