Skip to content

Commit 9e5d493

Browse files
committed
Fix the 'open' event on Connection class, fixes https://github.com/orgs/espruino/discussions/7746
1 parent 8b02a59 commit 9e5d493

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

uart.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,8 @@ To do:
513513
this.hadData = false;
514514
this.flowControlWait = 0;
515515
this.rxDataHandlerLastCh = 0;
516-
if (this.isOpen) {
517-
this.isOpen = false;
516+
if (!this.isOpen) {
517+
this.isOpen = true;
518518
this.emit("open");
519519
}
520520
// if we had any writes queued, do them now
@@ -569,8 +569,8 @@ To do:
569569
return;
570570
}
571571
var txItem = connection.txDataQueue[0];
572-
uart.writeProgress(txItem.maxLength - txItem.data.length, txItem.maxLength);
573-
connection.updateProgress(txItem.maxLength - txItem.data.length, txItem.maxLength);
572+
uart.writeProgress(txItem.maxLength - (txItem.data?txItem.data.length:0), txItem.maxLength);
573+
connection.updateProgress(txItem.maxLength - (txItem.data?txItem.data.length:0), txItem.maxLength);
574574
if (txItem.data.length <= connection.chunkSize) {
575575
chunk = txItem.data;
576576
txItem.data = undefined;
@@ -893,7 +893,7 @@ To do:
893893
});
894894
return device.gatt.connect();
895895
}).then(function(server) {
896-
log(1, "Connected");
896+
log(2, "BLE Connected");
897897
btServer = server;
898898
return server.getPrimaryService(NORDIC_SERVICE);
899899
}).then(function(service) {

0 commit comments

Comments
 (0)