mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-02-21 00:23:00 +08:00
parent
c8f8d6ac52
commit
837fb95a8a
@ -14,6 +14,7 @@ import {BarcodeScanner} from './plugins/barcodescanner';
|
||||
import {Base64ToGallery} from './plugins/base64togallery';
|
||||
import {BatteryStatus} from './plugins/batterystatus';
|
||||
import {BLE} from './plugins/ble';
|
||||
import {BluetoothSerial} from './plugins/bluetoothserial';
|
||||
import {Calendar} from './plugins/calendar';
|
||||
import {Camera} from './plugins/camera';
|
||||
import {Clipboard} from './plugins/clipboard';
|
||||
@ -61,6 +62,7 @@ export {
|
||||
Base64ToGallery,
|
||||
BatteryStatus,
|
||||
BLE,
|
||||
BluetoothSerial,
|
||||
Calendar,
|
||||
Camera,
|
||||
Clipboard,
|
||||
@ -113,6 +115,7 @@ window['IonicNative'] = {
|
||||
Base64ToGallery: Base64ToGallery,
|
||||
BatteryStatus: BatteryStatus,
|
||||
BLE: BLE,
|
||||
BluetoothSerial: BluetoothSerial,
|
||||
Calendar: Calendar,
|
||||
Camera: Camera,
|
||||
Clipboard: Clipboard,
|
||||
|
226
src/plugins/bluetoothserial.ts
Normal file
226
src/plugins/bluetoothserial.ts
Normal file
@ -0,0 +1,226 @@
|
||||
import {Plugin, Cordova} from './plugin';
|
||||
import {Observable} from "rxjs/Observable";
|
||||
|
||||
/**
|
||||
* @name Bluetooth Serial
|
||||
* @description This plugin enables serial communication over Bluetooth. It was written for communicating between Android or iOS and an Arduino.
|
||||
* @usage
|
||||
*/
|
||||
@Plugin({
|
||||
repo: 'https://github.com/don/BluetoothSerial',
|
||||
plugin: 'cordova-plugin-bluetooth-serial',
|
||||
pluginRef: '',
|
||||
platforms: ['Android','iOS','Windows Phone','Browser']
|
||||
})
|
||||
export class BluetoothSerial {
|
||||
|
||||
/**
|
||||
* Connect to a Bluetooth device
|
||||
* @param macAddress_or_uuid Identifier of the remote device
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android','iOS','Windows Phone']
|
||||
})
|
||||
static connect (macAddress_or_uuid : string) : Promise<any> {return}
|
||||
|
||||
/**
|
||||
* Connect insecurely to a Bluetooth device
|
||||
* @param macAddress Identifier of the remote device
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android']
|
||||
})
|
||||
static connectInsecure (macAddress : string) : Promise<any> {return}
|
||||
|
||||
/**
|
||||
* Disconnect
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android','iOS','Windows Phone']
|
||||
})
|
||||
static disconnect () : Promise<any> {return}
|
||||
|
||||
/**
|
||||
* Writes data to the serial port
|
||||
* @param data ArrayBuffer of data
|
||||
* @usage
|
||||
* ```ts
|
||||
* // Write a string
|
||||
* Bluetooth.write("hello world").then(success, failure);
|
||||
*
|
||||
* // Array of int or bytes
|
||||
* Bluetooth.write([186, 220, 222]).then(success, failure);
|
||||
*
|
||||
* // Typed Array
|
||||
* var data = new Uint8Array(4);
|
||||
* data[0] = 0x41;
|
||||
* data[1] = 0x42;
|
||||
* data[2] = 0x43;
|
||||
* data[3] = 0x44;
|
||||
* Bluetooth.write(data).then(success, failure);
|
||||
*
|
||||
* // Array Buffer
|
||||
* Bluetooth.write(data.buffer).then(success, failure);
|
||||
* ```
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS','Windows Phone']
|
||||
})
|
||||
static write (data : any) : Promise<any> {return}
|
||||
|
||||
/**
|
||||
* Gets the number of bytes of data available
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS','Windows Phone']
|
||||
}) static available () : Promise<any> {return}
|
||||
|
||||
/**
|
||||
* Reads data from the buffer
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS','Windows Phone']
|
||||
})
|
||||
static read () : Promise<any> {return}
|
||||
|
||||
/**
|
||||
* Reads data from the buffer until it reaches a delimiter
|
||||
* @param delimiter
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS','Windows Phone']
|
||||
})
|
||||
static readUntil (delimiter : string) : Promise<any> {return}
|
||||
|
||||
/**
|
||||
* Subscribe to be notified when data is received
|
||||
* @param delimiter
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS','Windows Phone'],
|
||||
observable: true,
|
||||
clearFunction: 'unsubscribe'
|
||||
})
|
||||
static subscribe (delimiter : string) : Observable<any> {return}
|
||||
|
||||
/**
|
||||
* Subscribe to be notified when data is received
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS','Windows Phone'],
|
||||
observable: true,
|
||||
clearFunction: 'unsubscribeRawData'
|
||||
})
|
||||
static subscribeRawData () : Observable<any> {return}
|
||||
|
||||
/**
|
||||
* Clears data in buffer
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS','Windows Phone']
|
||||
})
|
||||
static clear () : Promise<any> {return}
|
||||
|
||||
/**
|
||||
* Lists bonded devices
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS','Windows Phone']
|
||||
})
|
||||
static list () : Promise<any> {return}
|
||||
|
||||
/**
|
||||
* Reports if bluetooth is enabled
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS','Windows Phone']
|
||||
})
|
||||
static isEnabled () : Promise<any> {return}
|
||||
|
||||
/**
|
||||
* Reports the connection status
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS','Windows Phone']
|
||||
})
|
||||
static isConnected () : Promise<any> {return}
|
||||
|
||||
/**
|
||||
* Reads the RSSI from the connected peripheral
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS','Windows Phone']
|
||||
})
|
||||
static readRSSI () : Promise<any> {return}
|
||||
|
||||
/**
|
||||
* Show the Bluetooth settings on the device
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS','Windows Phone']
|
||||
})
|
||||
static showBluetoothSettings () : Promise<any> {return}
|
||||
|
||||
/**
|
||||
* Enable Bluetooth on the device
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS','Windows Phone']
|
||||
})
|
||||
static enable () : Promise<any> {return}
|
||||
|
||||
/**
|
||||
* Discover unpaired devices
|
||||
* @usage
|
||||
* ```ts
|
||||
* [{
|
||||
* "class": 276,
|
||||
* "id": "10:BF:48:CB:00:00",
|
||||
* "address": "10:BF:48:CB:00:00",
|
||||
* "name": "Nexus 7"
|
||||
* }, {
|
||||
* "class": 7936,
|
||||
* "id": "00:06:66:4D:00:00",
|
||||
* "address": "00:06:66:4D:00:00",
|
||||
* "name": "RN42"
|
||||
* }]
|
||||
* ```
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS','Windows Phone']
|
||||
})
|
||||
static discoverUnpaired () : Promise<any> {return}
|
||||
|
||||
/**
|
||||
* Subscribe to be notified on Bluetooth device discovery. Discovery process must be initiated with the `discoverUnpaired` function.
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS','Windows Phone'],
|
||||
observable: true,
|
||||
clearFunction: 'clearDeviceDiscoveredListener'
|
||||
})
|
||||
static setDeviceDiscoveredListener () : Observable<any> {return}
|
||||
|
||||
/**
|
||||
* Sets the human readable device name that is broadcasted to other devices
|
||||
* @param newName Desired name of device
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android'],
|
||||
sync: true
|
||||
})
|
||||
static setName (newName : string) : void {}
|
||||
|
||||
/**
|
||||
* Makes the device discoverable by other devices
|
||||
* @param discoverableDuration Desired number of seconds device should be discoverable for
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android'],
|
||||
sync: true
|
||||
})
|
||||
static setDiscoverable (discoverableDuration : number) : void {}
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user