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
302baabc
Commit
302baabc
authored
Sep 22, 2025
by
martin hou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 增加WebUSB写超时设置
parent
bf440ad5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
0 deletions
+40
-0
jensen.d.ts
jensen.d.ts
+6
-0
index.tsx
src/index.tsx
+16
-0
jensen.js
src/utils/jensen.js
+18
-0
No files found.
jensen.d.ts
View file @
302baabc
...
...
@@ -304,6 +304,12 @@ declare class Jensen {
// 更新设备UAC固件
updateUAC
:
(
data
:
Uint8Array
,
seconds
?:
number
)
=>
Promise
<
ReturnStruct
[
'common'
]
>
;
// 设置WebUSB超时时间
setWebUSBTimeout
:
(
timeout
:
number
,
seconds
?:
number
)
=>
Promise
<
ReturnStruct
[
'common'
]
>
;
// 获取WebUSB超时时间
getWebUSBTimeout
:
(
seconds
?:
number
)
=>
Promise
<
{
timeout
:
number
}
>
;
dump
:
(
void
);
}
...
...
src/index.tsx
View file @
302baabc
...
...
@@ -259,6 +259,20 @@ export function Home() {
else
alert
(
'Something went wrong...'
);
}
const
setWebUSBTimeout
=
async
()
=>
{
let
ts
=
prompt
(
'Please Input the Timeout (ms):'
,
'10000'
);
if
(
ts
===
undefined
||
ts
===
null
)
return
;
let
timeout
=
parseInt
(
ts
);
if
(
isNaN
(
timeout
)
||
timeout
<=
0
)
return
alert
(
'Please Input the Correct Timeout'
);
await
jensen
.
setWebUSBTimeout
(
timeout
,
30
);
alert
(
'Set Timeout Success'
);
}
const
getWebUSBTimeout
=
async
()
=>
{
let
rst
=
await
jensen
.
getWebUSBTimeout
(
5
);
alert
(
JSON
.
stringify
(
rst
));
}
return
(
<>
<
div
style=
{
{
display
:
'flex'
,
flexDirection
:
'row'
,
gap
:
'16px'
,
padding
:
'16px'
,
alignItems
:
'center'
,
flexWrap
:
'wrap'
}
}
>
...
...
@@ -272,6 +286,8 @@ export function Home() {
<
button
onClick=
{
disconnectBTDevice
}
>
Bluetooth Disconnect
</
button
>
<
button
onClick=
{
updateDeviceTone
}
>
Update Tone
</
button
>
<
button
onClick=
{
updateUAC
}
>
Update UAC
</
button
>
<
button
onClick=
{
setWebUSBTimeout
}
>
Set Timeout
</
button
>
<
button
onClick=
{
getWebUSBTimeout
}
>
Get Timeout
</
button
>
</
div
>
<
div
id=
"files"
style=
{
{
padding
:
'0px 0px 0px 30px'
,
marginBottom
:
'20px'
}
}
>
<
h3
>
Files:
</
h3
>
...
...
src/utils/jensen.js
View file @
302baabc
...
...
@@ -39,6 +39,8 @@ const BLUETOOTH_STATUS = 0x1003;
const
TEST_SN_WRITE
=
0xf007
;
const
RECORD_TEST_START
=
0xf008
;
const
RECORD_TEST_END
=
0xf009
;
const
WRITE_WEBUSB_TIMEOUT
=
0xf010
;
const
READ_WEBUSB_TIMEOUT
=
0xf011
;
const
COMMAND_NAMES
=
{
[
INVAILD
]:
'invalid-0'
,
...
...
@@ -764,6 +766,16 @@ Jensen.prototype.getBluetoothStatus = async function (seconds) {
return
this
.
send
(
new
Command
(
BLUETOOTH_STATUS
),
seconds
);
};
Jensen
.
prototype
.
setWebUSBTimeout
=
async
function
(
timeout
,
seconds
)
{
return
this
.
send
(
new
Command
(
WRITE_WEBUSB_TIMEOUT
).
body
([
timeout
]),
seconds
);
};
Jensen
.
prototype
.
getWebUSBTimeout
=
async
function
(
seconds
)
{
return
this
.
send
(
new
Command
(
READ_WEBUSB_TIMEOUT
),
seconds
);
};
Jensen
.
prototype
.
listFiles
=
async
function
()
{
let
tag
=
'filelist-'
+
this
.
serialNumber
;
if
(
this
[
tag
]
!=
null
)
return
null
;
...
...
@@ -1580,5 +1592,11 @@ Jensen.registerHandler(REQUEST_UAC_UPDATE, (msg) => {
return
{
code
:
rst
,
result
:
txt
};
});
Jensen
.
registerHandler
(
UAC_UPDATE
,
commonMessageParser
);
Jensen
.
registerHandler
(
WRITE_WEBUSB_TIMEOUT
,
commonMessageParser
);
Jensen
.
registerHandler
(
READ_WEBUSB_TIMEOUT
,
(
msg
)
=>
{
let
timeout
=
((
msg
.
body
[
0
]
&
0xff
)
<<
24
)
|
((
msg
.
body
[
1
]
&
0xff
)
<<
16
)
|
((
msg
.
body
[
2
]
&
0xff
)
<<
8
)
|
(
msg
.
body
[
3
]
&
0xff
);
return
{
timeout
:
timeout
};
});
export
{
Jensen
};
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