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
7befde52
Commit
7befde52
authored
Aug 25, 2025
by
martin hou
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'v20250816' into device-mgr
parents
2df424ff
7f27a5e9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
20 deletions
+33
-20
jensen.d.ts
jensen.d.ts
+2
-0
jensen.js
src/utils/jensen.js
+31
-20
No files found.
jensen.d.ts
View file @
7befde52
...
@@ -301,6 +301,8 @@ declare class Jensen {
...
@@ -301,6 +301,8 @@ declare class Jensen {
// 更新设备UAC固件
// 更新设备UAC固件
updateUAC
:
(
data
:
Uint8Array
,
seconds
?:
number
)
=>
Promise
<
ReturnStruct
[
'common'
]
>
;
updateUAC
:
(
data
:
Uint8Array
,
seconds
?:
number
)
=>
Promise
<
ReturnStruct
[
'common'
]
>
;
dump
:
(
void
);
}
}
export
=
Jensen
;
export
=
Jensen
;
src/utils/jensen.js
View file @
7befde52
...
@@ -244,6 +244,10 @@ function Jensen(log, conn) {
...
@@ -244,6 +244,10 @@ function Jensen(log, conn) {
return
device
;
return
device
;
}
}
this
.
busy
=
function
()
{
return
Boolean
(
current
);
}
this
.
setUSBDevice
=
function
(
dev
)
{
this
.
setUSBDevice
=
function
(
dev
)
{
device
=
dev
;
device
=
dev
;
ready
=
false
;
ready
=
false
;
...
@@ -290,15 +294,13 @@ function Jensen(log, conn) {
...
@@ -290,15 +294,13 @@ function Jensen(log, conn) {
let
data
=
cmd
.
make
();
let
data
=
cmd
.
make
();
current
=
'cmd-'
+
cmd
.
command
+
'-'
+
cmd
.
index
;
current
=
'cmd-'
+
cmd
.
command
+
'-'
+
cmd
.
index
;
Logger
.
debug
(
'jensen'
,
'sendNext'
,
pid
+
'-command: '
+
c
md
.
command
+
', data bytes: '
+
data
.
byteLength
);
Logger
.
debug
(
'jensen'
,
'sendNext'
,
pid
+
'-command: '
+
c
urrent
+
', 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
?
1000
:
10
;
console
.
log
(
pid
+
'-send'
,
data
);
console
.
log
(
pid
+
'-send'
,
data
);
if
(
self
.
onprogress
&&
(
cmd
.
command
==
TRANSFER_FILE
||
cmd
.
command
==
GET_FILE_BLOCK
)
)
if
(
self
.
onprogress
&&
cmd
.
command
==
TRANSFER_FILE
)
{
{
self
.
transferStartTime
=
new
Date
().
getTime
();
try
{
self
.
onprogress
(
0
);
}
catch
(
e
)
{}
Logger
.
debug
(
'jensen'
,
'file-transfer'
,
new
Date
().
getTime
());
try
{
self
.
onprogress
(
0
);
}
catch
(
e
)
{
}
}
}
await
device
.
transferOut
(
1
,
data
).
catch
((
e
)
=>
crash
(
'sendNext'
,
e
));
await
device
.
transferOut
(
1
,
data
).
catch
((
e
)
=>
crash
(
'sendNext'
,
e
));
if
(
cmd
.
onprogress
)
cmd
.
onprogress
(
1
,
1
);
if
(
cmd
.
onprogress
)
cmd
.
onprogress
(
1
,
1
);
...
@@ -337,9 +339,11 @@ function Jensen(log, conn) {
...
@@ -337,9 +339,11 @@ function Jensen(log, conn) {
timeout
(
tag
);
timeout
(
tag
);
},
seconds
*
1000
)
},
seconds
*
1000
)
:
null
;
:
null
;
Logger
.
debug
(
'jensen'
,
'register'
,
tag
);
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
actions
[
tag
]
=
{
actions
[
tag
]
=
{
tag
:
tag
,
tag
:
tag
,
createtime
:
new
Date
().
getTime
(),
resolve
:
resolve
,
resolve
:
resolve
,
reject
:
reject
,
reject
:
reject
,
timeout
:
t
timeout
:
t
...
@@ -353,18 +357,21 @@ function Jensen(log, conn) {
...
@@ -353,18 +357,21 @@ function Jensen(log, conn) {
const
trigger
=
function
(
resp
,
msgid
)
{
const
trigger
=
function
(
resp
,
msgid
)
{
if
(
current
==
null
)
return
;
if
(
current
==
null
)
return
;
Logger
.
debug
(
'jensen'
,
'trigger'
,
pid
+
':trigger - '
+
current
.
substring
(
0
,
current
.
lastIndexOf
(
'-'
))
+
' <---> cmd-'
+
(
msgid
||
'err'
));
Logger
.
debug
(
'jensen'
,
'trigger'
,
pid
+
':trigger - '
+
current
+
' <---> cmd-'
+
(
msgid
||
'err'
));
if
(
current
.
substring
(
0
,
current
.
lastIndexOf
(
'-'
))
!=
'cmd-'
+
msgid
)
{
if
(
current
.
substring
(
0
,
current
.
lastIndexOf
(
'-'
))
!=
'cmd-'
+
msgid
)
{
// current = null;
// current = null;
Logger
.
info
(
'jensen'
,
'trigger'
,
'return cuz cmd mismatched'
);
return
;
return
;
}
}
if
(
current
in
actions
==
false
)
{
if
(
current
in
actions
==
false
)
{
Logger
.
debug
(
'jensen'
,
'trigger'
,
pid
+
':no action registered'
);
Logger
.
debug
(
'jensen'
,
'trigger'
,
pid
+
':no action registered'
);
current
=
null
;
return
;
return
;
}
}
let
p
=
actions
[
current
];
let
p
=
actions
[
current
];
if
(
p
.
timeout
)
clearTimeout
(
p
.
timeout
);
if
(
p
.
timeout
)
clearTimeout
(
p
.
timeout
);
p
.
resolve
(
resp
);
p
.
resolve
(
resp
);
Logger
.
info
(
'jensen'
,
'trigger'
,
p
.
tag
+
', cost: '
+
(
new
Date
().
getTime
()
-
p
.
createtime
)
+
'ms'
);
delete
actions
[
current
];
delete
actions
[
current
];
current
=
null
;
current
=
null
;
};
};
...
@@ -381,13 +388,14 @@ function Jensen(log, conn) {
...
@@ -381,13 +388,14 @@ function Jensen(log, conn) {
console
.
log
(
'pending commands'
,
commands
);
console
.
log
(
'pending commands'
,
commands
);
console
.
log
(
'current'
,
current
);
console
.
log
(
'current'
,
current
);
console
.
log
(
'device'
,
device
);
console
.
log
(
'device'
,
device
);
return
{
'actions'
:
actions
,
'commands'
:
commands
,
'current'
:
current
,
'device'
:
device
}
};
};
this
.
busy
=
function
()
{
return
Boolean
(
current
);
// return false
}
const
tryReceive
=
function
()
{
const
tryReceive
=
function
()
{
if
(
device
)
if
(
device
)
// console.log('trace', device);
// console.log('trace', device);
...
@@ -474,7 +482,7 @@ function Jensen(log, conn) {
...
@@ -474,7 +482,7 @@ function Jensen(log, conn) {
Logger
.
debug
(
Logger
.
debug
(
'jensen'
,
'jensen'
,
'receive'
,
'receive'
,
pid
+
'-recv:
'
+
cname
+
', seq: '
+
msg
.
sequence
+
', data bytes: '
+
msg
.
body
?.
byteLength
+
', data: '
+
heading
.
join
(
' '
)
pid
+
'-recv:
cmd='
+
msg
.
id
+
', seq: '
+
msg
.
sequence
+
', data bytes: '
+
msg
.
body
?.
byteLength
+
', data: '
+
heading
.
join
(
' '
)
);
);
try
{
try
{
let
handler
=
handlers
[
msg
.
id
];
let
handler
=
handlers
[
msg
.
id
];
...
@@ -1013,18 +1021,22 @@ Jensen.prototype.getFile = async function (filename, length, ondata, onprogress)
...
@@ -1013,18 +1021,22 @@ Jensen.prototype.getFile = async function (filename, length, ondata, onprogress)
};
};
// this.onreceive = onprogress;
// this.onreceive = onprogress;
this
.
_progress_report
=
{};
this
.
_progress_report
=
{};
// try { onprogress(0); } catch(e) {}
let
self
=
this
;
this
.
onprogress
=
onprogress
;
this
.
onreceive
=
function
(
recvBytes
)
this
.
onreceive
=
function
(
recvBytes
)
{
{
let
percent
=
Math
.
floor
(
recvBytes
/
length
*
100
);
let
percent
=
Math
.
floor
(
recvBytes
/
length
*
100
);
let
k
=
't'
+
percent
;
let
k
=
't'
+
percent
;
if
(
percent
%
5
==
0
&&
percent
>
0
&&
percent
<
100
)
if
(
percent
>
0
&&
percent
<
100
)
{
{
this
.
_progress_report
[
k
]
&&
onprogress
?.(
recvBytes
);
if
(
!
(
k
in
self
.
_progress_report
))
onprogress
?.(
recvBytes
);
this
.
_progress_report
[
k
]
=
true
;
self
.
_progress_report
[
k
]
=
true
;
}
}
if
(
percent
==
100
)
if
(
percent
>=
100
&&
!
(
k
in
self
.
_progress_report
)
)
{
{
onprogress
?.(
recvBytes
);
onprogress
?.(
length
);
self
.
_progress_report
[
k
]
=
true
;
}
}
}
}
this
.
registerHandler
(
TRANSFER_FILE
,
handler
);
this
.
registerHandler
(
TRANSFER_FILE
,
handler
);
...
@@ -1139,11 +1151,10 @@ Jensen.prototype.getFileBlock = async function (filename, length, ondata) {
...
@@ -1139,11 +1151,10 @@ Jensen.prototype.getFileBlock = async function (filename, length, ondata) {
Jensen
.
prototype
.
getBatteryStatus
=
function
(
seconds
)
Jensen
.
prototype
.
getBatteryStatus
=
function
(
seconds
)
{
{
if
(
this
.
model
!=
'hidock-p1'
)
return
null
;
if
(
this
.
model
!=
'hidock-p1'
)
return
null
;
// 如果正在处理其它消息任务,则直接取消电池电量查询消息
if
(
this
.
busy
())
if
(
this
.
busy
())
{
{
// Logger.info('jensen', 'dispatcher', 'cancel battery status query...
');
Logger
.
debug
(
'jensen'
,
'dispatcher'
,
'cancel getBatteryStatus cuz busy
'
);
// return null
;
return
;
}
}
return
this
.
send
(
new
Command
(
GET_BATTERY_STATUS
),
seconds
);
return
this
.
send
(
new
Command
(
GET_BATTERY_STATUS
),
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