refactor ble connection to web ble connection

This commit is contained in:
liamcottle 2025-04-08 13:54:25 +12:00
parent 6a3d96b6c6
commit 06f8f9d4ea
4 changed files with 8 additions and 8 deletions

View file

@ -9,7 +9,7 @@ It can also be used in NodeJS to connect to MeshCore Companion devices over TCP/
## Supported Connection Methods
- Web Browser
- BLE: [BleConnection()](./src/connection/ble_connection.js)
- BLE: [WebBleConnection()](./src/connection/web_ble_connection.js)
- USB/Serial: [WebSerialConnection()](./src/connection/web_serial_connection.js)
- NodeJS
- TCP/WiFi: [TCPConnection("host", "port")](./src/connection/tcp_connection.js)

View file

@ -191,7 +191,7 @@
<script type="module">
import Constants from "./src/constants.js";
import WebSerialConnection from "./src/connection/web_serial_connection.js";
import BleConnection from "./src/connection/ble_connection.js";
import WebBleConnection from "./src/connection/web_ble_connection.js";
import BufferUtils from "./src/buffer_utils.js";
Vue.createApp({
data() {
@ -216,7 +216,7 @@
// this.connection.on("rx", (data) => console.log("rx", data));
},
async askForBleDevice() {
this.connection = await BleConnection.open();
this.connection = await WebBleConnection.open();
this.connection.on("connected", () => this.onConnected());
this.connection.on("disconnected", () => this.onDisconnected());
// this.connection.on("tx", (data) => console.log("tx", data));

View file

@ -1,7 +1,7 @@
import Constants from "../constants.js";
import Connection from "./connection.js";
class BleConnection extends Connection {
class WebBleConnection extends Connection {
constructor(bleDevice) {
super();
@ -36,7 +36,7 @@ class BleConnection extends Connection {
return null;
}
return new BleConnection(device);
return new WebBleConnection(device);
}
@ -103,4 +103,4 @@ class BleConnection extends Connection {
}
export default BleConnection;
export default WebBleConnection;

View file

@ -1,5 +1,5 @@
import Connection from "./connection/connection.js";
import BleConnection from "./connection/ble_connection.js";
import WebBleConnection from "./connection/web_ble_connection.js";
import SerialConnection from "./connection/serial_connection.js";
import NodeJSSerialConnection from "./connection/nodejs_serial_connection.js";
import WebSerialConnection from "./connection/web_serial_connection.js";
@ -11,7 +11,7 @@ import BufferUtils from "./buffer_utils.js";
export {
Connection,
BleConnection,
WebBleConnection,
SerialConnection,
NodeJSSerialConnection,
WebSerialConnection,