@hangtime/grip-connect 0.1.0 → 0.1.1

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.
Files changed (45) hide show
  1. package/README.md +9 -6
  2. package/package.json +1 -1
  3. package/src/calibration.d.ts +6 -0
  4. package/src/{calibrate.js → calibration.js} +4 -3
  5. package/src/{calibrate.ts → calibration.ts} +4 -3
  6. package/src/commands/climbro.d.ts +6 -0
  7. package/src/commands/climbro.js +5 -0
  8. package/src/commands/climbro.ts +6 -0
  9. package/src/commands/entralpi.d.ts +6 -0
  10. package/src/commands/entralpi.js +5 -0
  11. package/src/commands/entralpi.ts +6 -0
  12. package/src/commands/index.d.ts +5 -0
  13. package/src/commands/index.js +5 -0
  14. package/src/commands/index.ts +9 -0
  15. package/src/commands/motherboard.d.ts +6 -0
  16. package/src/commands/motherboard.js +13 -0
  17. package/src/commands/motherboard.ts +14 -0
  18. package/src/commands/smartboard.d.ts +6 -0
  19. package/src/commands/smartboard.js +5 -0
  20. package/src/commands/smartboard.ts +6 -0
  21. package/src/commands/tindeq.d.ts +11 -0
  22. package/src/commands/tindeq.js +23 -0
  23. package/src/commands/tindeq.ts +25 -0
  24. package/src/commands/types.d.ts +18 -0
  25. package/src/commands/types.js +1 -0
  26. package/src/commands/types.ts +21 -0
  27. package/src/connect.js +1 -1
  28. package/src/connect.ts +1 -1
  29. package/src/devices/index.d.ts +1 -1
  30. package/src/devices/index.js +1 -1
  31. package/src/devices/index.ts +1 -1
  32. package/src/devices/tindeq.d.ts +0 -15
  33. package/src/devices/tindeq.js +0 -15
  34. package/src/devices/tindeq.ts +0 -17
  35. package/src/index.d.ts +2 -1
  36. package/src/index.js +2 -3
  37. package/src/index.ts +3 -4
  38. package/src/{calibrate.d.ts → stop.d.ts} +1 -1
  39. package/src/stop.js +19 -0
  40. package/src/stop.ts +20 -0
  41. package/src/stream.js +10 -4
  42. package/src/stream.ts +10 -4
  43. /package/src/devices/{moterboard.d.ts → motherboard.d.ts} +0 -0
  44. /package/src/devices/{moterboard.js → motherboard.js} +0 -0
  45. /package/src/devices/{moterboard.ts → motherboard.ts} +0 -0
package/README.md CHANGED
@@ -63,7 +63,7 @@ Simply importing the utilities you need from `@hangtime/grip-connect`. Devices t
63
63
  ```
64
64
 
65
65
  ```js
66
- import { Motherboard, calibrate, connect, disconnect, notify, read, stream } from "@hangtime/grip-connect"
66
+ import { Motherboard, calibration, connect, disconnect, notify, read, stream } from "@hangtime/grip-connect"
67
67
 
68
68
  const motherboardButton = document.querySelector("#motherboard")
69
69
 
@@ -74,19 +74,22 @@ motherboardButton.addEventListener("click", () => {
74
74
  console.log(data)
75
75
  })
76
76
 
77
- // read battery + device info
77
+ // Read battery + device info
78
78
  await read(Motherboard, "battery", "level", 250)
79
79
  await read(Motherboard, "device", "manufacturer", 250)
80
80
  await read(Motherboard, "device", "hardware", 250)
81
81
  await read(Motherboard, "device", "firmware", 250)
82
82
 
83
- // read calibration (required before reading data)
84
- await calibrate(Motherboard)
83
+ // Read calibration (required before reading data)
84
+ await calibration(Motherboard)
85
85
 
86
- // start streaming for a minute
86
+ // Start streaming (for a minute) remove parameter for a continues stream
87
87
  await stream(Motherboard, 60000)
88
88
 
89
- // disconnect from device after we are done
89
+ // Manually call stop method if stream is continues
90
+ // await stop(Motherboard)
91
+
92
+ // Disconnect from device after we are done
90
93
  disconnect(Motherboard)
91
94
  })
92
95
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hangtime/grip-connect",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "A client that can establish connections with various Force-Sensing Hangboards/Plates used by climbers for strength measurement. Examples of such hangboards include the Motherboard, Climbro, SmartBoard, Entralpi or Tindeq Progressor",
5
5
  "main": "src/index.ts",
6
6
  "scripts": {
@@ -0,0 +1,6 @@
1
+ import { Device } from "./devices/types";
2
+ /**
3
+ * write command to get calibration
4
+ * @param board
5
+ */
6
+ export declare const calibration: (board: Device) => Promise<void>;
@@ -1,15 +1,16 @@
1
1
  import { Motherboard } from "./devices";
2
+ import { MotherboardCommands } from "./commands";
2
3
  import { write } from "./write";
3
4
  /**
4
- * read calibration
5
+ * write command to get calibration
5
6
  * @param board
6
7
  */
7
- export const calibrate = async (board) => {
8
+ export const calibration = async (board) => {
8
9
  if (!board.device)
9
10
  return;
10
11
  if (board.device.gatt?.connected) {
11
12
  if (board.name === "Motherboard") {
12
- await write(Motherboard, "uart", "tx", "C", 2500);
13
+ await write(Motherboard, "uart", "tx", String(MotherboardCommands.GET_CALIBRATION), 2500);
13
14
  }
14
15
  }
15
16
  };
@@ -1,16 +1,17 @@
1
1
  import { Device } from "./devices/types"
2
2
  import { Motherboard } from "./devices"
3
+ import { MotherboardCommands } from "./commands"
3
4
  import { write } from "./write"
4
5
 
5
6
  /**
6
- * read calibration
7
+ * write command to get calibration
7
8
  * @param board
8
9
  */
9
- export const calibrate = async (board: Device): Promise<void> => {
10
+ export const calibration = async (board: Device): Promise<void> => {
10
11
  if (!board.device) return
11
12
  if (board.device.gatt?.connected) {
12
13
  if (board.name === "Motherboard") {
13
- await write(Motherboard, "uart", "tx", "C", 2500)
14
+ await write(Motherboard, "uart", "tx", String(MotherboardCommands.GET_CALIBRATION), 2500)
14
15
  }
15
16
  }
16
17
  }
@@ -0,0 +1,6 @@
1
+ import { Commands } from "../commands/types";
2
+ /**
3
+ * Warning:
4
+ * Using other commands can seriously harm your device
5
+ */
6
+ export declare const ClimbroCommands: Commands;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Warning:
3
+ * Using other commands can seriously harm your device
4
+ */
5
+ export const ClimbroCommands = {};
@@ -0,0 +1,6 @@
1
+ import { Commands } from "../commands/types"
2
+ /**
3
+ * Warning:
4
+ * Using other commands can seriously harm your device
5
+ */
6
+ export const ClimbroCommands: Commands = {}
@@ -0,0 +1,6 @@
1
+ import { Commands } from "../commands/types";
2
+ /**
3
+ * Warning:
4
+ * Using other commands can seriously harm your device
5
+ */
6
+ export declare const EntralpiCommands: Commands;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Warning:
3
+ * Using other commands can seriously harm your device
4
+ */
5
+ export const EntralpiCommands = {};
@@ -0,0 +1,6 @@
1
+ import { Commands } from "../commands/types"
2
+ /**
3
+ * Warning:
4
+ * Using other commands can seriously harm your device
5
+ */
6
+ export const EntralpiCommands: Commands = {}
@@ -0,0 +1,5 @@
1
+ export { ClimbroCommands } from "./climbro";
2
+ export { EntralpiCommands } from "./entralpi";
3
+ export { MotherboardCommands } from "./motherboard";
4
+ export { SmartBoardCommands } from "./smartboard";
5
+ export { TindeqCommands } from "./tindeq";
@@ -0,0 +1,5 @@
1
+ export { ClimbroCommands } from "./climbro";
2
+ export { EntralpiCommands } from "./entralpi";
3
+ export { MotherboardCommands } from "./motherboard";
4
+ export { SmartBoardCommands } from "./smartboard";
5
+ export { TindeqCommands } from "./tindeq";
@@ -0,0 +1,9 @@
1
+ export { ClimbroCommands } from "./climbro"
2
+
3
+ export { EntralpiCommands } from "./entralpi"
4
+
5
+ export { MotherboardCommands } from "./motherboard"
6
+
7
+ export { SmartBoardCommands } from "./smartboard"
8
+
9
+ export { TindeqCommands } from "./tindeq"
@@ -0,0 +1,6 @@
1
+ import { Commands } from "../commands/types";
2
+ /**
3
+ * Warning:
4
+ * Using other commands can seriously harm your device
5
+ */
6
+ export declare const MotherboardCommands: Commands;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Warning:
3
+ * Using other commands can seriously harm your device
4
+ */
5
+ export const MotherboardCommands = {
6
+ GET_SERIAL: "#",
7
+ START_WEIGHT_MEAS: "S30",
8
+ STOP_WEIGHT_MEAS: "", // All commands will stop the data stream.
9
+ GET_CALIBRATION: "C",
10
+ SLEEP: 0,
11
+ GET_TEXT: "T",
12
+ DEBUG_STREAM: "D",
13
+ };
@@ -0,0 +1,14 @@
1
+ import { Commands } from "../commands/types"
2
+ /**
3
+ * Warning:
4
+ * Using other commands can seriously harm your device
5
+ */
6
+ export const MotherboardCommands: Commands = {
7
+ GET_SERIAL: "#",
8
+ START_WEIGHT_MEAS: "S30",
9
+ STOP_WEIGHT_MEAS: "", // All commands will stop the data stream.
10
+ GET_CALIBRATION: "C",
11
+ SLEEP: 0,
12
+ GET_TEXT: "T",
13
+ DEBUG_STREAM: "D",
14
+ }
@@ -0,0 +1,6 @@
1
+ import { Commands } from "../commands/types";
2
+ /**
3
+ * Warning:
4
+ * Using other commands can seriously harm your device
5
+ */
6
+ export declare const SmartBoardCommands: Commands;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Warning:
3
+ * Using other commands can seriously harm your device
4
+ */
5
+ export const SmartBoardCommands = {};
@@ -0,0 +1,6 @@
1
+ import { Commands } from "../commands/types"
2
+ /**
3
+ * Warning:
4
+ * Using other commands can seriously harm your device
5
+ */
6
+ export const SmartBoardCommands: Commands = {}
@@ -0,0 +1,11 @@
1
+ import { Commands } from "../commands/types";
2
+ /**
3
+ * Warning:
4
+ * Using other commands can seriously harm your device
5
+ */
6
+ export declare const TindeqCommands: Commands;
7
+ export declare const NotificationTypes: {
8
+ COMMAND_RESPONSE: number;
9
+ WEIGHT_MEASURE: number;
10
+ LOW_BATTERY_WARNING: number;
11
+ };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Warning:
3
+ * Using other commands can seriously harm your device
4
+ */
5
+ export const TindeqCommands = {
6
+ TARE_SCALE: 'd', // 0x64,
7
+ START_WEIGHT_MEAS: 'e', // 0x65,
8
+ STOP_WEIGHT_MEAS: 'f', // 0x66,
9
+ START_PEAK_RFD_MEAS: 'g', // 0x67,
10
+ START_PEAK_RFD_MEAS_SERIES: 'h', // 0x68,
11
+ ADD_CALIB_POINT: 'i', // 0x69,
12
+ SAVE_CALIB: 'j', // 0x6a,
13
+ GET_APP_VERSION: 'k', // 0x6b,
14
+ GET_ERR_INFO: 'l', // 0x6c,
15
+ CLR_ERR_INFO: 'm', // 0x6d,
16
+ SLEEP: 'n', // 0x6e,
17
+ GET_BATT_VLTG: 'o' // 0x6f,
18
+ };
19
+ export const NotificationTypes = {
20
+ COMMAND_RESPONSE: 0,
21
+ WEIGHT_MEASURE: 1,
22
+ LOW_BATTERY_WARNING: 2,
23
+ };
@@ -0,0 +1,25 @@
1
+ import { Commands } from "../commands/types"
2
+ /**
3
+ * Warning:
4
+ * Using other commands can seriously harm your device
5
+ */
6
+ export const TindeqCommands: Commands = {
7
+ TARE_SCALE: "d", // 0x64,
8
+ START_WEIGHT_MEAS: "e", // 0x65,
9
+ STOP_WEIGHT_MEAS: "f", // 0x66,
10
+ START_PEAK_RFD_MEAS: "g", // 0x67,
11
+ START_PEAK_RFD_MEAS_SERIES: "h", // 0x68,
12
+ ADD_CALIB_POINT: "i", // 0x69,
13
+ SAVE_CALIB: "j", // 0x6a,
14
+ GET_APP_VERSION: "k", // 0x6b,
15
+ GET_ERR_INFO: "l", // 0x6c,
16
+ CLR_ERR_INFO: "m", // 0x6d,
17
+ SLEEP: "n", // 0x6e,
18
+ GET_BATT_VLTG: "o", // 0x6f,
19
+ }
20
+
21
+ export const NotificationTypes = {
22
+ COMMAND_RESPONSE: 0,
23
+ WEIGHT_MEASURE: 1,
24
+ LOW_BATTERY_WARNING: 2,
25
+ }
@@ -0,0 +1,18 @@
1
+ export interface Commands {
2
+ START_WEIGHT_MEAS?: string;
3
+ STOP_WEIGHT_MEAS?: string;
4
+ SLEEP?: number | string;
5
+ GET_TEXT?: string;
6
+ GET_SERIAL?: string;
7
+ DEBUG_STREAM?: string;
8
+ GET_CALIBRATION?: string;
9
+ TARE_SCALE?: string;
10
+ START_PEAK_RFD_MEAS?: string;
11
+ START_PEAK_RFD_MEAS_SERIES?: string;
12
+ ADD_CALIB_POINT?: string;
13
+ SAVE_CALIB?: string;
14
+ GET_APP_VERSION?: string;
15
+ GET_ERR_INFO?: string;
16
+ CLR_ERR_INFO?: string;
17
+ GET_BATT_VLTG?: string;
18
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
1
+ export interface Commands {
2
+ // Motherboard, Tindeq
3
+ START_WEIGHT_MEAS?: string
4
+ STOP_WEIGHT_MEAS?: string
5
+ SLEEP?: number | string
6
+ // Motherboard
7
+ GET_TEXT?: string
8
+ GET_SERIAL?: string
9
+ DEBUG_STREAM?: string
10
+ GET_CALIBRATION?: string
11
+ // Tindeq
12
+ TARE_SCALE?: string
13
+ START_PEAK_RFD_MEAS?: string
14
+ START_PEAK_RFD_MEAS_SERIES?: string
15
+ ADD_CALIB_POINT?: string
16
+ SAVE_CALIB?: string
17
+ GET_APP_VERSION?: string
18
+ GET_ERR_INFO?: string
19
+ CLR_ERR_INFO?: string
20
+ GET_BATT_VLTG?: string
21
+ }
package/src/connect.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { notifyCallback } from "./notify";
2
- import { handleMotherboardData } from "./devices/moterboard";
2
+ import { handleMotherboardData } from "./devices/motherboard";
3
3
  import { handleEntralpiData } from "./devices/entralpi";
4
4
  let server;
5
5
  const receiveBuffer = [];
package/src/connect.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Device } from "./devices/types"
2
2
  import { notifyCallback } from "./notify"
3
- import { handleMotherboardData } from "./devices/moterboard"
3
+ import { handleMotherboardData } from "./devices/motherboard"
4
4
  import { handleEntralpiData } from "./devices/entralpi"
5
5
 
6
6
  let server: BluetoothRemoteGATTServer
@@ -1,5 +1,5 @@
1
1
  export { Climbro } from "./climbro";
2
2
  export { Entralpi } from "./entralpi";
3
- export { Motherboard } from "./moterboard";
3
+ export { Motherboard } from "./motherboard";
4
4
  export { SmartBoard } from "./smartboard";
5
5
  export { Tindeq } from "./tindeq";
@@ -1,5 +1,5 @@
1
1
  export { Climbro } from "./climbro";
2
2
  export { Entralpi } from "./entralpi";
3
- export { Motherboard } from "./moterboard";
3
+ export { Motherboard } from "./motherboard";
4
4
  export { SmartBoard } from "./smartboard";
5
5
  export { Tindeq } from "./tindeq";
@@ -2,7 +2,7 @@ export { Climbro } from "./climbro"
2
2
 
3
3
  export { Entralpi } from "./entralpi"
4
4
 
5
- export { Motherboard } from "./moterboard"
5
+ export { Motherboard } from "./motherboard"
6
6
 
7
7
  export { SmartBoard } from "./smartboard"
8
8
 
@@ -1,17 +1,2 @@
1
1
  import { Device } from "./types";
2
2
  export declare const Tindeq: Device;
3
- export declare const Commands: {
4
- TARE_SCALE: number;
5
- START_MEASURING: number;
6
- STOP_MEASURING: number;
7
- GET_APP_VERSION: number;
8
- GET_ERROR_INFO: number;
9
- CLEAR_ERR_INFO: number;
10
- GET_BATTERY_LEVEL: number;
11
- SLEEP: number;
12
- };
13
- export declare const NotificationTypes: {
14
- COMMAND_RESPONSE: number;
15
- WEIGHT_MEASURE: number;
16
- LOW_BATTERY_WARNING: number;
17
- };
@@ -20,18 +20,3 @@ export const Tindeq = {
20
20
  },
21
21
  ],
22
22
  };
23
- export const Commands = {
24
- TARE_SCALE: 0x64,
25
- START_MEASURING: 0x65,
26
- STOP_MEASURING: 0x66,
27
- GET_APP_VERSION: 0x6b,
28
- GET_ERROR_INFO: 0x6c,
29
- CLEAR_ERR_INFO: 0x6d,
30
- GET_BATTERY_LEVEL: 0x6f,
31
- SLEEP: 0x6e,
32
- };
33
- export const NotificationTypes = {
34
- COMMAND_RESPONSE: 0,
35
- WEIGHT_MEASURE: 1,
36
- LOW_BATTERY_WARNING: 2,
37
- };
@@ -22,20 +22,3 @@ export const Tindeq: Device = {
22
22
  },
23
23
  ],
24
24
  }
25
-
26
- export const Commands = {
27
- TARE_SCALE: 0x64,
28
- START_MEASURING: 0x65,
29
- STOP_MEASURING: 0x66,
30
- GET_APP_VERSION: 0x6b,
31
- GET_ERROR_INFO: 0x6c,
32
- CLEAR_ERR_INFO: 0x6d,
33
- GET_BATTERY_LEVEL: 0x6f,
34
- SLEEP: 0x6e,
35
- }
36
-
37
- export const NotificationTypes = {
38
- COMMAND_RESPONSE: 0,
39
- WEIGHT_MEASURE: 1,
40
- LOW_BATTERY_WARNING: 2,
41
- }
package/src/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  export { Climbro, Entralpi, Motherboard, SmartBoard, Tindeq } from "./devices/index";
2
- export { calibrate } from "./calibrate";
2
+ export { calibration } from "./calibration";
3
3
  export { connect } from "./connect";
4
4
  export { disconnect } from "./disconnect";
5
5
  export { notify } from "./notify";
6
6
  export { read } from "./read";
7
+ export { stop } from "./stop";
7
8
  export { stream } from "./stream";
package/src/index.js CHANGED
@@ -1,9 +1,8 @@
1
1
  export { Climbro, Entralpi, Motherboard, SmartBoard, Tindeq } from "./devices/index";
2
- export { calibrate } from "./calibrate";
2
+ export { calibration } from "./calibration";
3
3
  export { connect } from "./connect";
4
4
  export { disconnect } from "./disconnect";
5
5
  export { notify } from "./notify";
6
6
  export { read } from "./read";
7
+ export { stop } from "./stop";
7
8
  export { stream } from "./stream";
8
- // WARNING: Writing to device can seriously damage the device
9
- // export { write } from "./write"
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { Climbro, Entralpi, Motherboard, SmartBoard, Tindeq } from "./devices/index"
2
2
 
3
- export { calibrate } from "./calibrate"
3
+ export { calibration } from "./calibration"
4
4
 
5
5
  export { connect } from "./connect"
6
6
 
@@ -10,7 +10,6 @@ export { notify } from "./notify"
10
10
 
11
11
  export { read } from "./read"
12
12
 
13
- export { stream } from "./stream"
13
+ export { stop } from "./stop"
14
14
 
15
- // WARNING: Writing to device can seriously damage the device
16
- // export { write } from "./write"
15
+ export { stream } from "./stream"
@@ -3,4 +3,4 @@ import { Device } from "./devices/types";
3
3
  * read calibration
4
4
  * @param board
5
5
  */
6
- export declare const calibrate: (board: Device) => Promise<void>;
6
+ export declare const stop: (board: Device) => Promise<void>;
package/src/stop.js ADDED
@@ -0,0 +1,19 @@
1
+ import { Motherboard, Tindeq } from "./devices";
2
+ import { MotherboardCommands, TindeqCommands } from "./commands";
3
+ import { write } from "./write";
4
+ /**
5
+ * read calibration
6
+ * @param board
7
+ */
8
+ export const stop = async (board) => {
9
+ if (!board.device)
10
+ return;
11
+ if (board.device.gatt?.connected) {
12
+ if (board.name === "Motherboard") {
13
+ await write(Motherboard, "uart", "tx", String(MotherboardCommands.STOP_WEIGHT_MEAS), 0);
14
+ }
15
+ if (board.name === "Tindeq") {
16
+ await write(Tindeq, "progressor", "tx", String(TindeqCommands.STOP_WEIGHT_MEAS), 0);
17
+ }
18
+ }
19
+ };
package/src/stop.ts ADDED
@@ -0,0 +1,20 @@
1
+ import { Device } from "./devices/types"
2
+ import { Motherboard, Tindeq } from "./devices"
3
+ import { MotherboardCommands, TindeqCommands } from "./commands"
4
+ import { write } from "./write"
5
+
6
+ /**
7
+ * read calibration
8
+ * @param board
9
+ */
10
+ export const stop = async (board: Device): Promise<void> => {
11
+ if (!board.device) return
12
+ if (board.device.gatt?.connected) {
13
+ if (board.name === "Motherboard") {
14
+ await write(Motherboard, "uart", "tx", String(MotherboardCommands.STOP_WEIGHT_MEAS), 0)
15
+ }
16
+ if (board.name === "Tindeq") {
17
+ await write(Tindeq, "progressor", "tx", String(TindeqCommands.STOP_WEIGHT_MEAS), 0)
18
+ }
19
+ }
20
+ }
package/src/stream.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import { Motherboard, Tindeq } from "./devices";
2
+ import { MotherboardCommands, TindeqCommands } from "./commands";
2
3
  import { write } from "./write";
4
+ import { stop } from "./stop";
3
5
  /**
4
6
  * stream output
5
7
  * @param board
@@ -11,15 +13,19 @@ export const stream = async (board, duration = 0) => {
11
13
  if (board.name === "Motherboard") {
12
14
  // TODO: add check if device is recalibrated
13
15
  // start stream
14
- await write(Motherboard, "uart", "tx", "S30", duration);
16
+ await write(Motherboard, "uart", "tx", String(MotherboardCommands.START_WEIGHT_MEAS), duration);
15
17
  // end stream
16
- await write(Motherboard, "uart", "tx", "", 0);
18
+ if (duration !== 0) {
19
+ await stop(Motherboard);
20
+ }
17
21
  }
18
22
  if (board.name === "Tindeq") {
19
23
  // start stream
20
- await write(Tindeq, "progressor", "tx", "e", duration);
24
+ await write(Tindeq, "progressor", "tx", String(TindeqCommands.START_WEIGHT_MEAS), duration);
21
25
  // end stream
22
- await write(Tindeq, "progressor", "tx", "f", 0);
26
+ if (duration !== 0) {
27
+ await stop(Tindeq);
28
+ }
23
29
  }
24
30
  }
25
31
  };
package/src/stream.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { Device } from "./devices/types"
2
2
  import { Motherboard, Tindeq } from "./devices"
3
+ import { MotherboardCommands, TindeqCommands } from "./commands"
3
4
  import { write } from "./write"
5
+ import { stop } from "./stop"
4
6
 
5
7
  /**
6
8
  * stream output
@@ -12,15 +14,19 @@ export const stream = async (board: Device, duration: number = 0): Promise<void>
12
14
  if (board.name === "Motherboard") {
13
15
  // TODO: add check if device is recalibrated
14
16
  // start stream
15
- await write(Motherboard, "uart", "tx", "S30", duration)
17
+ await write(Motherboard, "uart", "tx", String(MotherboardCommands.START_WEIGHT_MEAS), duration)
16
18
  // end stream
17
- await write(Motherboard, "uart", "tx", "", 0)
19
+ if (duration !== 0) {
20
+ await stop(Motherboard)
21
+ }
18
22
  }
19
23
  if (board.name === "Tindeq") {
20
24
  // start stream
21
- await write(Tindeq, "progressor", "tx", "e", duration)
25
+ await write(Tindeq, "progressor", "tx", String(TindeqCommands.START_WEIGHT_MEAS), duration)
22
26
  // end stream
23
- await write(Tindeq, "progressor", "tx", "f", 0)
27
+ if (duration !== 0) {
28
+ await stop(Tindeq)
29
+ }
24
30
  }
25
31
  }
26
32
  }
File without changes
File without changes