Skip to content

Commit

Permalink
Fix error message if browser does not support Web Serial
Browse files Browse the repository at this point in the history
  • Loading branch information
lijon committed Sep 9, 2021
1 parent 2345485 commit c90241b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
6 changes: 3 additions & 3 deletions BafangWebCfg.html
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,10 @@ <h2>Throttle</h2>
bafang.saveFile();
});

navigator.serial.addEventListener("connect", (event) => {
// navigator.serial.addEventListener("connect", (event) => {
// TODO: Automatically open event.target or warn user a port is available.
console.log("Connected "+event.target);
});
// console.log("Connected "+event.target);
// });

// navigator.serial.addEventListener("disconnect", (event) => {
// // TODO: Remove |event.target| from the UI.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# BafangWebConfig
Cross-platform browser based configuration tool for Bafang BBSxx e-bike motors. It should work on any modern browser with support for Serial Web API, on Mac, Linux or Windows.
Cross-platform browser based configuration tool for Bafang BBSxx e-bike motors, runs on Mac, Linux or Windows. It requires a browser with support for Web Serial API, and should work on any recent version of Chrome, Opera or Edge.

## Run online

Expand Down
7 changes: 2 additions & 5 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ class BafangConfig {
const node = document.querySelector('#'+key+'.error-display');
node.style.color = "red";
node.innerText = msg.join(' ');
console.log(key,"ERROR:",msg.join(' '));
console.error(key,"ERROR:",msg.join(' '));
}
logMsg(blk, ...msg) {
const key = blockKeys[blk];
Expand Down Expand Up @@ -411,10 +411,7 @@ class BafangConfig {
}
}
else {
console.error('Web serial doesn\'t seem to be enabled in your browser. Try enabling it by visiting:');
console.error('chrome://flags/#enable-experimental-web-platform-features');
console.error('opera://flags/#enable-experimental-web-platform-features');
console.error('edge://flags/#enable-experimental-web-platform-features');
this.logError(BLK_GEN, "Web Serial disabled or not supported by your browser.\nTry a recent version of Chrome, Opera or Edge.")
}
}
async write(data) {
Expand Down

0 comments on commit c90241b

Please sign in to comment.