From 03e6afbad40ed32c186c92af6b080c7b4b70aaeb Mon Sep 17 00:00:00 2001 From: Domvel <35452565+Domvel@users.noreply.github.com> Date: Wed, 13 Jun 2018 20:05:05 +0200 Subject: [PATCH] feat(ble): update wrapper to match latest plugin release (#2548) feat(ble): update wrapper to match latest plugin release --- src/@ionic-native/plugins/ble/index.ts | 65 ++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/src/@ionic-native/plugins/ble/index.ts b/src/@ionic-native/plugins/ble/index.ts index d108e2df4..11a42989e 100644 --- a/src/@ionic-native/plugins/ble/index.ts +++ b/src/@ionic-native/plugins/ble/index.ts @@ -289,6 +289,71 @@ export class BLE extends IonicNativePlugin { return; } + /** + * Establish an automatic connection to a peripheral. + * @usage + * ``` + * BLE.autoConnect('12:34:56:78:9A:BC').subscribe(peripheralData => { + * console.log(peripheralData); + * }, + * peripheralData => { + * console.log('disconnected'); + * }); + * ``` + * @param {string} deviceId UUID or MAC address of the peripheral + * @return {Observable} Returns an Observable that notifies of connect/disconnect. + */ + @Cordova({ + observable: true, + clearFunction: 'disconnect', + clearWithArgs: true + }) + autoConnect(deviceId: string): Observable { + return; + } + + /** + * Request MTU size. + * May be used to fix the Error 14 "Unlikely" on write requests with more than 20 bytes. + * @usage + * ``` + * BLE.requestMtu('12:34:56:78:9A:BC', 512).then(() => { + * console.log('MTU Size Accepted'); + * }, error => { + * console.log('MTU Size Failed'); + * }); + * ``` + * @param {string} deviceId UUID or MAC address of the peripheral + * @param {number} mtuSize The new MTU size. (23 - 517, default is usually 23. Max recommended: 512) + * @return {Promise} Returns a Promise. + */ + @Cordova() + requestMtu(deviceId: string, mtuSize: number): Promise { + return; + } + + /** + * Refresh Device Cache + * This method may fix a issue of old cached services and characteristics. + * NOTE Since this uses an undocumented API it's not guaranteed to work. + * If you choose a too low delay time (timeoutMillis) the method could fail. + * @usage + * ``` + * BLE.refreshDeviceCache('12:34:56:78:9A:BC', 10000).then(discoveredServices => { + * console.log('The new discovered services after the clean: ', discoveredServices); + * }, error => { + * console.log('Refresh device cache failed.'); + * }); + * ``` + * @param {string} deviceId UUID or MAC address of the peripheral + * @param {number} timeoutMillis Delay in milliseconds after refresh before discovering services. + * @return {Promise} Returns a Promise. + */ + @Cordova() + refreshDeviceCache(deviceId: string, timeoutMillis: number): Promise { + return; + } + /** * Disconnect from a peripheral. * @usage