@meshtastic/meshtasticjs
Advanced tools
Comparing version 0.6.108 to 0.6.109
@@ -10,2 +10,3 @@ /// <reference types="web-bluetooth" /> | ||
device: BluetoothDevice | undefined; | ||
GATTServer: BluetoothRemoteGATTServer | undefined; | ||
/** Short Description */ | ||
@@ -12,0 +13,0 @@ service: BluetoothRemoteGATTService | undefined; |
@@ -11,2 +11,3 @@ import { Protobuf, Types } from "./index.js"; | ||
device; | ||
GATTServer; | ||
/** Short Description */ | ||
@@ -27,2 +28,3 @@ service; | ||
this.service = undefined; | ||
this.GATTServer = undefined; | ||
this.toRadioCharacteristic = undefined; | ||
@@ -86,8 +88,41 @@ this.fromRadioCharacteristic = undefined; | ||
/** Connect to device */ | ||
await this.device.gatt?.connect(); | ||
this.service = await this.device.gatt?.getPrimaryService(serviceUUID); | ||
this.toRadioCharacteristic = await this.service?.getCharacteristic(toRadioUUID); | ||
this.fromRadioCharacteristic = await this.service?.getCharacteristic(fromRadioUUID); | ||
this.fromNumCharacteristic = await this.service?.getCharacteristic(fromNumUUID); | ||
await this.fromNumCharacteristic?.startNotifications(); | ||
await this.device.gatt | ||
?.connect() | ||
.then((server) => { | ||
this.log(Types.EmitterScope.iBleConnection, Types.Emitter.connect, `✅ Got GATT Server for device: ${server.device.id}`, Protobuf.LogRecord_Level.INFO); | ||
this.GATTServer = server; | ||
}) | ||
.catch((e) => { | ||
this.log(Types.EmitterScope.iBleConnection, Types.Emitter.connect, `❌ Failed to connect: ${e.message}`, Protobuf.LogRecord_Level.ERROR); | ||
}); | ||
await this.GATTServer?.getPrimaryService(serviceUUID) | ||
.then((service) => { | ||
this.log(Types.EmitterScope.iBleConnection, Types.Emitter.connect, `✅ Got GATT Service for device: ${service.device.id}`, Protobuf.LogRecord_Level.INFO); | ||
this.service = service; | ||
}) | ||
.catch((e) => { | ||
this.log(Types.EmitterScope.iBleConnection, Types.Emitter.connect, `❌ Failed to get primary service: q${e.message}`, Protobuf.LogRecord_Level.ERROR); | ||
}); | ||
[toRadioUUID, fromRadioUUID, fromNumUUID].map(async (uuid) => { | ||
await this.service | ||
?.getCharacteristic(uuid) | ||
.then((characteristic) => { | ||
this.log(Types.EmitterScope.iBleConnection, Types.Emitter.connect, `✅ Got Characteristic ${characteristic.uuid} for device: ${characteristic.name}`, Protobuf.LogRecord_Level.INFO); | ||
switch (uuid) { | ||
case toRadioUUID: | ||
this.toRadioCharacteristic = characteristic; | ||
break; | ||
case fromRadioUUID: | ||
this.fromRadioCharacteristic = characteristic; | ||
break; | ||
case fromNumUUID: | ||
this.fromNumCharacteristic = characteristic; | ||
break; | ||
} | ||
}) | ||
.catch((e) => { | ||
this.log(Types.EmitterScope.iBleConnection, Types.Emitter.connect, `❌ Failed to get toRadio characteristic: q${e.message}`, Protobuf.LogRecord_Level.ERROR); | ||
}); | ||
}); | ||
await this.fromNumCharacteristic?.startNotifications(); // TODO: catch | ||
this.fromNumCharacteristic?.addEventListener("characteristicvaluechanged", () => { | ||
@@ -94,0 +129,0 @@ void this.readFromRadio(); |
{ | ||
"name": "@meshtastic/meshtasticjs", | ||
"version": "0.6.108", | ||
"version": "0.6.109", | ||
"description": "Browser library for interfacing with meshtastic devices", | ||
@@ -5,0 +5,0 @@ "license": "GPL-3.0-only", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
544064
10945