Ionic Bluetooth Serial


Ionic Bluetooth Serial – This plugin is basically used to establish serial communication over bluetooth.


Ionic Bluetooth Serial Native Plugin Example

Installation

Below command is used to install the bluetooth serial plugin-

Ionic Bluetooth Serial Native Plugin Installation:

$ ionic cordova plugin add cordova-plugin-bluetooth-serial
$ npm install --save @ionic-native/bluetooth-serial

Supported Platforms

  • Windows 8
  • Android
  • iOS

Example

| Example:

import { BluetoothSerial } from '@ionic-native/bluetooth-serial';

constructor(private bluetoothSerial: BluetoothSerial) { }


// Write a string
this.bluetoothSerial.write('hello world').then(success, failure);

// Array of int or bytes
this.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;
this.bluetoothSerial.write(data).then(success, failure);

// Array Buffer
this.bluetoothSerial.write(data.buffer).then(success, failure);

Instance Members

  • connect(macAddress_or_uuid)
  • connectInsecure(macAddress)
  • disconnect()
  • write()
  • available()
  • read()
  • readUntil(delimiter)
  • subscribe(delimiter)
  • subscribeRawData()
  • clear()
  • list()
  • isEnabled()
  • isEnabled()
  • isConnected()
  • readRSSI()
  • showBluetoothSettings()
  • enable()
  • discoverUnpaired()
  • setDeviceDiscoveredListener()
  • setName(newName)
  • setDiscoverable(discoverableDuration)

Advertisements

Add Comment

📖 Read More