Commit 3c281c51 authored by martin hou's avatar martin hou

fix: 增加定时扫描测试

parent eba1e99a
......@@ -37,7 +37,6 @@ export const Logger = {
},
save(module: string, procedure: string, message: any) { },
_append(level: Level, module: string, procedure: string, message: string) {
return;
let log = {
level,
module,
......
......@@ -75,13 +75,11 @@ export function Home() {
// 创建日志更新定时器
const logUpdateInterval = setInterval(() => {
/*
let last = Logger.messages.slice(-500).reverse();
let logStr: string[] = last.map((item) => {
return `[${item.level === 'error' ? 'x' : '*'}] [${new Date(item.time).toLocaleString()}] (${item.module} - ${item.procedure}) ${item.message}`;
});
setLogs(logStr);
*/
}, 1000);
// 清理函数
......@@ -125,6 +123,26 @@ export function Home() {
setGreeting('scanning...');
}
const scanBluetooth = async () => {
let jensen = getJensen();
if (jensen == null) return;
const scan = async () => {
await jensen.startBluetoothScan(10, 5);
await sleep(5000);
await jensen.stopBluetoothScan(5);
let devices = await jensen.getScanResults(5);
console.log(devices);
if (devices == null)
{
Logger.error('jensen', 'bluetooth', 'no scan results.');
}
else setDevices(devices);
setTimeout(scan, 5000);
};
scan();
}
const stopBluetoothScan = async () => {
let jensen = getJensen();
if (jensen == null) return;
......@@ -176,7 +194,7 @@ export function Home() {
const clsBleDevice: React.CSSProperties = {
height: '40px',
lineHeight: '40px',
minWidth: '500px',
minWidth: '100%',
position: 'relative',
display: 'inline-block'
}
......@@ -617,6 +635,7 @@ export function Home() {
<button onClick={bluetoothScan}>Start Scan</button>
<button onClick={stopBluetoothScan}>Stop Scan</button>
<button onClick={getScanResults}>Scan Results</button>
<button onClick={scanBluetooth}>Scan</button>
<button onClick={getPairedDevices}>Paired Devices</button>
<button onClick={clearPairedDevices}>Clear Paired</button>
{
......@@ -679,7 +698,7 @@ export function Home() {
})}
</ol>
</div>
<div style={{ padding: '0px 0px 0px 30px', width: '500px' }}>
<div style={{ padding: '0px 0px 0px 30px', width: '800px' }}>
<h3>Bluetooth Device List: </h3>
{
greeting ? <div>{greeting}</div> : <></>
......
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