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
0ac3ddb8
Commit
0ac3ddb8
authored
Apr 01, 2025
by
martin hou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf trace
parent
14b905e3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
2 deletions
+20
-2
index.tsx
src/index.tsx
+16
-1
jensen.js
src/utils/jensen.js
+4
-1
No files found.
src/index.tsx
View file @
0ac3ddb8
...
...
@@ -80,7 +80,7 @@ export function Home() {
const
listFiles
=
async
()
=>
{
let
files
=
await
jensen
.
listFiles
();
console
.
log
(
files
);
setFiles
(
files
);
}
const
getBluetoothStatus
=
async
()
=>
{
...
...
@@ -88,6 +88,20 @@ export function Home() {
alert
(
JSON
.
stringify
(
info
));
}
const
transferFile
=
async
()
=>
{
if
(
files
.
length
==
0
)
return
alert
(
'No files found'
);
let
idx
=
prompt
(
'请输入文件序号(从0开始):'
,
'0'
);
if
(
idx
===
undefined
)
return
;
if
(
idx
===
null
)
return
;
let
num
=
parseInt
(
idx
);
if
(
isNaN
(
num
))
return
;
if
(
num
<
0
||
num
>=
files
.
length
)
return
alert
(
'无效序号'
);
let
file
=
files
[
num
];
jensen
.
getFile
(
file
.
name
,
file
.
length
,
(
segment
)
=>
{
// ...
});
}
return
(
<>
<
div
style=
{
{
display
:
'flex'
,
flexDirection
:
'row'
,
gap
:
'16px'
,
padding
:
'16px'
,
alignItems
:
'center'
}
}
>
...
...
@@ -101,6 +115,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
</
button
>
<
button
style=
{
{
width
:
'200px'
,
height
:
'50px'
}
}
onClick=
{
getBluetoothStatus
}
>
Bluetooth Status
</
button
>
<
button
style=
{
{
width
:
'200px'
,
height
:
'50px'
}
}
onClick=
{
bluetoothScan
}
>
Bluetooth Scan
</
button
>
<
button
style=
{
{
width
:
'200px'
,
height
:
'50px'
}
}
onClick=
{
disconnectBTDevice
}
>
Bluetooth Disconnect
</
button
>
...
...
src/utils/jensen.js
View file @
0ac3ddb8
...
...
@@ -889,7 +889,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
)
{
...
...
@@ -901,6 +901,9 @@ Jensen.prototype.getFile = async function (filename, length, ondata, onprogress)
Logger
.
info
(
'jensen'
,
'getFile'
,
'file transfer finish.'
);
// clearEventAndTask();
// return OK indicates all file blocks received
let
etime
=
new
Date
();
let
cost
=
etime
.
getTime
()
-
stime
.
getTime
();
Logger
.
info
(
'jensen'
,
'getFile'
,
'cost '
+
cost
+
' ms'
);
return
'OK'
;
}
}
else
{
...
...
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