1 Star 0 Fork 3

BossDing-2020 / BTPrinter

forked from 山野羡民 / BTPrinter 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 1.09 KB
一键复制 编辑 原始数据 按行查看 历史
山野羡民 提交于 2019-11-10 01:04 . 更新JS方法说明

JS调用原生方法

显示消息短提示:

Bluetooth.showToast('提示语');

显示消息对话框:

Bluetooth.showAlert('提示语');

显示/关闭等待对话框:

Bluetooth.showProgress('提示语');
Bluetooth.closeProgress();

检查蓝牙是否开启:

if (Bluetooth.isBluetoothEnabled()) {
    Bluetooth.showToast('蓝牙已打开');
} else {
    Bluetooth.showToast('蓝牙未打开');
}

开启蓝牙:

Bluetooth.enableBluetooth();

关闭蓝牙:

Bluetooth.disableBluetooth();

打开蓝牙设置(配对):

Bluetooth.openBluetoothSettings();

获取已配对蓝牙设备:

var json = Bluetooth.getPairedDevice();
Bluetooth.showAlert(json);
[{"address":"DC:0D:30:60:A1:F3","name":"Printer001"},{"address":"54:DC:1D:57:7D:57","name":"cool1 dual"},{"address":"E4:F8:9C:66:5A:B6","name":"LIYUJIANG"}]

连接蓝牙打印机:

Bluetooth.connectPrinter('DC:0D:30:60:A1:F3');

打印测试:

var json = '{}';
Bluetooth.printPaper(json);
Android
1
https://gitee.com/BossDing/BTPrinter.git
git@gitee.com:BossDing/BTPrinter.git
BossDing
BTPrinter
BTPrinter
master

搜索帮助