Commit 26be443f authored by martin hou's avatar martin hou

fix: 增加scanning/connecting的设备状态识别

parent eb2facdd
......@@ -247,6 +247,11 @@ export function Home() {
else alert('what the fuck????');
}
const getPairedDevices = async () => {
let devices = await jensen.getPairedDevices();
alert(JSON.stringify(devices));
}
return (
<>
<div style={{ display: 'flex', flexDirection: 'row', gap: '16px', padding: '16px', alignItems: 'center', flexWrap: 'wrap' }}>
......@@ -261,6 +266,7 @@ export function Home() {
<button onClick={getBluetoothStatus}>蓝牙连接状态</button>
<button onClick={bluetoothScan}>蓝牙扫描</button>
<button onClick={disconnectBTDevice}>蓝牙断开</button>
<button onClick={getPairedDevices}>Paired</button>
<button onClick={readFilePartial}>Read File Partial</button>
<button onClick={updateDeviceTone}>更新提示音</button>
<button onClick={updateUAC}>更新UAC</button>
......
......@@ -1546,6 +1546,8 @@ Jensen.registerHandler(BLUETOOTH_STATUS, (msg) => {
if (msg.body.length == 0) return { status: 'disconnected' };
let status = msg.body[0];
if (status == 1) return { status: 'disconnected' };
if (status == 2) return { status: 'scanning' };
if (status == 3) return { status: 'connecting' };
let flen = ((msg.body[1] & 0xff) << 8) | (msg.body[2] & 0xff);
let decoder = new TextDecoder('UTF-8');
let sname = new Uint8Array(flen);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment