ionic-native
Version:
Native plugin wrappers for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support
263 lines • 9.51 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { Cordova, Plugin } from './plugin';
/**
* @name Bluetooth Serial
* @description This plugin enables serial communication over Bluetooth. It was written for communicating between Android or iOS and an Arduino.
* @usage
* ```typescript
* import { BluetoothSerial } from 'ionic-native';
*
*
* // Write a string
* BluetoothSerial.write("hello world").then(success, failure);
*
* // Array of int or bytes
* BluetoothSerial.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;
* BluetoothSerial.write(data).then(success, failure);
*
* // Array Buffer
* BluetoothSerial.write(data.buffer).then(success, failure);
* ```
*/
export var BluetoothSerial = (function () {
function BluetoothSerial() {
}
/**
* Connect to a Bluetooth device
* @param {string} macAddress_or_uuid Identifier of the remote device
* @returns {Observable<any>} Subscribe to connect, unsubscribe to disconnect.
*/
BluetoothSerial.connect = function (macAddress_or_uuid) { return; };
/**
* Connect insecurely to a Bluetooth device
* @param {string} macAddress Identifier of the remote device
* @returns {Observable<any>} Subscribe to connect, unsubscribe to disconnect.
*/
BluetoothSerial.connectInsecure = function (macAddress) { return; };
/**
* Disconnect from the connected device
* @returns {Promise<any>}
*/
BluetoothSerial.disconnect = function () { return; };
/**
* Writes data to the serial port
* @param {any} data ArrayBuffer of data
* @returns {Promise<any>} returns a promise when data has been written
*/
BluetoothSerial.write = function (data) { return; };
/**
* Gets the number of bytes of data available
* @returns {Promise<any>} returns a promise that contains the available bytes
*/
BluetoothSerial.available = function () { return; };
/**
* Reads data from the buffer
* @returns {Promise<any>} returns a promise with data from the buffer
*/
BluetoothSerial.read = function () { return; };
/**
* Reads data from the buffer until it reaches a delimiter
* @param {string} delimiter string that you want to search until
* @returns {Promise<any>} returns a promise
*/
BluetoothSerial.readUntil = function (delimiter) { return; };
/**
* Subscribe to be notified when data is received
* @param {string} delimiter the string you want to watch for
* @returns {Observable<any>} returns an observable.
*/
BluetoothSerial.subscribe = function (delimiter) { return; };
/**
* Subscribe to be notified when data is received
* @returns {Observable<any>} returns an observable
*/
BluetoothSerial.subscribeRawData = function () { return; };
/**
* Clears data in buffer
* @returns {Promise<any>} returns a promise when completed
*/
BluetoothSerial.clear = function () { return; };
/**
* Lists bonded devices
* @returns {Promise<any>} returns a promise
*/
BluetoothSerial.list = function () { return; };
/**
* Reports if bluetooth is enabled
* @returns {Promise<any>} returns a promise
*/
BluetoothSerial.isEnabled = function () { return; };
/**
* Reports the connection status
* @returns {Promise<any>} returns a promise
*/
BluetoothSerial.isConnected = function () { return; };
/**
* Reads the RSSI from the connected peripheral
* @returns {Promise<any>} returns a promise
*/
BluetoothSerial.readRSSI = function () { return; };
/**
* Show the Bluetooth settings on the device
* @returns {Promise<any>} returns a promise
*/
BluetoothSerial.showBluetoothSettings = function () { return; };
/**
* Enable Bluetooth on the device
* @returns {Promise<any>} returns a promise
*/
BluetoothSerial.enable = function () { return; };
/**
* Discover unpaired devices
* @returns {Promise<any>} returns a promise
*/
BluetoothSerial.discoverUnpaired = function () { return; };
/**
* Subscribe to be notified on Bluetooth device discovery. Discovery process must be initiated with the `discoverUnpaired` function.
* @returns {Observable<any>} Returns an observable
*/
BluetoothSerial.setDeviceDiscoveredListener = function () { return; };
/**
* Sets the human readable device name that is broadcasted to other devices
* @param {string} newName Desired name of device
*/
BluetoothSerial.setName = function (newName) { };
/**
* Makes the device discoverable by other devices
* @param {number} discoverableDuration Desired number of seconds device should be discoverable for
*/
BluetoothSerial.setDiscoverable = function (discoverableDuration) { };
__decorate([
Cordova({
platforms: ['Android', 'iOS', 'Windows Phone'],
observable: true,
clearFunction: 'disconnect'
})
], BluetoothSerial, "connect", null);
__decorate([
Cordova({
platforms: ['Android'],
observable: true,
clearFunction: 'disconnect'
})
], BluetoothSerial, "connectInsecure", null);
__decorate([
Cordova()
], BluetoothSerial, "disconnect", null);
__decorate([
Cordova({
platforms: ['Android', 'iOS', 'Windows Phone']
})
], BluetoothSerial, "write", null);
__decorate([
Cordova({
platforms: ['Android', 'iOS', 'Windows Phone']
})
], BluetoothSerial, "available", null);
__decorate([
Cordova({
platforms: ['Android', 'iOS', 'Windows Phone']
})
], BluetoothSerial, "read", null);
__decorate([
Cordova({
platforms: ['Android', 'iOS', 'Windows Phone']
})
], BluetoothSerial, "readUntil", null);
__decorate([
Cordova({
platforms: ['Android', 'iOS', 'Windows Phone'],
observable: true,
clearFunction: 'unsubscribe'
})
], BluetoothSerial, "subscribe", null);
__decorate([
Cordova({
platforms: ['Android', 'iOS', 'Windows Phone'],
observable: true,
clearFunction: 'unsubscribeRawData'
})
], BluetoothSerial, "subscribeRawData", null);
__decorate([
Cordova({
platforms: ['Android', 'iOS', 'Windows Phone']
})
], BluetoothSerial, "clear", null);
__decorate([
Cordova({
platforms: ['Android', 'iOS', 'Windows Phone']
})
], BluetoothSerial, "list", null);
__decorate([
Cordova({
platforms: ['Android', 'iOS', 'Windows Phone']
})
], BluetoothSerial, "isEnabled", null);
__decorate([
Cordova({
platforms: ['Android', 'iOS', 'Windows Phone']
})
], BluetoothSerial, "isConnected", null);
__decorate([
Cordova({
platforms: ['Android', 'iOS', 'Windows Phone']
})
], BluetoothSerial, "readRSSI", null);
__decorate([
Cordova({
platforms: ['Android', 'iOS', 'Windows Phone']
})
], BluetoothSerial, "showBluetoothSettings", null);
__decorate([
Cordova({
platforms: ['Android', 'iOS', 'Windows Phone']
})
], BluetoothSerial, "enable", null);
__decorate([
Cordova({
platforms: ['Android', 'iOS', 'Windows Phone']
})
], BluetoothSerial, "discoverUnpaired", null);
__decorate([
Cordova({
platforms: ['Android', 'iOS', 'Windows Phone'],
observable: true,
clearFunction: 'clearDeviceDiscoveredListener'
})
], BluetoothSerial, "setDeviceDiscoveredListener", null);
__decorate([
Cordova({
platforms: ['Android'],
sync: true
})
], BluetoothSerial, "setName", null);
__decorate([
Cordova({
platforms: ['Android'],
sync: true
})
], BluetoothSerial, "setDiscoverable", null);
BluetoothSerial = __decorate([
Plugin({
pluginName: 'BluetoothSerial',
repo: 'https://github.com/don/BluetoothSerial',
plugin: 'cordova-plugin-bluetooth-serial',
pluginRef: 'bluetoothSerial',
platforms: ['Android', 'iOS', 'Windows Phone', 'Browser']
})
], BluetoothSerial);
return BluetoothSerial;
}());
//# sourceMappingURL=bluetoothserial.js.map