mirror of
https://github.com/thegecko/web-bluetooth-dfu.git
synced 2026-03-15 13:13:19 +08:00
Merge uuid options with defaults
Move UuidOptions interface into secure-dfu.ts
This commit is contained in:
@@ -24,7 +24,6 @@
|
||||
*/
|
||||
|
||||
import { EventDispatcher } from "./dispatcher";
|
||||
import { UuidOptions } from "./uuid-options";
|
||||
|
||||
const CONTROL_UUID = "8ec90001-f315-4f60-9fb8-838830daea50";
|
||||
const PACKET_UUID = "8ec90002-f315-4f60-9fb8-838830daea50";
|
||||
@@ -119,6 +118,13 @@ export interface BluetoothLEScanFilterInit {
|
||||
namePrefix?: string;
|
||||
}
|
||||
|
||||
export interface UuidOptions {
|
||||
service?: number | string;
|
||||
button?: number | string;
|
||||
control?: number | string;
|
||||
packet?: number | string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Secure Device Firmware Update class
|
||||
*/
|
||||
@@ -409,6 +415,10 @@ export class SecureDfu extends EventDispatcher {
|
||||
filters: Array<BluetoothLEScanFilterInit>,
|
||||
uuids: UuidOptions = this.DEFAULT_UUIDS
|
||||
): Promise<BluetoothDevice> {
|
||||
uuids = {
|
||||
...this.DEFAULT_UUIDS,
|
||||
...uuids
|
||||
};
|
||||
if (!buttonLess && !filters) {
|
||||
filters = [ { services: [ uuids.service ] } ];
|
||||
}
|
||||
@@ -436,6 +446,10 @@ export class SecureDfu extends EventDispatcher {
|
||||
* @returns Promise containing the device if it is still on a valid state
|
||||
*/
|
||||
public setDfuMode(device: BluetoothDevice, uuids: UuidOptions = this.DEFAULT_UUIDS): Promise<BluetoothDevice> {
|
||||
uuids = {
|
||||
...this.DEFAULT_UUIDS,
|
||||
...uuids
|
||||
};
|
||||
return this.gattConnect(device, uuids.service)
|
||||
.then(characteristics => {
|
||||
this.log(`found ${characteristics.length} characteristic(s)`);
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
export interface UuidOptions {
|
||||
service?: number | string;
|
||||
button?: number | string;
|
||||
control?: number | string;
|
||||
packet?: number | string;
|
||||
}
|
||||
Reference in New Issue
Block a user