Skip to content

Commit

Permalink
feat(bluetooth-le): Allow specifying transport mode for Android (#3571)
Browse files Browse the repository at this point in the history
  • Loading branch information
EinfachHans authored Nov 19, 2020
1 parent 68d245e commit b3d5baa
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions src/@ionic-native/plugins/bluetooth-le/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,38 @@ export interface RespondParams {
offset?: number;
}

export interface ConnectionParams {
/** The address/identifier provided by the scan's return object */
address: string;
/** Automatically connect as soon as the remote device becomes available (Android) */
autoConnect?: boolean;
/**
* Transport mode. Available from API 23 (Android).
* If none is specified the default behavior is TRANSPORT_AUTO
*
* Note: On Android 10, TRANSPORT_AUTO can lead to connection errors with Status code 133.
* In this case TRANSPORT_LE can be used.
*/
transport?: AndroidGattTransportMode;
}

export enum AndroidGattTransportMode {
/**
* No preference of physical transport for GATT connections to remote dual-mode devices
*/
TRANSPORT_AUTO = 0,

/**
* Prefer BR/EDR transport for GATT connections to remote dual-mode devices
*/
TRANSPORT_BREDR = 1,

/**
* Prefer LE transport for GATT connections to remote dual-mode devices
*/
TRANSPORT_LE = 2,
}

export interface CharacteristicParams extends Params {
/** An array of characteristic IDs to discover or empty array / null */
characteristics?: string[];
Expand Down Expand Up @@ -543,15 +575,15 @@ export class BluetoothLE extends IonicNativePlugin {
* Connect to a Bluetooth LE device
* @param connectSuccess The success callback that is passed with device object
* @param connectError The callback that will be triggered when the connect operation fails
* @param params The address/identifier
* @param params The connection params
*
* @param {{address: string, autoConnect: boolean}} params
* @param {ConnectionParams} params
* @returns {(Observable<{ status: DeviceInfo }>)}
* success: device object with status
* error: The callback that will be triggered when the unbond operation fails
*/
@Cordova({ callbackOrder: 'reverse', observable: true })
connect(params: { address: string; autoConnect?: boolean }): Observable<DeviceInfo> {
connect(params: ConnectionParams): Observable<DeviceInfo> {
return;
}

Expand Down

0 comments on commit b3d5baa

Please sign in to comment.