cordova 调用蓝牙_Ionic4 蓝牙插件-蓝牙 Bluetooth Serial - Ionic Native

本文介绍了一个用于实现Android和iOS设备与Arduino之间串行通信的Cordova插件——Bluetooth Serial。内容包括Ionic蓝牙插件的安装步骤、支持的平台以及如何在代码中使用此插件进行数据写入操作。
摘要由CSDN通过智能技术生成

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

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

Community(社区版)Enterprise(企业版)

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值