mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-02-01 02:53:03 +08:00
fix(ble): change signature for autoConnect (#2594)
* fix(ble): change signature for autoConnect (#2573) * fix(ble): update usage for autoConnect (#2573)
This commit is contained in:
parent
12ddf96705
commit
d95a359719
@ -290,25 +290,34 @@ export class BLE extends IonicNativePlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Establish an automatic connection to a peripheral.
|
* Establish an automatic connection to a peripheral. The phone will automatically connect to the Bluetooth peripheral
|
||||||
|
* whenever it is in range. The autoConnect function uses callbacks instead of observables because connect and
|
||||||
|
* disconnect can each be called many times as a devices connects and disconnects.
|
||||||
|
*
|
||||||
|
* On Android you can pass a MAC address directly to autoConnect. With iOS, you need to get a device id by scanning,
|
||||||
|
* calling ble.peripheralsWithIdentifiers, or calling ble.connectedPeripheralsWithServices.
|
||||||
|
*
|
||||||
* @usage
|
* @usage
|
||||||
* ```
|
* ```
|
||||||
* BLE.autoConnect('12:34:56:78:9A:BC').subscribe(peripheralData => {
|
* someFunction() {
|
||||||
* console.log(peripheralData);
|
* this.ble.autoConnect(deviceId, onConnected.bind(this), onDisconnected.bind(this));
|
||||||
* },
|
* }
|
||||||
* peripheralData => {
|
*
|
||||||
* console.log('disconnected');
|
* onConnected(peripheral) {
|
||||||
* });
|
* console.log(`Connected to ${peripheral.id}`)l
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* onDisconnected(peripheral) {
|
||||||
|
* console.log(`Disconnected from ${peripheral.id}`)l
|
||||||
|
* }
|
||||||
|
*
|
||||||
* ```
|
* ```
|
||||||
* @param {string} deviceId UUID or MAC address of the peripheral
|
* @param {string} deviceId UUID or MAC address of the peripheral
|
||||||
* @return {Observable<any>} Returns an Observable that notifies of connect/disconnect.
|
* @param {function} connectCallback function that is called with peripheral data when the devices connects
|
||||||
|
* @param {function} disconnectCallback function that is called with peripheral data when the devices disconnects
|
||||||
*/
|
*/
|
||||||
@Cordova({
|
@Cordova({ sync: true })
|
||||||
observable: true,
|
autoConnect(deviceId: string, connectCallback: any, disconnectCallback: any) {
|
||||||
clearFunction: 'disconnect',
|
|
||||||
clearWithArgs: true
|
|
||||||
})
|
|
||||||
autoConnect(deviceId: string): Observable<any> {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user