Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
J
jensen
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Skye Yu
jensen
Commits
1d2ac0d5
Commit
1d2ac0d5
authored
Apr 14, 2025
by
martin hou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加对Eason Mini的识别,以及增加了文件传输时长的计算
parent
6dfa7138
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
4 deletions
+25
-4
index.tsx
src/index.tsx
+20
-0
jensen.js
src/utils/jensen.js
+5
-4
No files found.
src/index.tsx
View file @
1d2ac0d5
...
...
@@ -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
>
...
...
src/utils/jensen.js
View file @
1d2ac0d5
...
...
@@ -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'
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment