Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
U
usp-js
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WebSDK
usp-js
Commits
c6d6d0ae
Commit
c6d6d0ae
authored
4 years ago
by
Marin Karamihalev
Browse files
Options
Downloads
Patches
Plain Diff
README update
parent
4948aa67
No related branches found
Branches containing commit
Tags
0.0.3
Tags containing commit
No related merge requests found
Pipeline
#8737
passed
4 years ago
Stage: install
Stage: unit-testing
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+18
-20
18 additions, 20 deletions
README.md
package.json
+1
-1
1 addition, 1 deletion
package.json
with
19 additions
and
21 deletions
README.md
+
18
−
20
View file @
c6d6d0ae
...
...
@@ -13,18 +13,18 @@ Helper library for easy usp communication using mqtt over tcp or ws.
const
connect
=
require
(
"
usp-js
"
).
default
const
run
=
async
()
=>
{
// Connect
to device
const
device
=
await
connect
({
// Connect
const
usp
=
await
connect
({
host
:
"
192.168.1.1
"
,
username
:
"
admin
"
,
password
:
"
admin
"
});
// Get property
await
device
.
get
(
"
Device.WiFi.
"
).
then
(
console
.
log
);
await
usp
.
get
(
"
Device.WiFi.
"
).
then
(
console
.
log
);
// Disconnect
await
device
.
disconnect
();
await
usp
.
disconnect
();
};
run
();
...
...
@@ -36,13 +36,13 @@ run();
-
Connect
```
javascript
// options are based on https://github.com/mqttjs/MQTT.js#mqttconnecturl-options
const
device
=
await
connect
(
options
);
const
usp
=
await
connect
(
options
);
```
-
Get
-
get object - all object end with a dot
```
javascript
await
device
.
get
(
"
Device.Time.
"
);
await
usp
.
get
(
"
Device.Time.
"
);
// => {
// "CurrentLocalTime": "2020-12-15T12:33:19Z",
// "Enable": true,
...
...
@@ -52,12 +52,12 @@ const device = await connect(options);
- get property
```javascript
await
device
.get("Device.Time.CurrentLocalTime"); // => "2020-12-15T12:33:19Z"
await
usp
.get("Device.Time.CurrentLocalTime"); // => "2020-12-15T12:33:19Z"
```
- get multiple paths
```javascript
await
device
.get(["Device.WiFi.Radio.1.", "Device.WiFi.Radio.2."]);
await
usp
.get(["Device.WiFi.Radio.1.", "Device.WiFi.Radio.2."]);
// => [
// { ... },
// { ... }
...
...
@@ -66,14 +66,14 @@ const device = await connect(options);
- get using pattern
```javascript
await
device
.get('Device.Ethernet.Interface.[Alias=="WAN"].CurrentBitRate'); // => 0
await
usp
.get('Device.Ethernet.Interface.[Alias=="WAN"].CurrentBitRate'); // => 0
```
- resolve references in get
```javascript
await
device
.get("Device.WiFi.Radio.1.").then(
device
.resolve); // => { ... }
await
usp
.get("Device.WiFi.Radio.1.").then(
usp
.resolve); // => { ... }
// or if deeper resolution is needed (be careful when using level, going above 3 often causes an infinite reference loop)
await
device
.get("Device.WiFi.Radio.1.").then(msg =>
device
.resolve(msg, 3 /* level - defaults to 1 */)); // => { ... }
await
usp
.get("Device.WiFi.Radio.1.").then(msg =>
usp
.resolve(msg, 3 /* level - defaults to 1 */)); // => { ... }
```
...
...
@@ -81,39 +81,37 @@ const device = await connect(options);
-
set object - does not need to have all attributes, but some may be required (check USP Reference)
```
javascript
await
device
.
set
(
"
Device.WiFi.Radio.1.
"
,
{
Name
:
"
radio-1
"
});
// => void
await
usp
.
set
(
"
Device.WiFi.Radio.1.
"
,
{
Name
:
"
radio-1
"
});
// => void
```
-
set property
```
javascript
await
device
.
set
(
"
Device.WiFi.Radio.1.Name
"
,
"
radio-1
"
);
// => void
await
usp
.
set
(
"
Device.WiFi.Radio.1.Name
"
,
"
radio-1
"
);
// => void
```
-
Operate - WIP (response message not working yet)
-
operate without no arguments
```
javascript
await
device
.
operate
(
"
Device.SelfTestDiagnostics()
"
);
await
usp
.
operate
(
"
Device.SelfTestDiagnostics()
"
);
```
-
operate with arguments (for required args check USP Reference)
```
javascript
await
device
.
operate
(
"
Device.IP.Diagnostics.IPPing()
"
,
{
Host
:
"
iopsys.eu
"
});
await
usp
.
operate
(
"
Device.IP.Diagnostics.IPPing()
"
,
{
Host
:
"
iopsys.eu
"
});
```
-
Add
-
add with no arguments - adds a new default object
<br>
```
javascript
await
device
.
add
(
"
Device.NAT.PortMapping.
"
);
// => "Device.NAT.PortMapping.3."
await
usp
.
add
(
"
Device.NAT.PortMapping.
"
);
// => "Device.NAT.PortMapping.3."
```
-
add with arguments - adds a new object with provided values
<br>
```
javascript
await
device
.
add
(
"
Device.NAT.PortMapping.
"
,
{
await
usp
.
add
(
"
Device.NAT.PortMapping.
"
,
{
Description
:
"
webserver1-set
"
,
ExternalPort
:
"
80
"
,
Protocol
:
"
TCP
"
,
...
...
@@ -126,5 +124,5 @@ const device = await connect(options);
-
Delete
```
javascript
await
device
.
del
(
"
Device.NAT.PortMapping.4.
"
);
// => void
await
usp
.
del
(
"
Device.NAT.PortMapping.4.
"
);
// => void
```
\ No newline at end of file
This diff is collapsed.
Click to expand it.
package.json
+
1
−
1
View file @
c6d6d0ae
{
"name"
:
"usp-js"
,
"version"
:
"0.0.
2
"
,
"version"
:
"0.0.
3
"
,
"description"
:
"Helper library for easy usp communication using mqtt over tcp or ws."
,
"main"
:
"build/index.js"
,
"scripts"
:
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment