@hangtime/grip-connect 0.2.0 → 0.2.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.
- package/README.md +8 -5
- package/package.json +2 -2
- package/src/battery.ts +4 -4
- package/src/calibration.ts +1 -1
- package/src/commands/index.ts +2 -2
- package/src/commands/{tindeq.ts → progressor.ts} +7 -3
- package/src/commands/types.ts +5 -5
- package/src/connect.ts +64 -5
- package/src/devices/index.ts +1 -1
- package/src/devices/{tindeq.ts → progressor.ts} +17 -5
- package/src/index.ts +1 -1
- package/src/info.ts +6 -6
- package/src/stop.ts +5 -5
- package/src/stream.ts +6 -6
- package/src/write.ts +7 -4
- package/src/battery.d.ts +0 -6
- package/src/battery.js +0 -19
- package/src/calibration.d.ts +0 -6
- package/src/calibration.js +0 -15
- package/src/characteristic.d.ts +0 -9
- package/src/characteristic.js +0 -15
- package/src/commands/climbro.d.ts +0 -6
- package/src/commands/climbro.js +0 -5
- package/src/commands/entralpi.d.ts +0 -6
- package/src/commands/entralpi.js +0 -5
- package/src/commands/index.d.ts +0 -5
- package/src/commands/index.js +0 -5
- package/src/commands/motherboard.d.ts +0 -6
- package/src/commands/motherboard.js +0 -13
- package/src/commands/smartboard.d.ts +0 -6
- package/src/commands/smartboard.js +0 -5
- package/src/commands/tindeq.d.ts +0 -11
- package/src/commands/tindeq.js +0 -23
- package/src/commands/types.d.ts +0 -18
- package/src/commands/types.js +0 -1
- package/src/connect.d.ts +0 -7
- package/src/connect.js +0 -156
- package/src/data.d.ts +0 -8
- package/src/data.js +0 -109
- package/src/devices/climbro.d.ts +0 -2
- package/src/devices/climbro.js +0 -4
- package/src/devices/entralpi.d.ts +0 -2
- package/src/devices/entralpi.js +0 -52
- package/src/devices/index.d.ts +0 -5
- package/src/devices/index.js +0 -5
- package/src/devices/motherboard.d.ts +0 -2
- package/src/devices/motherboard.js +0 -79
- package/src/devices/smartboard.d.ts +0 -2
- package/src/devices/smartboard.js +0 -4
- package/src/devices/tindeq.d.ts +0 -2
- package/src/devices/tindeq.js +0 -22
- package/src/devices/types.d.ts +0 -20
- package/src/devices/types.js +0 -1
- package/src/disconnect.d.ts +0 -6
- package/src/disconnect.js +0 -10
- package/src/index.d.ts +0 -10
- package/src/index.js +0 -12
- package/src/info.d.ts +0 -6
- package/src/info.js +0 -23
- package/src/is-connected.d.ts +0 -7
- package/src/is-connected.js +0 -10
- package/src/notify.d.ts +0 -4
- package/src/notify.js +0 -6
- package/src/read.d.ts +0 -6
- package/src/read.js +0 -45
- package/src/stop.d.ts +0 -6
- package/src/stop.js +0 -18
- package/src/stream.d.ts +0 -6
- package/src/stream.js +0 -35
- package/src/write.d.ts +0 -7
- package/src/write.js +0 -35
package/src/stop.d.ts
DELETED
package/src/stop.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { write } from "./write";
|
|
2
|
-
import { isConnected } from "./is-connected";
|
|
3
|
-
import { Motherboard, Tindeq } from "./devices";
|
|
4
|
-
import { MotherboardCommands, TindeqCommands } from "./commands";
|
|
5
|
-
/**
|
|
6
|
-
* read calibration
|
|
7
|
-
* @param board
|
|
8
|
-
*/
|
|
9
|
-
export const stop = async (board) => {
|
|
10
|
-
if (isConnected(board)) {
|
|
11
|
-
if (board.name === "Motherboard") {
|
|
12
|
-
await write(Motherboard, "uart", "tx", String(MotherboardCommands.STOP_WEIGHT_MEAS), 0);
|
|
13
|
-
}
|
|
14
|
-
if (board.name === "Tindeq") {
|
|
15
|
-
await write(Tindeq, "progressor", "tx", String(TindeqCommands.STOP_WEIGHT_MEAS), 0);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
};
|
package/src/stream.d.ts
DELETED
package/src/stream.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { isConnected } from "./is-connected";
|
|
2
|
-
import { write } from "./write";
|
|
3
|
-
import { stop } from "./stop";
|
|
4
|
-
import { Motherboard, Tindeq } from "./devices";
|
|
5
|
-
import { MotherboardCommands, TindeqCommands } from "./commands";
|
|
6
|
-
import { CALIBRATION } from "./data";
|
|
7
|
-
import { calibration } from "./calibration";
|
|
8
|
-
/**
|
|
9
|
-
* stream output
|
|
10
|
-
* @param board
|
|
11
|
-
*/
|
|
12
|
-
export const stream = async (board, duration = 0) => {
|
|
13
|
-
if (isConnected(board)) {
|
|
14
|
-
if (board.name === "Motherboard") {
|
|
15
|
-
// read calibration (required before reading data)
|
|
16
|
-
if (!CALIBRATION[0].length) {
|
|
17
|
-
await calibration(Motherboard);
|
|
18
|
-
}
|
|
19
|
-
// start stream
|
|
20
|
-
await write(Motherboard, "uart", "tx", String(MotherboardCommands.START_WEIGHT_MEAS), duration);
|
|
21
|
-
// end stream if duration is set
|
|
22
|
-
if (duration !== 0) {
|
|
23
|
-
await stop(Motherboard);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (board.name === "Tindeq") {
|
|
27
|
-
// start stream
|
|
28
|
-
await write(Tindeq, "progressor", "tx", String(TindeqCommands.START_WEIGHT_MEAS), duration);
|
|
29
|
-
// end stream if duration is set
|
|
30
|
-
if (duration !== 0) {
|
|
31
|
-
await stop(Tindeq);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
};
|
package/src/write.d.ts
DELETED
package/src/write.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { isConnected } from "./is-connected";
|
|
2
|
-
import { getCharacteristic } from "./characteristic";
|
|
3
|
-
/**
|
|
4
|
-
* write
|
|
5
|
-
* @param characteristic
|
|
6
|
-
* @param message
|
|
7
|
-
*/
|
|
8
|
-
export const write = (board, serviceId, characteristicId, message, duration = 0) => {
|
|
9
|
-
return new Promise((resolve, reject) => {
|
|
10
|
-
if (isConnected(board)) {
|
|
11
|
-
const encoder = new TextEncoder();
|
|
12
|
-
const characteristic = getCharacteristic(board, serviceId, characteristicId);
|
|
13
|
-
if (characteristic) {
|
|
14
|
-
characteristic
|
|
15
|
-
.writeValue(encoder.encode(message))
|
|
16
|
-
.then(() => {
|
|
17
|
-
if (duration !== 0) {
|
|
18
|
-
setTimeout(() => {
|
|
19
|
-
resolve();
|
|
20
|
-
}, duration);
|
|
21
|
-
}
|
|
22
|
-
})
|
|
23
|
-
.catch((error) => {
|
|
24
|
-
reject(error);
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
reject(new Error("Characteristics is undefined"));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
reject(new Error("Device is not connected"));
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
};
|