@blueyerobotics/blueye-ts 3.0.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/example.js +1 -1
- package/dist/src/client.d.ts +1 -1
- package/dist/src/client.js +18 -7
- package/package.json +8 -8
package/dist/example.js
CHANGED
|
@@ -14,7 +14,7 @@ const main = async () => {
|
|
|
14
14
|
await client.sendControl("LightsCtrl", { lights: { value: 1 } });
|
|
15
15
|
});
|
|
16
16
|
// subscribe to battery telemetry updates
|
|
17
|
-
client.on("BatteryTel", data => {
|
|
17
|
+
client.on("BatteryTel", (data) => {
|
|
18
18
|
console.log("received BatteryTel:", data);
|
|
19
19
|
});
|
|
20
20
|
client.connect();
|
package/dist/src/client.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ export declare class BlueyeClient extends Emitter<Events> {
|
|
|
38
38
|
private rpc;
|
|
39
39
|
private pub;
|
|
40
40
|
private logger;
|
|
41
|
-
constructor({ subUrl, rpcUrl, pubUrl, timeout, logLevel, autoConnect }?: Options);
|
|
41
|
+
constructor({ subUrl, rpcUrl, pubUrl, timeout, logLevel, autoConnect, }?: Options);
|
|
42
42
|
private updateState;
|
|
43
43
|
connect(): void;
|
|
44
44
|
disconnect(): void;
|
package/dist/src/client.js
CHANGED
|
@@ -24,10 +24,13 @@ class BlueyeClient extends strict_event_emitter_1.Emitter {
|
|
|
24
24
|
rpc;
|
|
25
25
|
pub;
|
|
26
26
|
logger;
|
|
27
|
-
constructor({ subUrl = DEFAULT_SUB_URL, rpcUrl = DEFAULT_RPC_URL, pubUrl = DEFAULT_PUB_URL, timeout = 2000, logLevel = consola_1.LogLevels.info, autoConnect = false } = {}) {
|
|
27
|
+
constructor({ subUrl = DEFAULT_SUB_URL, rpcUrl = DEFAULT_RPC_URL, pubUrl = DEFAULT_PUB_URL, timeout = 2000, logLevel = consola_1.LogLevels.info, autoConnect = false, } = {}) {
|
|
28
28
|
super();
|
|
29
29
|
this.timeout = timeout;
|
|
30
|
-
this.logger = (0, consola_1.createConsola)({
|
|
30
|
+
this.logger = (0, consola_1.createConsola)({
|
|
31
|
+
level: logLevel,
|
|
32
|
+
formatOptions: { colors: true, compact: false },
|
|
33
|
+
});
|
|
31
34
|
this.subUrl = subUrl;
|
|
32
35
|
this.rpcUrl = rpcUrl;
|
|
33
36
|
this.pubUrl = pubUrl;
|
|
@@ -95,13 +98,16 @@ class BlueyeClient extends strict_event_emitter_1.Emitter {
|
|
|
95
98
|
const encoded = protocol.encode(message).finish();
|
|
96
99
|
const { key, data } = await Promise.race([
|
|
97
100
|
new Promise((_, reject) => setTimeout(() => reject(new Error("[rpc] request timed out")), this.timeout)),
|
|
98
|
-
new Promise(resolve => {
|
|
101
|
+
new Promise((resolve) => {
|
|
99
102
|
// @ts-ignore
|
|
100
103
|
this.rpc.once("message", (topic, msg) => {
|
|
101
104
|
resolve({ key: topic.toString().split(".").at(-1), data: msg });
|
|
102
105
|
});
|
|
103
|
-
this.rpc.send([
|
|
104
|
-
|
|
106
|
+
this.rpc.send([
|
|
107
|
+
buffer_1.Buffer.from(`blueye.protocol.${req}`),
|
|
108
|
+
buffer_1.Buffer.from(encoded),
|
|
109
|
+
]);
|
|
110
|
+
}),
|
|
105
111
|
]);
|
|
106
112
|
if (key === "Empty") {
|
|
107
113
|
return null;
|
|
@@ -115,7 +121,9 @@ class BlueyeClient extends strict_event_emitter_1.Emitter {
|
|
|
115
121
|
return result;
|
|
116
122
|
}
|
|
117
123
|
async getTelemetry(type) {
|
|
118
|
-
const response = await this.sendRequest("GetTelemetryReq", {
|
|
124
|
+
const response = await this.sendRequest("GetTelemetryReq", {
|
|
125
|
+
messageType: type,
|
|
126
|
+
});
|
|
119
127
|
const { payload } = schema_1.telemetrySchema.parse(response);
|
|
120
128
|
const { typeUrl, value } = payload;
|
|
121
129
|
if (!(0, exports.isInProtocol)(typeUrl) || !typeUrl.endsWith("Tel")) {
|
|
@@ -133,7 +141,10 @@ class BlueyeClient extends strict_event_emitter_1.Emitter {
|
|
|
133
141
|
const message = protocol.create(opts);
|
|
134
142
|
const encoded = protocol.encode(message).finish();
|
|
135
143
|
this.logger.debug("[pub] sending control:", ctrl, message);
|
|
136
|
-
this.pub.send([
|
|
144
|
+
this.pub.send([
|
|
145
|
+
buffer_1.Buffer.from(`blueye.protocol.${ctrl}`),
|
|
146
|
+
buffer_1.Buffer.from(encoded),
|
|
147
|
+
]);
|
|
137
148
|
}
|
|
138
149
|
}
|
|
139
150
|
exports.BlueyeClient = BlueyeClient;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blueyerobotics/blueye-ts",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "A TypeScript client for interacting with Blueye underwater drones.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,15 +11,11 @@
|
|
|
11
11
|
"files": [
|
|
12
12
|
"dist"
|
|
13
13
|
],
|
|
14
|
-
"scripts": {
|
|
15
|
-
"start": "node dist/example.js",
|
|
16
|
-
"build": "tsc"
|
|
17
|
-
},
|
|
18
14
|
"keywords": [],
|
|
19
15
|
"author": "Blueye <contact@blueye.no> (https://blueye.no/)",
|
|
20
16
|
"license": "LGPL-3.0-only",
|
|
21
17
|
"dependencies": {
|
|
22
|
-
"@blueyerobotics/protocol-definitions": "3.2.0-
|
|
18
|
+
"@blueyerobotics/protocol-definitions": "3.2.0-946df8e4",
|
|
23
19
|
"buffer": "^6.0.3",
|
|
24
20
|
"consola": "^3.4.2",
|
|
25
21
|
"jszmq": "^0.1.2",
|
|
@@ -27,6 +23,10 @@
|
|
|
27
23
|
"zod": "^3.25.67"
|
|
28
24
|
},
|
|
29
25
|
"devDependencies": {
|
|
30
|
-
"typescript": "^5.
|
|
26
|
+
"typescript": "^5.9.2"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"start": "node dist/example.js",
|
|
30
|
+
"build": "tsc"
|
|
31
31
|
}
|
|
32
|
-
}
|
|
32
|
+
}
|