Skip to content

Commit 296dd3d

Browse files
committed
v1.7.2
## [Version 1.7.2](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.7.2) (2022-12-26) ## What's Changed - Fix for @abandonware/nobles breaking changes that cause: `TypeError: this.noble.once is not a function`. **Full Changelog**: v1.7.1...v1.7.2
1 parent 01cce41 commit 296dd3d

File tree

5 files changed

+190
-117
lines changed

5 files changed

+190
-117
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/)
44

5+
## [Version 1.7.2](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.7.2) (2022-12-26)
6+
7+
## What's Changed
8+
9+
- Fix for @abandonware/nobles breaking changes that cause: `TypeError: this.noble.once is not a function`.
10+
11+
**Full Changelog**: https://github.com/OpenWonderLabs/node-switchbot/compare/v1.7.1...v1.7.2
12+
513
## [Version 1.7.1](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.7.1) (2022-12-20)
614

715
## What's Changed

lib/switchbot-device.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class SwitchbotDevice {
131131
});
132132

133133
// Connect
134-
this._peripheral.connectAsync((error) => {
134+
this._peripheral.connect((error) => {
135135
if (error) {
136136
reject(error);
137137
return;
@@ -145,7 +145,7 @@ class SwitchbotDevice {
145145
resolve();
146146
})
147147
.catch((error) => {
148-
this._peripheral.disconnectAsync();
148+
this._peripheral.disconnect();
149149
reject(error);
150150
});
151151
});
@@ -224,7 +224,7 @@ class SwitchbotDevice {
224224

225225
_discoverServices() {
226226
return new Promise((resolve, reject) => {
227-
this._peripheral.discoverServicesAsync([], (error, service_list) => {
227+
this._peripheral.discoverServices([], (error, service_list) => {
228228
if (error) {
229229
reject(error);
230230
return;
@@ -321,7 +321,7 @@ class SwitchbotDevice {
321321
// Unsubscribe
322322
this._unsubscribe().then(() => {
323323
// Disconnect
324-
this._peripheral.disconnectAsync(() => {
324+
this._peripheral.disconnect(() => {
325325
resolve();
326326
});
327327
});

lib/switchbot.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Switchbot {
3030
if (params && params.noble) {
3131
noble = params.noble;
3232
} else {
33-
noble = require('@abandonware/noble')({extended: false});
33+
noble = require("@abandonware/noble");
3434
}
3535

3636
// Public properties
@@ -127,7 +127,7 @@ class Switchbot {
127127
clearTimeout(timer);
128128
}
129129
this.noble.removeAllListeners("discover");
130-
this.noble.stopScanningAsync(() => process.exit());
130+
this.noble.stopScanning();
131131
let device_list = [];
132132
for (let addr in peripherals) {
133133
device_list.push(peripherals[addr]);
@@ -155,7 +155,7 @@ class Switchbot {
155155
});
156156

157157
// Start scanning
158-
this.noble.startScanningAsync(
158+
this.noble.startScanning(
159159
this._PRIMARY_SERVICE_UUID_LIST,
160160
false,
161161
(error) => {
@@ -167,7 +167,7 @@ class Switchbot {
167167
finishDiscovery();
168168
}, p.duration);
169169
}
170-
, false);
170+
);
171171
})
172172
.catch((error) => {
173173
reject(error);
@@ -371,7 +371,7 @@ class Switchbot {
371371
});
372372

373373
// Start scanning
374-
this.noble.startScanningAsync(
374+
this.noble.startScanning(
375375
this._PRIMARY_SERVICE_UUID_LIST,
376376
true,
377377
(error) => {
@@ -381,7 +381,7 @@ class Switchbot {
381381
resolve();
382382
}
383383
}
384-
, false);
384+
);
385385
})
386386
.catch((error) => {
387387
reject(error);
@@ -402,7 +402,7 @@ class Switchbot {
402402
* ---------------------------------------------------------------- */
403403
stopScan() {
404404
this.noble.removeAllListeners("discover");
405-
this.noble.stopScanningAsync(() => process.exit());
405+
this.noble.stopScanning();
406406
}
407407

408408
/* ------------------------------------------------------------------

0 commit comments

Comments
 (0)