From 1b7b90fb4f05622672b7ec8daeda3d6ff82dad67 Mon Sep 17 00:00:00 2001 From: Phablulo Date: Fri, 16 Oct 2020 10:29:42 -0300 Subject: [PATCH 1/2] handling scan errors --- lib/bluetooth-serial-port.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/bluetooth-serial-port.js b/lib/bluetooth-serial-port.js index 55152237..ece76530 100644 --- a/lib/bluetooth-serial-port.js +++ b/lib/bluetooth-serial-port.js @@ -32,7 +32,8 @@ var self = this; - this.finish = function (devices) { + this.finish = function (err, devices) { + if (err) return self.emit("error", err) for (const device of devices) { self.emit("found", device.address, device.name); } From 4cb2e1fcb4c26f0650fe4d24fbb911e0cf0df678 Mon Sep 17 00:00:00 2001 From: Phablulo Date: Fri, 16 Oct 2020 10:30:06 -0300 Subject: [PATCH 2/2] emiting device list when finished --- lib/bluetooth-serial-port.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bluetooth-serial-port.js b/lib/bluetooth-serial-port.js index ece76530..6f8eed84 100644 --- a/lib/bluetooth-serial-port.js +++ b/lib/bluetooth-serial-port.js @@ -38,7 +38,7 @@ self.emit("found", device.address, device.name); } - self.emit("finished"); + self.emit("finished", devices); }; }