Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement: add timeout options for api disconnect #647

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/bleClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,9 @@ export interface BleClientInterface {
/**
* Disconnect from a peripheral BLE device. For an example, see [usage](#usage).
* @param deviceId The ID of the device to use (obtained from [requestDevice](#requestDevice) or [requestLEScan](#requestLEScan))
* @param options Options for plugin call
*/
disconnect(deviceId: string): Promise<void>;
disconnect(deviceId: string, options?: TimeoutOptions): Promise<void>;

/**
* Get services, characteristics and descriptors of a device.
Expand Down Expand Up @@ -488,9 +489,9 @@ class BleClientClass implements BleClientInterface {
return isBonded;
}

async disconnect(deviceId: string): Promise<void> {
async disconnect(deviceId: string, options?: TimeoutOptions): Promise<void> {
await this.queue(async () => {
await BluetoothLe.disconnect({ deviceId });
await BluetoothLe.disconnect({ deviceId, ...options });
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ export interface BluetoothLePlugin {
connect(options: DeviceIdOptions & TimeoutOptions): Promise<void>;
createBond(options: DeviceIdOptions & TimeoutOptions): Promise<void>;
isBonded(options: DeviceIdOptions): Promise<BooleanResult>;
disconnect(options: DeviceIdOptions): Promise<void>;
disconnect(options: DeviceIdOptions & TimeoutOptions): Promise<void>;
getServices(options: DeviceIdOptions): Promise<BleServices>;
discoverServices(options: DeviceIdOptions): Promise<void>;
getMtu(options: DeviceIdOptions): Promise<GetMtuResult>;
Expand Down