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
f8f75923
Commit
f8f75923
authored
Jul 15, 2025
by
martin hou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 增加P1电量API实现
parent
1feaf54e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
2 deletions
+16
-2
jensen.js
src/utils/jensen.js
+16
-2
No files found.
src/utils/jensen.js
View file @
f8f75923
...
@@ -26,7 +26,7 @@ const TONE_UPDATE = 0x17;
...
@@ -26,7 +26,7 @@ const TONE_UPDATE = 0x17;
const
REQUEST_UAC_UPDATE
=
0x18
;
const
REQUEST_UAC_UPDATE
=
0x18
;
const
UAC_UPDATE
=
0x19
;
const
UAC_UPDATE
=
0x19
;
const
FACTORY_RESET
=
0xf00b
;
const
FACTORY_RESET
=
0xf00b
;
const
GET_BATTERY_STATUS
=
0x1004
;
const
REALTIME_READ_SETTING
=
0x20
;
const
REALTIME_READ_SETTING
=
0x20
;
const
REALTIME_CONTROL
=
0x21
;
const
REALTIME_CONTROL
=
0x21
;
const
REALTIME_TRANSFER
=
0x22
;
const
REALTIME_TRANSFER
=
0x22
;
...
@@ -1108,7 +1108,11 @@ Jensen.prototype.getFileBlock = async function (filename, length, ondata) {
...
@@ -1108,7 +1108,11 @@ Jensen.prototype.getFileBlock = async function (filename, length, ondata) {
return
this
.
send
(
new
Command
(
GET_FILE_BLOCK
).
body
(
data
));
return
this
.
send
(
new
Command
(
GET_FILE_BLOCK
).
body
(
data
));
};
};
Jensen
.
prototype
.
getBatteryStatus
=
function
(
seconds
)
{
if
(
this
.
model
!=
'hidock-p1'
)
return
null
;
return
this
.
send
(
new
Command
(
GET_BATTERY_STATUS
),
seconds
);
}
Jensen
.
prototype
.
writeSerialNumber
=
async
function
(
sn
)
{
Jensen
.
prototype
.
writeSerialNumber
=
async
function
(
sn
)
{
let
data
=
[];
let
data
=
[];
for
(
let
i
=
0
;
i
<
sn
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
sn
.
length
;
i
++
)
{
...
@@ -1205,6 +1209,16 @@ Jensen.registerHandler(REALTIME_READ_SETTING, (msg) => {
...
@@ -1205,6 +1209,16 @@ Jensen.registerHandler(REALTIME_READ_SETTING, (msg) => {
// console.log(msg);
// console.log(msg);
return
msg
;
return
msg
;
});
});
Jensen
.
registerHandler
(
GET_BATTERY_STATUS
,
(
msg
)
=>
{
let
status
=
msg
.
body
[
0
]
&
0xff
;
let
percent
=
msg
.
body
[
1
]
&
0xff
;
let
voltage
=
((
msg
.
body
[
2
]
&
0xff
)
<<
24
)
|
((
msg
.
body
[
3
]
&
0xff
)
<<
16
)
|
((
msg
.
body
[
4
]
&
0xff
)
<<
8
)
|
(
msg
.
body
[
5
]
&
0xff
);
return
{
status
:
status
==
0
?
'idle'
:
(
status
==
1
?
'charging'
:
'full'
),
battery
:
percent
,
voltage
:
voltage
};
})
Jensen
.
registerHandler
(
REALTIME_TRANSFER
,
(
msg
)
=>
{
Jensen
.
registerHandler
(
REALTIME_TRANSFER
,
(
msg
)
=>
{
let
a
=
msg
.
body
[
0
]
&
0xff
;
let
a
=
msg
.
body
[
0
]
&
0xff
;
let
b
=
msg
.
body
[
1
]
&
0xff
;
let
b
=
msg
.
body
[
1
]
&
0xff
;
...
...
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