问题描述
我有一个Web应用程序,可以打印到蓝牙热敏打印机。我设法连接到打印机并打印出我需要的东西。我想知道是否有一种方法可以将设备信息保存到会话或本地存储中,因此不需要用户每次都与设备配对。
我当前的代码如下:
const device = await navigator.bluetooth.requestDevice({
acceptAllDevices: true,optionalServices: [
'000018f0-0000-1000-8000-00805f9b34fb'
]
});
const server = await device.gatt.connect();
const service = await server.getPrimaryService("000018f0-0000-1000-8000-00805f9b34fb");
const characteristic = await service.getCharacteristic("00002af1-0000-1000-8000-00805f9b34fb");
想法是像这样:
const device = await navigator.bluetooth.connect(deviceId);
// using the device's ID or address,name or whatever information is available from the first pairing.
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)