dsc-itv2-client 1.0.13 → 1.0.16

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/ITV2Client.js +19 -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.13",
4
+ "version": "1.0.16",
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._log('[Error] Failed to parse packet');
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._log(`[Handshake] Sending our REQUEST_ACCESS`);
450
+ this._logMinimal('[Handshake] Sending our REQUEST_ACCESS...');
445
451
 
446
452
  // Enable encryption with SEND key
447
453
  this.session.sendAesActive = true;
@@ -502,6 +508,17 @@ export class ITV2Client extends EventEmitter {
502
508
  // ==================== Notification Handlers ====================
503
509
 
504
510
  _handleLifestyleZoneStatus(parsed) {
511
+ // If we receive encrypted zone data, session is established (even if we missed the final ACK)
512
+ if (this.handshakeState === 'SENT_REQUEST_ACCESS') {
513
+ this.handshakeState = 'ESTABLISHED';
514
+ this._logMinimal(`[Handshake] Session established (Type ${this.detectedEncryptionType} encryption)`);
515
+ this.emit('session:established', {
516
+ encryptionType: this.detectedEncryptionType,
517
+ sendKey: this.session.derivedSendKey?.toString('hex'),
518
+ recvKey: this.session.pendingReceiveKey?.toString('hex')
519
+ });
520
+ }
521
+
505
522
  const data = parsed.commandData;
506
523
 
507
524
  if (data && data.length >= 2) {