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
e87b778c
Commit
e87b778c
authored
Mar 20, 2026
by
martin hou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 调整readFile实现支持大块传输
parent
ca7daefb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
3 deletions
+46
-3
index.tsx
src/index.tsx
+15
-1
jensen.js
src/utils/jensen.js
+31
-2
No files found.
src/index.tsx
View file @
e87b778c
...
@@ -248,6 +248,11 @@ export function Home() {
...
@@ -248,6 +248,11 @@ export function Home() {
// alert(fc?.count);
// alert(fc?.count);
let
files
=
await
jensen
.
listFiles
();
let
files
=
await
jensen
.
listFiles
();
console
.
log
(
files
);
console
.
log
(
files
);
let
totalLength
=
0
;
for
(
const
f
of
files
)
{
totalLength
+=
f
.
length
;
}
Logger
.
info
(
'jensen'
,
'listFiles'
,
'Total Length: '
+
(
totalLength
/
1024
/
1024
).
toFixed
(
2
)
+
'MB'
);
setFiles
(
files
)
setFiles
(
files
)
await
releaseJensen
();
await
releaseJensen
();
}
}
...
@@ -829,11 +834,19 @@ export function Home() {
...
@@ -829,11 +834,19 @@ export function Home() {
if
(
jensen
==
null
)
return
;
if
(
jensen
==
null
)
return
;
const
fname
=
'2026Feb04-152156-Rec00.wav'
;
const
fname
=
'2026Feb04-152156-Rec00.wav'
;
let
rst
=
await
jensen
.
readFile
(
fname
,
0
,
1024
*
1024
*
2
);
let
rst
=
await
jensen
.
readFile
(
fname
,
0
,
1024
*
1024
*
2
);
console
.
log
(
'xxxxxx0'
,
rst
);
console
.
log
(
'xxxxxx0'
,
rst
.
length
);
// Logger.info('jensen', 'read-block', 'Read Block: ' + JSON.stringify(rst));
// Logger.info('jensen', 'read-block', 'Read Block: ' + JSON.stringify(rst));
await
releaseJensen
();
await
releaseJensen
();
}
}
const
readCardInfo
=
async
()
=>
{
let
jensen
=
await
getJensen
();
if
(
jensen
==
null
)
return
;
let
rst
=
await
jensen
.
getCardInfo
(
5
);
Logger
.
info
(
'jensen'
,
'card-info'
,
'Get Card Info: '
+
JSON
.
stringify
(
rst
));
await
releaseJensen
();
}
return
(
return
(
<>
<>
<
div
className=
"btn-container"
style=
{
{
display
:
'flex'
,
flexDirection
:
'row'
,
gap
:
'16px'
,
padding
:
'16px'
,
alignItems
:
'center'
,
flexWrap
:
'wrap'
}
}
>
<
div
className=
"btn-container"
style=
{
{
display
:
'flex'
,
flexDirection
:
'row'
,
gap
:
'16px'
,
padding
:
'16px'
,
alignItems
:
'center'
,
flexWrap
:
'wrap'
}
}
>
...
@@ -842,6 +855,7 @@ export function Home() {
...
@@ -842,6 +855,7 @@ export function Home() {
<
button
onClick=
{
getTime
}
>
Get Time
</
button
>
<
button
onClick=
{
getTime
}
>
Get Time
</
button
>
<
button
onClick=
{
listFiles
}
>
List Files
</
button
>
<
button
onClick=
{
listFiles
}
>
List Files
</
button
>
<
button
onClick=
{
transferFile
}
>
Transfer
</
button
>
<
button
onClick=
{
transferFile
}
>
Transfer
</
button
>
<
button
onClick=
{
readCardInfo
}
>
Card Info
</
button
>
<
button
onClick=
{
batteryStatus
}
>
Battery
</
button
>
<
button
onClick=
{
batteryStatus
}
>
Battery
</
button
>
<
button
onClick=
{
getBluetoothStatus
}
>
Bluetooth Status
</
button
>
<
button
onClick=
{
getBluetoothStatus
}
>
Bluetooth Status
</
button
>
<
button
onClick=
{
bluetoothScan
}
>
Start Scan
</
button
>
<
button
onClick=
{
bluetoothScan
}
>
Start Scan
</
button
>
...
...
src/utils/jensen.js
View file @
e87b778c
...
@@ -339,7 +339,7 @@ function Jensen(log, conn) {
...
@@ -339,7 +339,7 @@ function Jensen(log, conn) {
current
=
'cmd-'
+
cmd
.
command
+
'-'
+
cmd
.
index
;
current
=
'cmd-'
+
cmd
.
command
+
'-'
+
cmd
.
index
;
Logger
.
debug
(
'jensen'
,
'sendNext'
,
pid
+
'-command: '
+
current
+
', data bytes: '
+
data
.
byteLength
);
Logger
.
debug
(
'jensen'
,
'sendNext'
,
pid
+
'-command: '
+
current
+
', data bytes: '
+
data
.
byteLength
);
self
.
timewait
=
cmd
.
command
==
TRANSFER_FILE
||
cmd
.
command
==
GET_FILE_BLOCK
?
1000
:
10
;
self
.
timewait
=
cmd
.
command
==
TRANSFER_FILE
||
cmd
.
command
==
GET_FILE_BLOCK
||
cmd
.
command
==
TRANSFER_FILE_PARTIAL
?
1000
:
10
;
console
.
log
(
pid
+
'-send'
,
data
);
console
.
log
(
pid
+
'-send'
,
data
);
if
(
self
.
onprogress
&&
cmd
.
command
==
TRANSFER_FILE
)
if
(
self
.
onprogress
&&
cmd
.
command
==
TRANSFER_FILE
)
{
{
...
@@ -1059,7 +1059,9 @@ Jensen.prototype.deleteFile = async function (filename, seconds) {
...
@@ -1059,7 +1059,9 @@ Jensen.prototype.deleteFile = async function (filename, seconds) {
};
};
Jensen
.
prototype
.
readFile
=
async
function
(
filename
,
offset
,
length
,
seconds
)
{
Jensen
.
prototype
.
readFile
=
async
function
(
filename
,
offset
,
length
,
seconds
)
{
// 如果确定支持的版本号
if
(
typeof
length
!=
'number'
)
throw
new
Error
(
'parameter `length` required'
);
if
(
length
<=
0
)
throw
new
Error
(
'parameter `length` must greater than zero'
);
let
data
=
[];
let
data
=
[];
data
.
push
((
offset
>>
24
)
&
0xff
);
data
.
push
((
offset
>>
24
)
&
0xff
);
data
.
push
((
offset
>>
16
)
&
0xff
);
data
.
push
((
offset
>>
16
)
&
0xff
);
...
@@ -1070,6 +1072,33 @@ Jensen.prototype.readFile = async function (filename, offset, length, seconds) {
...
@@ -1070,6 +1072,33 @@ Jensen.prototype.readFile = async function (filename, offset, length, seconds) {
data
.
push
((
length
>>
8
)
&
0xff
);
data
.
push
((
length
>>
8
)
&
0xff
);
data
.
push
((
length
>>
0
)
&
0xff
);
data
.
push
((
length
>>
0
)
&
0xff
);
for
(
let
i
=
0
;
i
<
filename
.
length
;
i
++
)
data
.
push
(
filename
.
charCodeAt
(
i
));
for
(
let
i
=
0
;
i
<
filename
.
length
;
i
++
)
data
.
push
(
filename
.
charCodeAt
(
i
));
let
chunks
=
[];
let
flen
=
0
;
let
handler
=
(
msg
)
=>
{
if
(
msg
!=
null
)
{
let
chunk
=
msg
.
body
;
let
chunkLen
=
chunk
.
length
||
chunk
.
byteLength
;
flen
+=
chunkLen
;
chunks
.
push
(
chunk
);
if
(
flen
>=
length
)
{
let
result
=
new
Uint8Array
(
Math
.
min
(
flen
,
length
));
let
pos
=
0
;
for
(
let
i
=
0
;
i
<
chunks
.
length
&&
pos
<
result
.
length
;
i
++
)
{
let
c
=
chunks
[
i
];
let
cview
=
c
instanceof
Uint8Array
?
c
:
new
Uint8Array
(
c
);
let
toCopy
=
Math
.
min
(
cview
.
length
,
result
.
length
-
pos
);
result
.
set
(
cview
.
subarray
(
0
,
toCopy
),
pos
);
pos
+=
toCopy
;
}
return
result
;
}
}
else
{
Logger
.
info
(
'jensen'
,
'readFile'
,
'file transfer fail.'
);
return
null
;
}
};
this
.
registerHandler
(
TRANSFER_FILE_PARTIAL
,
handler
);
return
this
.
send
(
new
Command
(
TRANSFER_FILE_PARTIAL
).
body
(
data
),
seconds
);
return
this
.
send
(
new
Command
(
TRANSFER_FILE_PARTIAL
).
body
(
data
),
seconds
);
}
}
...
...
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