Commit cf2eaa4b authored by martin hou's avatar martin hou

feat: 调整为英文版的测试页面

parent b9be3f07
......@@ -15,7 +15,7 @@ export function Home() {
jensen.onconnect = () => {
console.log('connect successfully');
jensen.addWakeupListener(function() {
console.log('从休眠中恢复过来了?');
console.log('Wake up from sleep?');
});
jensen.getDeviceInfo().then((info) => {
console.log('getDeviceInfo', info);
......@@ -65,7 +65,7 @@ export function Home() {
let jensen = new Jensen(Logger, conn);
jensen.onerror = (e) => {
console.log('onerror', e);
alert('此设备已经在其它已打开的HiNotes网页上建立连接');
alert('This device has already been connected to another HiNotes webpage');
};
await jensen.initialize();
let dinfo = await jensen.getDeviceInfo();
......@@ -131,20 +131,20 @@ export function Home() {
}
const readFilePartial = async() => {
if (files.length == 0) return alert('你没有录音文件,或是还没有查询过文件列表');
let s0 = prompt('请输入需要读取的文件序号,从0开始:', '0');
let s1 = prompt('请输入开始位置,从0开始:', '0');
let s2 = prompt('请输入读取字节数量', '32');
if (files.length == 0) return alert('You don\'t have any recording files, or you haven\'t queried the file list');
let s0 = prompt('Please Input the File Index (Start from 0):', '0');
let s1 = prompt('Please Input the Start Position (Start from 0):', '0');
let s2 = prompt('Please Input the Read Byte Count', '32');
if (s0 && s1 && s2) console.log();
else return;
let index = parseInt(s0);
let offset = parseInt(s1);
let length = parseInt(s2);
if (isNaN(index) && isNaN(offset) || isNaN(length)) return;
if (index >= files.length) return alert('请输入正确的文件序号');
if (index >= files.length) return alert('Please Input the Correct File Index');
let file = files[index];
if (offset < 0 || offset > file.length) return alert('请输入正确的读取开始位置');
if (length <= 0) return alert('请输入正确的文件读取长度');
if (offset < 0 || offset > file.length) return alert('Please Input the Correct Read Start Position');
if (length <= 0) return alert('Please Input the Correct Read Byte Count');
let data = await jensen.readFile(file.name, offset, length);
console.log(data);
}
......@@ -196,11 +196,11 @@ export function Home() {
let filename = '';
let filelength = 0;
const transferFile = async () => {
if (files == null || files.length == 0) return alert('请先点击List Files');
let idx = prompt('请输入需要获取的文件序号(从0开始):', '0');
if (files == null || files.length == 0) return alert('Please Click "List Files" first');
let idx = prompt('Please Input the File Index (Start from 0):', '0');
if (idx === undefined || idx === null) return;
let num = parseInt(idx);
if (isNaN(num) || num < 0 || num >= files.length) return alert('请输入正确的序号');
if (isNaN(num) || num < 0 || num >= files.length) return alert('Please Input the Correct Index');
let file = files[num];
// 2025Jun24-165914-Wip00.hda, 232704 @ 19392
filename = file.name;
......@@ -210,8 +210,15 @@ export function Home() {
}
const get_file = () => {
let recvBytes = 0;
let stime = new Date().getTime();
jensen.getFile(filename, filelength, function(data) {
// console.log('data', data.length);
recvBytes += data.length;
if (recvBytes >= filelength) {
let cost = new Date().getTime() - stime;
alert('File Transfer Complete, Cost: ' + cost + ' ms');
}
}, function(recvBytes) {
let percent = Math.floor(recvBytes / filelength * 100);
// console.log('progress', percent);
......@@ -219,7 +226,7 @@ export function Home() {
}
const writeSN = async () => {
let nsn = prompt('请输入新的SN号', '');
let nsn = prompt('Please Input the New SN:', '');
if (nsn && nsn.match(/^HD(H1|1E|P1|PM)\w{9}$/gi))
{
let rst = await jensen.writeSerialNumber(nsn);
......@@ -249,27 +256,22 @@ export function Home() {
await jensen.reconnect();
let rst = await jensen.getDeviceInfo();
if (rst) alert(rst.sn + ' reconnected...');
else alert('what the fuck????');
else alert('Something went wrong...');
}
return (
<>
<div style={{ display: 'flex', flexDirection: 'row', gap: '16px', padding: '16px', alignItems: 'center', flexWrap: 'wrap' }}>
<button onClick={connecty}>连接新设备</button>
<button onClick={connect}>连接</button>
<button onClick={getFilePart}>获取文件</button>
<button onClick={writeSN}>SN写号</button>
<button onClick={getTime}>获取时间</button>
<button onClick={listFiles}>文件列表</button>
<button onClick={transferFile}>传输文件</button>
<button onClick={batteryStatus}>电池电量</button>
<button onClick={getBluetoothStatus}>蓝牙连接状态</button>
<button onClick={bluetoothScan}>蓝牙扫描</button>
<button onClick={disconnectBTDevice}>蓝牙断开</button>
<button onClick={readFilePartial}>Read File Partial</button>
<button onClick={updateDeviceTone}>更新提示音</button>
<button onClick={updateUAC}>更新UAC</button>
<button onClick={test}>测试重连</button>
<button onClick={connecty}>Connect</button>
<button onClick={getTime}>Get Time</button>
<button onClick={listFiles}>List Files</button>
<button onClick={transferFile}>Transfer</button>
<button onClick={batteryStatus}>Battery</button>
<button onClick={getBluetoothStatus}>Bluetooth Status</button>
<button onClick={bluetoothScan}>Bluetooth Scan</button>
<button onClick={disconnectBTDevice}>Bluetooth Disconnect</button>
<button onClick={updateDeviceTone}>Update Tone</button>
<button onClick={updateUAC}>Update UAC</button>
</div>
<div id="files" style={{ padding: '0px 0px 0px 30px', marginBottom: '20px' }}>
<h3>Files: </h3>
......
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