Commit ad38a3a4 authored by martin hou's avatar martin hou

feat: added compatibility with eason file list

parent 15ce97f3
...@@ -78,6 +78,11 @@ export function Home() { ...@@ -78,6 +78,11 @@ export function Home() {
alert(JSON.stringify(time)); alert(JSON.stringify(time));
} }
const listFiles = async () => {
let files = await jensen.listFiles();
console.log(files);
}
return ( return (
<> <>
<div style={{ display: 'flex', flexDirection: 'row', gap: '16px', padding: '16px', alignItems: 'center' }}> <div style={{ display: 'flex', flexDirection: 'row', gap: '16px', padding: '16px', alignItems: 'center' }}>
...@@ -90,6 +95,7 @@ export function Home() { ...@@ -90,6 +95,7 @@ export function Home() {
<button style={{ width: '200px', height: '50px' }} onClick={getTime}> <button style={{ width: '200px', height: '50px' }} onClick={getTime}>
Get Time Get Time
</button> </button>
<button style={{ width: '200px', height: '50px' }} onClick={listFiles}>List Files</button>
<button style={{ width : '200px', height : '50px' }} onClick={bluetoothScan}>Bluetooth Scan</button> <button style={{ width : '200px', height : '50px' }} onClick={bluetoothScan}>Bluetooth Scan</button>
<button style={{ width : '200px', height : '50px' }} onClick={disconnectBTDevice}>Bluetooth Disconnect</button> <button style={{ width : '200px', height : '50px' }} onClick={disconnectBTDevice}>Bluetooth Disconnect</button>
</div> </div>
......
...@@ -648,17 +648,26 @@ Jensen.prototype.listFiles = async function () { ...@@ -648,17 +648,26 @@ Jensen.prototype.listFiles = async function () {
ftime = ftime.replace(/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})REC.*$/gi, '$1-$2-$3 $4:$5:$6'); ftime = ftime.replace(/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})REC.*$/gi, '$1-$2-$3 $4:$5:$6');
ftime = new Date(ftime); ftime = new Date(ftime);
duration = flen / 32; duration = flen / 32;
} else if (ftime.match(/^(\d{2})?(\d{2})(\w{3})(\d{2})-(\d{2})(\d{2})(\d{2})-.*\.hda$/gi)) { } else if (ftime.match(/^(\d{2})?(\d{2})(\w{3})(\d{2})-(\d{2})(\d{2})(\d{2})-.*\.(hda|wav)$/gi)) {
// 2024Mar19-110932-Rec00.hda // 2024Mar19-110932-Rec00.hda
ftime = ftime.replace(/^(\d{2})?(\d{2})(\w{3})(\d{2})-(\d{2})(\d{2})(\d{2})-.*\.hda$/gi, '20$2 $3 $4 $5:$6:$7'); ftime = ftime.replace(/^(\d{2})?(\d{2})(\w{3})(\d{2})-(\d{2})(\d{2})(\d{2})-.*\.(hda|wav)$/gi, '20$2 $3 $4 $5:$6:$7');
ftime = new Date(ftime); ftime = new Date(ftime);
duration = (flen / 32) * 4; duration = (flen / 32) * 4;
} else { }
else {
ftime = null; ftime = null;
} }
if (ver == 1) { if (ver == 1) {
duration = duration * 2; duration = duration * 2;
} }
else if (ver == 2)
{
duration = (flen - 44) / 48 / 2;
}
else if (ver == 3)
{
duration = (flen - 44) / 48 / 2 / 2;
}
let createDate = ''; let createDate = '';
let createTime = ''; let createTime = '';
if (ftime) { if (ftime) {
...@@ -671,6 +680,7 @@ Jensen.prototype.listFiles = async function () { ...@@ -671,6 +680,7 @@ Jensen.prototype.listFiles = async function () {
createTime: createTime, createTime: createTime,
time: ftime, time: ftime,
duration: duration, duration: duration,
version: ver,
length: flen, length: flen,
signature: sign.join('') signature: sign.join('')
}); });
......
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