Transport disconnect method (#753)

* Prevent reads from piling up

* Implement disconnect() method for all transports
This commit is contained in:
Henri Bergius
2025-08-05 22:46:23 -04:00
committed by GitHub
parent 313c4dbb71
commit 0a7b653ec8
7 changed files with 62 additions and 6 deletions
@@ -9,6 +9,7 @@ export class TransportWebBluetooth implements Types.Transport {
private toRadioCharacteristic: BluetoothRemoteGATTCharacteristic;
private fromRadioCharacteristic: BluetoothRemoteGATTCharacteristic;
private fromNumCharacteristic: BluetoothRemoteGATTCharacteristic;
private gattServer: BluetoothRemoteGATTServer;
static ToRadioUuid = "f75c76d2-129e-4dad-a1dd-7866124401e7";
static FromRadioUuid = "2c55e69e-4993-11ed-b878-0242ac120002";
@@ -65,6 +66,7 @@ export class TransportWebBluetooth implements Types.Transport {
toRadioCharacteristic,
fromRadioCharacteristic,
fromNumCharacteristic,
gattServer,
);
}
@@ -72,10 +74,12 @@ export class TransportWebBluetooth implements Types.Transport {
toRadioCharacteristic: BluetoothRemoteGATTCharacteristic,
fromRadioCharacteristic: BluetoothRemoteGATTCharacteristic,
fromNumCharacteristic: BluetoothRemoteGATTCharacteristic,
gattServer: BluetoothRemoteGATTServer,
) {
this.toRadioCharacteristic = toRadioCharacteristic;
this.fromRadioCharacteristic = fromRadioCharacteristic;
this.fromNumCharacteristic = fromNumCharacteristic;
this.gattServer = gattServer;
this._fromDevice = new ReadableStream({
start: (ctrl) => {
@@ -133,4 +137,9 @@ export class TransportWebBluetooth implements Types.Transport {
});
}
}
disconnect() : Promise<void> {
this.gattServer.disconnect();
return Promise.resolve();
}
}