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
d7fcd3dc
Commit
d7fcd3dc
authored
Sep 18, 2024
by
Skye Yu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add reset factory settings interface
parent
91ea7e9a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
37 deletions
+18
-37
jensen.d.ts
jensen.d.ts
+1
-0
jensen.js
src/jensen.js
+17
-37
No files found.
jensen.d.ts
View file @
d7fcd3dc
...
@@ -74,6 +74,7 @@ declare module 'jensen' {
...
@@ -74,6 +74,7 @@ declare module 'jensen' {
)
=>
Promise
<
{
used
:
number
;
capacity
:
number
;
status
:
string
}
>
;
)
=>
Promise
<
{
used
:
number
;
capacity
:
number
;
status
:
string
}
>
;
formatCard
:
(
seconds
?:
number
)
=>
Promise
<
ReturnStruct
[
'common'
]
>
;
formatCard
:
(
seconds
?:
number
)
=>
Promise
<
ReturnStruct
[
'common'
]
>
;
factoryReset
:
(
seconds
?:
number
)
=>
Promise
<
ReturnStruct
[
'common'
]
>
;
factoryReset
:
(
seconds
?:
number
)
=>
Promise
<
ReturnStruct
[
'common'
]
>
;
restoreFactorySettings
:
(
seconds
?:
number
)
=>
Promise
<
ReturnStruct
[
'common'
]
>
;
getModel
:
()
=>
Promise
<
string
>
;
getModel
:
()
=>
Promise
<
string
>
;
getFileCount
:
(
seconds
?:
number
)
=>
Promise
<
{
count
:
number
}
|
null
>
;
getFileCount
:
(
seconds
?:
number
)
=>
Promise
<
{
count
:
number
}
|
null
>
;
recordTestStart
:
(
type
:
number
,
seconds
?:
number
)
=>
Promise
<
ReturnStruct
[
'common'
]
>
;
recordTestStart
:
(
type
:
number
,
seconds
?:
number
)
=>
Promise
<
ReturnStruct
[
'common'
]
>
;
...
...
src/jensen.js
View file @
d7fcd3dc
...
@@ -9,13 +9,14 @@ const QUERY_FILE_COUNT = 0x06;
...
@@ -9,13 +9,14 @@ const QUERY_FILE_COUNT = 0x06;
const
DELETE_FILE
=
0x07
;
const
DELETE_FILE
=
0x07
;
const
REQUEST_FIRMWARE_UPGRADE
=
0x08
;
const
REQUEST_FIRMWARE_UPGRADE
=
0x08
;
const
FIRMWARE_UPLOAD
=
0x09
;
const
FIRMWARE_UPLOAD
=
0x09
;
const
READ_CARD_INFO
=
0x10
;
const
FORMAT_CARD
=
0x11
;
const
GET_RECORDING_FILE
=
0x12
;
const
RESTORE_FACTORY_SETTINGS
=
0x13
;
const
DEVICE_MSG_TEST
=
0x0a
;
const
DEVICE_MSG_TEST
=
0x0a
;
const
BNC_DEMO_TEST
=
0x0a
;
const
BNC_DEMO_TEST
=
0x0a
;
const
GET_SETTINGS
=
0x0b
;
const
GET_SETTINGS
=
0x0b
;
const
SET_SETTINGS
=
0x0c
;
const
SET_SETTINGS
=
0x0c
;
const
READ_CARD_INFO
=
0x10
;
const
FORMAT_CARD
=
0x11
;
const
GET_RECORDING_FILE
=
0x12
;
const
GET_FILE_BLOCK
=
0x0d
;
const
GET_FILE_BLOCK
=
0x0d
;
const
FACTORY_RESET
=
0xf00b
;
const
FACTORY_RESET
=
0xf00b
;
...
@@ -34,15 +35,16 @@ const COMMAND_NAMES = [
...
@@ -34,15 +35,16 @@ const COMMAND_NAMES = [
'delete-file'
,
'delete-file'
,
'request-firmware-upgrade'
,
'request-firmware-upgrade'
,
'firmware-upload'
,
'firmware-upload'
,
'demo-test'
,
'read card info'
,
'format card'
,
'get recording file'
,
'restore factory settings'
,
'device msg test'
,
'bnc demo test'
,
'get-settings'
,
'get-settings'
,
'set-settings'
,
'set-settings'
,
'd'
,
'get file block'
,
'e'
,
'factory reset'
,
'f'
,
'get-card-info'
,
'optimize'
,
'get-recording'
,
];
];
function
Jensen
()
{
function
Jensen
()
{
...
@@ -299,33 +301,6 @@ function Jensen() {
...
@@ -299,33 +301,6 @@ function Jensen() {
}
}
};
};
/*
const receive = function (result) {
for (let i = 0; i < result.data.byteLength; i++) {
buffer.push(result.data.getInt8(i));
}
while (true) {
let msg = decode();
if (msg == null) break;
var cname = msg.id == FACTORY_RESET ? 'factory-reset' : COMMAND_NAMES[msg.id];
Logger.debug('jensen', 'receive', 'recv: ' + cname + ', seq: ' + msg.sequence + ', data bytes: ' + msg.body?.length + ', data: ' + msg.body.slice(0, 16).join(','));
try {
let handler = Jensen.handlers[msg.id];
let r = handler(msg, self);
if (r) trigger(r, msg.id);
}
catch (e) {
trigger(e);
Logger.error('jensen', 'receive', 'recv: ' + COMMAND_NAMES[msg.id] + ', seq: ' + msg.sequence + ', error: ' + String(e));
}
sendNext();
}
device.transferIn(2, 1024).then(function (r) {
receive(r);
});
}
*/
const
receive
=
function
(
result
)
{
const
receive
=
function
(
result
)
{
totalBytes
+=
result
.
data
.
byteLength
;
totalBytes
+=
result
.
data
.
byteLength
;
// 做一个回调,怎么样找到它呢?
// 做一个回调,怎么样找到它呢?
...
@@ -575,6 +550,10 @@ Jensen.prototype.factoryReset = async function (seconds) {
...
@@ -575,6 +550,10 @@ Jensen.prototype.factoryReset = async function (seconds) {
if
(
this
.
versionNumber
<
327705
)
return
null
;
if
(
this
.
versionNumber
<
327705
)
return
null
;
return
this
.
send
(
new
Command
(
FACTORY_RESET
),
seconds
);
return
this
.
send
(
new
Command
(
FACTORY_RESET
),
seconds
);
};
};
Jensen
.
prototype
.
restoreFactorySettings
=
async
function
(
seconds
)
{
if
(
this
.
versionNumber
<
393475
)
return
null
;
return
this
.
send
(
new
Command
(
RESTORE_FACTORY_SETTINGS
),
seconds
);
};
Jensen
.
prototype
.
listFiles
=
async
function
()
{
Jensen
.
prototype
.
listFiles
=
async
function
()
{
let
tag
=
'filelist'
;
let
tag
=
'filelist'
;
if
(
this
[
tag
]
!=
null
)
return
null
;
if
(
this
[
tag
]
!=
null
)
return
null
;
...
@@ -898,6 +877,7 @@ Jensen.registerHandler(GET_SETTINGS, (msg) => {
...
@@ -898,6 +877,7 @@ Jensen.registerHandler(GET_SETTINGS, (msg) => {
});
});
Jensen
.
registerHandler
(
SET_SETTINGS
,
commonMessageParser
);
Jensen
.
registerHandler
(
SET_SETTINGS
,
commonMessageParser
);
Jensen
.
registerHandler
(
FACTORY_RESET
,
commonMessageParser
);
Jensen
.
registerHandler
(
FACTORY_RESET
,
commonMessageParser
);
Jensen
.
registerHandler
(
RESTORE_FACTORY_SETTINGS
,
commonMessageParser
);
Jensen
.
registerHandler
(
REQUEST_FIRMWARE_UPGRADE
,
(
msg
)
=>
{
Jensen
.
registerHandler
(
REQUEST_FIRMWARE_UPGRADE
,
(
msg
)
=>
{
let
rst
=
''
;
let
rst
=
''
;
let
c
=
msg
.
body
[
0
];
let
c
=
msg
.
body
[
0
];
...
...
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