Skip to main content

Bluetooth Classic Serial Port

This plugin is written using the iOS Accessory Framework (MFi) to support Classic Bluetooth on iOS.

https://github.com/MaximBelov/cordova-plugin-bluetooth-classic-serial-port

Stuck on a Cordova issue?

Don't waste precious time on plugin issues.

If you're building a serious project, you can't afford to spend hours troubleshooting. Ionic’s experts offer premium advisory services for both community plugins and premier plugins.

Installation#

$ npm install cordova-plugin-bluetooth-classic-serial-port $ npm install @ionic-native/bluetooth-classic-serial-port $ ionic cap sync

Supported Platforms#

  • Android
  • iOS
  • Browser

Usage#

React#

Learn more about using Ionic Native components in React

Angular#

import { BluetoothClassicSerialPort } from '@ionic-native/bluetooth-classic-serial-port/ngx';
constructor(private bluetoothClassicSerialPort: BluetoothClassicSerialPort) { }

// Write a stringthis.bluetoothClassicSerialPort.write("00001101-0000-1000-8000-00805F9B34FB", "hello, world", success, failure);
// Array of int or bytesthis.bluetoothClassicSerialPort.write("00001101-0000-1000-8000-00805F9B34FB", [186, 220, 222], success, failure);
// Typed Arrayvar data = new Uint8Array(4);data[0] = 0x41;data[1] = 0x42;data[2] = 0x43;data[3] = 0x44;this.bluetoothClassicSerialPort.write(interfaceId, data, success, failure);
// Array Bufferthis.bluetoothClassicSerialPort.write(interfaceId, data.buffer, success, failure);

// iOS select accessory

 async selectAccessory() {   const deviceDiscovery = this.bluetoothClassicSerialPort.setDeviceDiscoveredListener().subscribe(async (connectionConfig) => {     deviceDiscovery.unsubscribe();   })
   await this.bluetoothClassicSerialPort.discoverUnpaired().catch(error => {     deviceDiscovery.unsubscribe();   })
 }