fix(ble): fix definitions (#2974)

* Fix bad definitions in blueooth-le module in initialize and enable funcions

* Fix MATCH_MODE_AGGRESSIVE

* Fix startScan return

* Fix connect return

* Fix rssi function return type

* Fix disconnect return.
Fix close return.
Fix discover return.
Fix services return.
Fix mtu return.
This commit is contained in:
Julián Mesa Llopis 2019-04-07 19:09:22 +02:00 committed by Daniel Sogl
parent c75aeb9c39
commit 6a19509ded

View File

@ -431,20 +431,20 @@ export class BluetoothLE extends IonicNativePlugin {
* @name initialize * @name initialize
* Initialize Bluetooth on the device * Initialize Bluetooth on the device
* @param {InitParams} [params] * @param {InitParams} [params]
* @returns {(Promise<{ status: 'enabled' | 'disabled'}>)} The callback that is passed initialize status (enabled/disabled) * @returns {(Observable<{ status: 'enabled' | 'disabled'}>)} The callback that is passed initialize status (enabled/disabled)
*/ */
@Cordova({ callbackOrder: 'reverse' }) @Cordova({ successIndex: 0, errorIndex: 2, observable: true })
initialize(params?: InitParams): Promise<{ status: 'enabled' | 'disabled' }> { initialize(params?: InitParams): Observable<{ status: 'enabled' | 'disabled' }> {
return; return;
} }
/** /**
* @name enable (Android) * @name enable (Android)
* Enable Bluetooth on the device. Android support only * Enable Bluetooth on the device. Android support only
* @returns {Promise<{ status: boolean }>} * @returns void
*/ */
@Cordova({ callbackOrder: 'reverse', sync: true }) @Cordova({ callbackOrder: 'reverse', sync: true })
enable(): Promise<{ status: boolean }> { enable() {
return; return;
} }
@ -480,10 +480,10 @@ export class BluetoothLE extends IonicNativePlugin {
* Android API >= 23 also requires location services to be enabled. Use isLocationEnabled to determine whether location services are enabled. * Android API >= 23 also requires location services to be enabled. Use isLocationEnabled to determine whether location services are enabled.
* If not enabled, use requestLocation to prompt the location services settings page. * If not enabled, use requestLocation to prompt the location services settings page.
* @param {ScanParams} params Scan params * @param {ScanParams} params Scan params
* @returns {(Observable<{ status: ScanStatus }>)} * @returns {(Observable< ScanStatus >)}
*/ */
@Cordova({ callbackOrder: 'reverse', observable: true }) @Cordova({ callbackOrder: 'reverse', observable: true })
startScan(params: ScanParams): Observable<{ status: ScanStatus }> { startScan(params: ScanParams): Observable< ScanStatus > {
return; return;
} }
@ -559,7 +559,7 @@ export class BluetoothLE extends IonicNativePlugin {
connect(params: { connect(params: {
address: string; address: string;
autoConnect?: boolean; autoConnect?: boolean;
}): Observable<{ status: DeviceInfo }> { }): Observable< DeviceInfo > {
return; return;
} }
@ -579,10 +579,10 @@ export class BluetoothLE extends IonicNativePlugin {
* Disconnect from a Bluetooth LE device. * Disconnect from a Bluetooth LE device.
* Note: It's simpler to just call close(). Starting with iOS 10, disconnecting before closing seems required! * Note: It's simpler to just call close(). Starting with iOS 10, disconnecting before closing seems required!
* @param {{address: string}} params The address/identifier * @param {{address: string}} params The address/identifier
* @returns {Promise<{ status: DeviceInfo }>} * @returns {Promise<DeviceInfo>}
*/ */
@Cordova({ callbackOrder: 'reverse' }) @Cordova({ callbackOrder: 'reverse' })
disconnect(params: { address: string }): Promise<{ status: DeviceInfo }> { disconnect(params: { address: string }): Promise<DeviceInfo> {
return; return;
} }
@ -592,10 +592,10 @@ export class BluetoothLE extends IonicNativePlugin {
* Prior to 2.7.0, you needed to disconnect to the device before closing, but this is no longer the case. * Prior to 2.7.0, you needed to disconnect to the device before closing, but this is no longer the case.
* Starting with iOS 10, disconnecting before closing seems required! * Starting with iOS 10, disconnecting before closing seems required!
* @param {{ address: string }} params The address/identifier * @param {{ address: string }} params The address/identifier
* @returns {Promise<{ status: DeviceInfo }>} * @returns {Promise<DeviceInfo>}
*/ */
@Cordova({ callbackOrder: 'reverse' }) @Cordova({ callbackOrder: 'reverse' })
close(params: { address: string }): Promise<{ status: DeviceInfo }> { close(params: { address: string }): Promise<DeviceInfo> {
return; return;
} }
@ -609,7 +609,7 @@ export class BluetoothLE extends IonicNativePlugin {
* Subsequent discover events will make use of this cache. * Subsequent discover events will make use of this cache.
* If your device's services change, set the clearCache parameter to force Android to re-discover services. * If your device's services change, set the clearCache parameter to force Android to re-discover services.
* @param {{ address: string, clearCache: boolean }} params The address/identifier * @param {{ address: string, clearCache: boolean }} params The address/identifier
* @returns {Promise<{ device: Device }>} * @returns {Promise<Device>}
* success: device object (contains array of service objects) * success: device object (contains array of service objects)
* error: The callback that will be triggered when the unbond operation fails * error: The callback that will be triggered when the unbond operation fails
*/ */
@ -617,7 +617,7 @@ export class BluetoothLE extends IonicNativePlugin {
discover(params: { discover(params: {
address: string; address: string;
clearCache?: boolean; clearCache?: boolean;
}): Promise<{ device: Device }> { }): Promise<Device> {
return; return;
} }
@ -626,13 +626,13 @@ export class BluetoothLE extends IonicNativePlugin {
* Discover the device's services. * Discover the device's services.
* Not providing an array of services will return all services and take longer to discover. iOS support only. * Not providing an array of services will return all services and take longer to discover. iOS support only.
* @param {{address: string, services: string[]}} params * @param {{address: string, services: string[]}} params
* @returns {Promise<{ services: Services }>} * @returns {Promise<Services>}
*/ */
@Cordova({ callbackOrder: 'reverse' }) @Cordova({ callbackOrder: 'reverse' })
services(params: { services(params: {
address: string; address: string;
services?: string[]; services?: string[];
}): Promise<{ services: Services }> { }): Promise<Services> {
return; return;
} }
@ -747,10 +747,10 @@ export class BluetoothLE extends IonicNativePlugin {
* @name rssi * @name rssi
* Read RSSI of a connected device. RSSI is also returned with scanning. * Read RSSI of a connected device. RSSI is also returned with scanning.
* @param {{ address: string }} params * @param {{ address: string }} params
* @returns {Promise<{ rssi: RSSI }>} * @returns {Promise< RSSI >}
*/ */
@Cordova({ callbackOrder: 'reverse' }) @Cordova({ callbackOrder: 'reverse' })
rssi(params: { address: string }): Promise<{ rssi: RSSI }> { rssi(params: { address: string }): Promise< RSSI > {
return; return;
} }
@ -758,10 +758,10 @@ export class BluetoothLE extends IonicNativePlugin {
* @name mtu (Android, Android 5+) * @name mtu (Android, Android 5+)
* Set MTU of a connected device. Android only. * Set MTU of a connected device. Android only.
* @param {{ address: string, mtu: number }} params * @param {{ address: string, mtu: number }} params
* @returns {Promise<{ mtu: MTU }>} * @returns {Promise< MTU >}
*/ */
@Cordova({ callbackOrder: 'reverse' }) @Cordova({ callbackOrder: 'reverse' })
mtu(params: { address: string; mtu?: number }): Promise<{ mtu: MTU }> { mtu(params: { address: string; mtu?: number }): Promise< MTU > {
return; return;
} }
@ -1057,7 +1057,7 @@ export class BluetoothLE extends IonicNativePlugin {
@CordovaProperty() @CordovaProperty()
SCAN_MODE_LOW_LATENCY: number; SCAN_MODE_LOW_LATENCY: number;
@CordovaProperty() @CordovaProperty()
MATCH_MODE_AGRESSIVE: number; MATCH_MODE_AGGRESSIVE: number;
@CordovaProperty() @CordovaProperty()
MATCH_MODE_STICKY: number; MATCH_MODE_STICKY: number;
@CordovaProperty() @CordovaProperty()