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
992d2444
Commit
992d2444
authored
Dec 01, 2025
by
martin hou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 增加设备类型识别
parent
62561199
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
+17
-2
index.tsx
src/index.tsx
+1
-0
jensen.js
src/utils/jensen.js
+16
-2
No files found.
src/index.tsx
View file @
992d2444
...
...
@@ -119,6 +119,7 @@ export function Home() {
let
jensen
=
getJensen
();
if
(
jensen
==
null
)
return
;
let
devices
=
await
jensen
.
getScanResults
(
5
);
console
.
log
(
devices
);
if
(
devices
==
null
)
return
alert
(
'get scan results failed.'
);
setDevices
(
devices
);
}
...
...
src/utils/jensen.js
View file @
992d2444
...
...
@@ -1686,15 +1686,29 @@ Jensen.registerHandler(BT_DEV_LIST, (msg, jensen) => {
}
let
rssi
=
msg
.
body
[
k
++
]
&
0xff
;
let
cod
=
((
msg
.
body
[
k
++
]
&
0xff
)
<<
16
)
|
((
msg
.
body
[
k
++
]
&
0xff
)
<<
8
)
|
(
msg
.
body
[
k
++
]
&
0xff
);
let
isAudio
=
__is_headset_or_mic
(
cod
);
devices
.
push
({
name
:
decoder
.
decode
(
jensen
.
truncateIncompleteUtf8
(
sname
)),
name
:
(
isAudio
?
'🎧'
:
'🚫'
)
+
decoder
.
decode
(
jensen
.
truncateIncompleteUtf8
(
sname
)),
mac
:
mac
.
join
(
'-'
),
rssi
:
rssi
,
cod
:
cod
cod
:
cod
,
audio
:
isAudio
});
}
return
devices
;
});
function
__is_headset_or_mic
(
cod
)
{
const
SERVICE_AUDIO
=
1
<<
21
;
// Audio bit (bit 21)
const
SERVICE_TELEPHONY
=
1
<<
22
;
// Telephony bit (bit 22)
const
SERVICE_CAPTURING
=
1
<<
19
;
// Capturing (mic / scanner) bit (optional)
const
serviceMask
=
cod
&
0x00FFE000
;
// Explanation: bits 13–23 correspond to mask 0x00FFE000 (binary: 0000 0000 1111 1111 1110 0000 0000 0000)
// Alternatively you can directly mask bits 19,21,22 as above.
return
(
serviceMask
&
(
SERVICE_AUDIO
|
SERVICE_TELEPHONY
|
SERVICE_CAPTURING
))
!==
0
;
}
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