Skip to content

Commit 4007f8b

Browse files
author
Daisuke Baba
committed
Merge tag '3.0.0' into develop
no message
2 parents db91aec + 04c9f51 commit 4007f8b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ Set `GENERIC_BLE_TRACE=true` on starting Node-RED and you can find the precise l
211211

212212
* 3.0.0
213213
- Refactor entire architecture
214+
- Peripheral connections are retained until it disconnects
215+
- Characteristic subscriptions are retained while the ongoing flows are running (will be unsubscribed on stopping them though)
216+
- The max number of concurrent BLE connections is 5 or 6 according to [this document](https://github.com/noble/noble#maximum-simultaneous-connections)
214217

215218
* 2.0.4
216219
- Fix an issue where this node don't work with [email protected]

src/generic-ble.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ export default function(RED) {
244244
},
245245
unsubscribe: () => {
246246
return new Promise((resolve) => {
247-
if (obj.notifiable) {
247+
let peripheral = noble._peripherals[obj._peripheralId];
248+
if (obj.notifiable && peripheral && peripheral.state === 'connected') {
248249
delete obj.dataListener;
249250
obj.object.unsubscribe(resolve);
250251
} else {
@@ -304,8 +305,8 @@ export default function(RED) {
304305
}, []).map((c) => toCharacteristic(c));
305306
});
306307
});
308+
peripheral.connect(); // peripheral.state => connecting
307309
}
308-
peripheral.connect(); // peripheral.state => connecting
309310
connecting = true;
310311
break;
311312
}
@@ -552,6 +553,7 @@ export default function(RED) {
552553
}
553554
});
554555
});
556+
this.emit('disconnected');
555557
this.on('close', (done) => {
556558
Object.keys(configBleDevices).forEach(k => delete configBleDevices[k]);
557559
this.operations.shutdown().then(done).catch(done);

0 commit comments

Comments
 (0)