Flutter教程

Bluetooth Serial

Contents

This plugin enables serial communication over Bluetooth. It was written for communicating between Android or iOS and an Arduino (not Android to Android or iOS to iOS).

https://github.com/don/BluetoothSerial

联系我们?

If you're building a serious project, you can't afford to spend hours troubleshooting. Ionic's experts offer official maintenance, support, and integration help.

Contact Us Today!

Ionic 蓝牙 Bluetooth Serial插件的安装(Installation)

ionic cordova plugin add cordova-plugin-bluetooth-serial npm install @ionic-native/bluetooth-serial
Ionic EE comes with fully supported and maintained plugins from the Ionic Team. Learn More or Contact Us
ionic enterprise register --key=YOURPRODUCTKEY npm install @ionic-enterprise/bluetooth-serial

Ionic 蓝牙 Bluetooth Serial插件支持的平台(Supported Platforms)

  • Android
  • iOS
  • Windows Phone 8

Ionic 蓝牙 Bluetooth Serial插件的用法(Usage)

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

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);