File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 8181
8282 - name : Publish to npm
8383 run : |
84+ cp README.npm.md protobuf_definitions/README.md
8485 cd protobuf_definitions
8586 npm publish --access public --tag latest
8687 env :
Original file line number Diff line number Diff line change 1+ # @blueyerobotics/protocol-definitions
2+
3+ TypeScript protobuf definitions for Blueye Robotics protocols generated using [ ts-proto] ( https://github.com/stephenh/ts-proto ) .
4+
5+ ## Installation
6+
7+ ``` bash
8+ npm install @blueyerobotics/protocol-definitions
9+ ```
10+
11+ ## Usage
12+
13+ ``` ts
14+ import { blueye } from " @blueyerobotics/protocol-definitions" ;
15+
16+ // Create a new GetBatteryReq message
17+ const request = blueye .protocol .GetBatteryReq .create ();
18+
19+ // Serialize the message to a Uint8Array (binary)
20+ const binary = blueye .protocol .GetBatteryReq .encode (request ).finish ();
21+
22+ // ...
23+
24+ // For demonstration, we will simulate a response from the device
25+ const response = blueye .protocol .GetBatteryRep .create ({
26+ battery: {
27+ level: 85 ,
28+ voltage: 12.5 ,
29+ temperature: 25 ,
30+ },
31+ });
32+
33+ const binaryResponse = blueye .protocol .GetBatteryRep .encode (response ).finish ();
34+
35+ // Decode a binary response back into a message
36+ const decoded = blueye .protocol .GetBatteryRep .decode (binaryResponse );
37+
38+ // Access fields
39+ console .log (decoded .battery ?.level );
40+ ```
You can’t perform that action at this time.
0 commit comments