@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.
Files changed (71) hide show
  1. package/README.md +8 -5
  2. package/package.json +2 -2
  3. package/src/battery.ts +4 -4
  4. package/src/calibration.ts +1 -1
  5. package/src/commands/index.ts +2 -2
  6. package/src/commands/{tindeq.ts → progressor.ts} +7 -3
  7. package/src/commands/types.ts +5 -5
  8. package/src/connect.ts +64 -5
  9. package/src/devices/index.ts +1 -1
  10. package/src/devices/{tindeq.ts → progressor.ts} +17 -5
  11. package/src/index.ts +1 -1
  12. package/src/info.ts +6 -6
  13. package/src/stop.ts +5 -5
  14. package/src/stream.ts +6 -6
  15. package/src/write.ts +7 -4
  16. package/src/battery.d.ts +0 -6
  17. package/src/battery.js +0 -19
  18. package/src/calibration.d.ts +0 -6
  19. package/src/calibration.js +0 -15
  20. package/src/characteristic.d.ts +0 -9
  21. package/src/characteristic.js +0 -15
  22. package/src/commands/climbro.d.ts +0 -6
  23. package/src/commands/climbro.js +0 -5
  24. package/src/commands/entralpi.d.ts +0 -6
  25. package/src/commands/entralpi.js +0 -5
  26. package/src/commands/index.d.ts +0 -5
  27. package/src/commands/index.js +0 -5
  28. package/src/commands/motherboard.d.ts +0 -6
  29. package/src/commands/motherboard.js +0 -13
  30. package/src/commands/smartboard.d.ts +0 -6
  31. package/src/commands/smartboard.js +0 -5
  32. package/src/commands/tindeq.d.ts +0 -11
  33. package/src/commands/tindeq.js +0 -23
  34. package/src/commands/types.d.ts +0 -18
  35. package/src/commands/types.js +0 -1
  36. package/src/connect.d.ts +0 -7
  37. package/src/connect.js +0 -156
  38. package/src/data.d.ts +0 -8
  39. package/src/data.js +0 -109
  40. package/src/devices/climbro.d.ts +0 -2
  41. package/src/devices/climbro.js +0 -4
  42. package/src/devices/entralpi.d.ts +0 -2
  43. package/src/devices/entralpi.js +0 -52
  44. package/src/devices/index.d.ts +0 -5
  45. package/src/devices/index.js +0 -5
  46. package/src/devices/motherboard.d.ts +0 -2
  47. package/src/devices/motherboard.js +0 -79
  48. package/src/devices/smartboard.d.ts +0 -2
  49. package/src/devices/smartboard.js +0 -4
  50. package/src/devices/tindeq.d.ts +0 -2
  51. package/src/devices/tindeq.js +0 -22
  52. package/src/devices/types.d.ts +0 -20
  53. package/src/devices/types.js +0 -1
  54. package/src/disconnect.d.ts +0 -6
  55. package/src/disconnect.js +0 -10
  56. package/src/index.d.ts +0 -10
  57. package/src/index.js +0 -12
  58. package/src/info.d.ts +0 -6
  59. package/src/info.js +0 -23
  60. package/src/is-connected.d.ts +0 -7
  61. package/src/is-connected.js +0 -10
  62. package/src/notify.d.ts +0 -4
  63. package/src/notify.js +0 -6
  64. package/src/read.d.ts +0 -6
  65. package/src/read.js +0 -45
  66. package/src/stop.d.ts +0 -6
  67. package/src/stop.js +0 -18
  68. package/src/stream.d.ts +0 -6
  69. package/src/stream.js +0 -35
  70. package/src/write.d.ts +0 -7
  71. package/src/write.js +0 -35
package/src/stop.d.ts DELETED
@@ -1,6 +0,0 @@
1
- import { Device } from "./devices/types";
2
- /**
3
- * read calibration
4
- * @param board
5
- */
6
- export declare const stop: (board: Device) => Promise<void>;
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
@@ -1,6 +0,0 @@
1
- import { Device } from "./devices/types";
2
- /**
3
- * stream output
4
- * @param board
5
- */
6
- export declare const stream: (board: Device, duration?: number) => Promise<void>;
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
@@ -1,7 +0,0 @@
1
- import { Device } from "./devices/types";
2
- /**
3
- * write
4
- * @param characteristic
5
- * @param message
6
- */
7
- export declare const write: (board: Device, serviceId: string, characteristicId: string, message: string, duration?: number) => Promise<void>;
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
- };