Commit 1d2ac0d5 authored by martin hou's avatar martin hou

增加对Eason Mini的识别,以及增加了文件传输时长的计算

parent 6dfa7138
......@@ -146,6 +146,25 @@ export function Home() {
xhr.send();
}
let filename = '';
let filelength = 0;
const transferFile = async () => {
if (files == null || files.length == 0) return alert('请先点击List Files');
let idx = prompt('请输入需要获取的文件序号(从0开始):', '0');
if (idx === undefined || idx === null) return;
let num = parseInt(idx);
if (isNaN(num) || num < 0 || num >= files.length) return alert('请输入正确的序号');
let file = files[num];
filename = file.name;
filelength = file.length;
get_file();
}
const get_file = () => {
jensen.getFile(filename, filelength, function() {}, function() {});
}
return (
<>
<div style={{ display: 'flex', flexDirection: 'row', gap: '16px', padding: '16px', alignItems: 'center' }}>
......@@ -159,6 +178,7 @@ export function Home() {
Get Time
</button>
<button style={{ width: '200px', height: '50px' }} onClick={listFiles}>List Files</button>
<button style={{ width: '200px', height: '50px' }} onClick={transferFile}>Transfer File</button>
<button style={{ width: '200px', height: '50px' }} onClick={getBluetoothStatus}>蓝牙连接状态</button>
<button style={{ width : '200px', height : '50px' }} onClick={bluetoothScan}>蓝牙扫描</button>
<button style={{ width : '200px', height : '50px' }} onClick={disconnectBTDevice}>蓝牙断开</button>
......
......@@ -136,7 +136,7 @@ function Jensen(log) {
? 'hidock-h1e'
: device.productId == 0xb00e
? 'hidock-p1'
: 'unknown';
: device.productId == 0xb00f ? 'hidock-p1:mini' : 'unknown';
} catch (e) {
Logger.error('jensen', 'setup', String(e));
}
......@@ -324,7 +324,7 @@ function Jensen(log) {
if (device)
device.transferIn(2, RECV_BUFF_SIZE).then((r) => {
Logger.save?.('jensen', 'tryReceive', r?.data);
console.log('Receive', r?.data);
// console.log('Receive', r?.data);
receive(r);
});
};
......@@ -883,7 +883,7 @@ Jensen.prototype.getFile = async function (filename, length, ondata, onprogress)
// visibilitychange();
// document.addEventListener('visibilitychange', visibilitychange);
let stime = new Date();
let flen = 0;
let handler = (msg) => {
if (msg != null) {
......@@ -892,7 +892,8 @@ Jensen.prototype.getFile = async function (filename, length, ondata, onprogress)
// Logger.info('jensen', 'getFile length', `${length} ${flen}`);
if (flen >= length) {
// document.removeEventListener('visibilitychange', visibilitychange);
Logger.info('jensen', 'getFile', 'file transfer finish.');
let cost = new Date().getTime() - stime.getTime();
Logger.info('jensen', 'getFile', 'file transfer finish, cost: ' + cost + ' ms');
// clearEventAndTask();
// return OK indicates all file blocks received
return 'OK';
......
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