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
a1ed6bce
Commit
a1ed6bce
authored
Nov 11, 2025
by
martin hou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 增加清空已配对设备列表的指令实现与测试
parent
1bc6b6dc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
0 deletions
+19
-0
jensen.d.ts
jensen.d.ts
+3
-0
index.tsx
src/index.tsx
+8
-0
jensen.js
src/utils/jensen.js
+8
-0
No files found.
jensen.d.ts
View file @
a1ed6bce
...
...
@@ -287,6 +287,9 @@ declare class Jensen {
// 获取已配对的蓝牙设备列表
getPairedDevices
:
(
seconds
?:
number
)
=>
Promise
<
BluetoothDevice
[]
>
;
// 清空已配对的蓝牙设备列表
clearPairedDevices
:
(
seconds
?:
number
)
=>
Promise
<
ReturnStruct
[
'common'
]
>
;
// 设备回连
reconnectDevice
:
(
mac
:
string
,
seconds
?:
number
)
=>
Promise
<
ReturnStruct
[
'common'
]
>
;
...
...
src/index.tsx
View file @
a1ed6bce
...
...
@@ -435,6 +435,13 @@ export function Home() {
Logger
.
info
(
'jensen'
,
'bluetooth'
,
'Paired Devices: '
+
JSON
.
stringify
(
devices
));
}
const
clearPairedDevices
=
async
()
=>
{
let
jensen
=
getJensen
();
if
(
jensen
==
null
)
return
;
let
rst
=
await
jensen
.
clearPairedDevices
(
5
);
Logger
.
info
(
'jensen'
,
'bluetooth'
,
'Clear Paired Devices: '
+
JSON
.
stringify
(
rst
));
}
return
(
<>
<
div
className=
"btn-container"
style=
{
{
display
:
'flex'
,
flexDirection
:
'row'
,
gap
:
'16px'
,
padding
:
'16px'
,
alignItems
:
'center'
,
flexWrap
:
'wrap'
}
}
>
...
...
@@ -449,6 +456,7 @@ export function Home() {
<
button
onClick=
{
stopBluetoothScan
}
>
Stop Scan
</
button
>
<
button
onClick=
{
getScanResults
}
>
Scan Results
</
button
>
<
button
onClick=
{
getPairedDevices
}
>
Paired Devices
</
button
>
<
button
onClick=
{
clearPairedDevices
}
>
Clear Paired
</
button
>
{
/*
<button onClick={reconnectDevice}>Connect Device</button>
...
...
src/utils/jensen.js
View file @
a1ed6bce
...
...
@@ -39,6 +39,7 @@ const BLUETOOTH_STATUS = 0x1003;
const
BT_SCAN
=
0x1005
;
const
BT_DEV_LIST
=
0x1006
;
const
BT_GET_PAIRED_DEV_LIST
=
0x1007
;
const
BT_REMOVE_PAIRED_DEV
=
0x1008
;
const
TEST_SN_WRITE
=
0xf007
;
const
RECORD_TEST_START
=
0xf008
;
...
...
@@ -734,6 +735,12 @@ Jensen.prototype.getPairedDevices = async function (seconds) {
return
this
.
send
(
new
Command
(
BT_GET_PAIRED_DEV_LIST
),
seconds
);
};
// 清空已配对的蓝牙设备列表
Jensen
.
prototype
.
clearPairedDevices
=
async
function
(
seconds
)
{
if
(
this
.
model
.
indexOf
(
'hidock-p1'
)
==
-
1
)
return
null
;
return
this
.
send
(
new
Command
(
BT_REMOVE_PAIRED_DEV
).
body
([
0x00
]),
seconds
);
}
// 设备回连
Jensen
.
prototype
.
reconnectDevice
=
async
function
(
mac
,
seconds
)
{
if
(
this
.
model
.
indexOf
(
'hidock-p1'
)
==
-
1
)
return
null
;
...
...
@@ -1609,6 +1616,7 @@ Jensen.registerHandler(READ_WEBUSB_TIMEOUT, (msg) => {
});
Jensen
.
registerHandler
(
BT_SCAN
,
commonMessageParser
);
Jensen
.
registerHandler
(
BT_REMOVE_PAIRED_DEV
,
commonMessageParser
);
Jensen
.
registerHandler
(
BT_DEV_LIST
,
(
msg
)
=>
{
// console.log('bluetooth-scan', msg);
if
(
msg
.
body
.
length
==
0
)
return
[];
...
...
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