node-switchbot 1.4.2-beta.10 → 1.4.2-beta.11

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.
@@ -361,20 +361,20 @@ class SwitchbotAdvertising {
361
361
  return null;
362
362
  }
363
363
  const byte9 = buf.readUInt8(9); // byte9: color bulb state; 0x00=off, 0x80=on & lightLevel: 1~100%
364
- const byte10 = buf.readUInt8(10); // byte10: bit0: 0=no delay,1=delay, bit1:0=no timer, 1=timer; bit2:0=no sync time, 1=sync'ed time
365
- const byte11 = buf.readUInt8(11); // byte11: wifi rssi
366
- const byte12 = buf.readUInt8(12); // byte12: bit7: overload?
367
- const byte13 = buf.readUInt8(13); // byte12[bit0~6] + byte13: current power value
364
+ //const byte10 = buf.readUInt8(10); // byte10: bit0: 0=no delay,1=delay, bit1:0=no timer, 1=timer; bit2:0=no sync time, 1=sync'ed time
365
+ //const byte11 = buf.readUInt8(11); // byte11: wifi rssi
366
+ //const byte12 = buf.readUInt8(12); // byte12: bit7: overload?
367
+ //const byte13 = buf.readUInt8(13); // byte12[bit0~6] + byte13: current power value
368
368
 
369
369
  const state = byte9 === 0x01 ? "off" : byte9 === 0x80 ? "on" : null;
370
370
  const lightLevel = byte9 & 0b00000011;
371
- const delay = !!(byte10 & 0b00000001);
372
- const networkStatus = !!(byte10 & 0b00000001);
373
- const statePreset = !!(byte10 & 0b00000010);
374
- const lightState = !!(byte10 & 0b00000100);
375
- const wifiRssi = byte11;
376
- const dynamicRate = !!(byte12 & 0b10000000);
377
- const loopIndex = (((byte12 & 0b01111111) << 8) + byte13) / 10; // in watt
371
+ //const delay = !!(byte10 & 0b00000001);
372
+ //const networkStatus = !!(byte10 & 0b00000001);
373
+ //const statePreset = !!(byte10 & 0b00000010);
374
+ //const lightState = !!(byte10 & 0b00000100);
375
+ //const wifiRssi = byte11;
376
+ //const dynamicRate = !!(byte12 & 0b10000000);
377
+ //const loopIndex = (((byte12 & 0b01111111) << 8) + byte13) / 10; // in watt
378
378
 
379
379
  const data = {
380
380
  model: "u",
@@ -540,25 +540,49 @@ class SwitchbotAdvertising {
540
540
  return data;
541
541
  }
542
542
 
543
- _parseServiceDataForWoLEDStripLight(buf, onlog) {
544
- if (buf.length !== 6) {
543
+ _parseServiceDataForWoStrip(buf, onlog) {
544
+ if (buf.length !== 18) {
545
545
  if (onlog && typeof onlog === "function") {
546
546
  onlog(
547
- `[_parseServiceDataForWoLEDStripLight] Buffer length ${buf.length} !== 6!`
547
+ `[_parseServiceDataForWoStrip] Buffer length ${buf.length} !== 18!`
548
548
  );
549
549
  }
550
550
  return null;
551
551
  }
552
- let byte1 = buf.readUInt8(1);
553
- let byte2 = buf.readUInt8(2);
554
- // let byte3 = buf.readUInt8(3);
555
- // let byte4 = buf.readUInt8(4);
556
- let byte5 = buf.readUInt8(5);
552
+ const byte9 = buf.readUInt8(9); // byte9: color bulb state; 0x00=off, 0x80=on & lightLevel: 1~100%
553
+ //const byte10 = buf.readUInt8(10); // byte10: bit0: 0=no delay,1=delay, bit1:0=no timer, 1=timer; bit2:0=no sync time, 1=sync'ed time
554
+ //const byte11 = buf.readUInt8(11); // byte11: wifi rssi
555
+ //const byte12 = buf.readUInt8(12); // byte12: bit7: overload?
556
+ //const byte13 = buf.readUInt8(13); // byte12[bit0~6] + byte13: current power value
557
557
 
558
- let data = {
558
+ const state = byte9 === 0x01 ? "off" : byte9 === 0x80 ? "on" : null;
559
+ //const lightLevel = byte9 & 0b00000011;
560
+ //const delay = !!(byte10 & 0b00000001);
561
+ //const networkStatus = !!(byte10 & 0b00000001);
562
+ //const statePreset = !!(byte10 & 0b00000010);
563
+ //const lightState = !!(byte10 & 0b00000100);
564
+ //const wifiRssi = byte11;
565
+ //const dynamicRate = !!(byte12 & 0b10000000);
566
+ //const loopIndex = (((byte12 & 0b01111111) << 8) + byte13) / 10; // in watt
567
+
568
+ const data = {
559
569
  model: "r",
560
- modelName: "WoLEDStripLight",
570
+ modelName: "WoStrip",
571
+ state: state,
561
572
  };
573
+ /* const data = {
574
+ model: "u",
575
+ modelName: "WoBulb",
576
+ state: state,
577
+ lightLevel: lightLevel,
578
+ delay: delay,
579
+ networkStatus: networkStatus,
580
+ statePreset: statePreset,
581
+ lightState: lightState,
582
+ wifiRssi: wifiRssi,
583
+ dynamicRate: dynamicRate,
584
+ loopIndex: loopIndex,
585
+ };*/
562
586
 
563
587
  return data;
564
588
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-switchbot",
3
- "version": "1.4.2-beta.10",
3
+ "version": "1.4.2-beta.11",
4
4
  "description": "The node-switchbot is a Node.js module which allows you to control your Switchbot Devices through Bluetooth (BLE).",
5
5
  "main": "./lib/switchbot.js",
6
6
  "files": [