@hangtime/grip-connect 0.1.1 → 0.2.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/README.md +14 -20
- package/package.json +1 -1
- package/src/battery.d.ts +6 -0
- package/src/battery.js +19 -0
- package/src/battery.ts +21 -0
- package/src/calibration.js +3 -4
- package/src/calibration.ts +3 -3
- package/src/commands/tindeq.js +12 -12
- package/src/connect.js +11 -5
- package/src/connect.ts +10 -4
- package/src/data.d.ts +8 -0
- package/src/data.js +109 -0
- package/src/data.ts +133 -0
- package/src/devices/entralpi.d.ts +0 -6
- package/src/devices/entralpi.js +0 -16
- package/src/devices/entralpi.ts +0 -17
- package/src/devices/motherboard.d.ts +0 -6
- package/src/devices/motherboard.js +0 -110
- package/src/devices/motherboard.ts +0 -134
- package/src/disconnect.js +3 -4
- package/src/disconnect.ts +3 -3
- package/src/index.d.ts +3 -1
- package/src/index.js +5 -1
- package/src/index.ts +9 -1
- package/src/info.d.ts +6 -0
- package/src/info.js +23 -0
- package/src/info.ts +25 -0
- package/src/is-connected.d.ts +7 -0
- package/src/is-connected.js +10 -0
- package/src/is-connected.ts +11 -0
- package/src/notify.js +1 -1
- package/src/notify.ts +2 -2
- package/src/read.js +2 -1
- package/src/read.ts +2 -1
- package/src/stop.js +3 -4
- package/src/stop.ts +3 -3
- package/src/stream.js +12 -8
- package/src/stream.ts +12 -7
- package/src/write.js +7 -4
- package/src/write.ts +8 -4
- package/tsconfig.json +2 -2
package/src/write.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Device } from "./devices/types"
|
|
2
|
+
import { isConnected } from "./is-connected"
|
|
2
3
|
import { getCharacteristic } from "./characteristic"
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* write
|
|
5
7
|
* @param characteristic
|
|
@@ -13,7 +15,7 @@ export const write = (
|
|
|
13
15
|
duration: number = 0,
|
|
14
16
|
): Promise<void> => {
|
|
15
17
|
return new Promise((resolve, reject) => {
|
|
16
|
-
if (board
|
|
18
|
+
if (isConnected(board)) {
|
|
17
19
|
const encoder = new TextEncoder()
|
|
18
20
|
|
|
19
21
|
const characteristic = getCharacteristic(board, serviceId, characteristicId)
|
|
@@ -22,9 +24,11 @@ export const write = (
|
|
|
22
24
|
characteristic
|
|
23
25
|
.writeValue(encoder.encode(message))
|
|
24
26
|
.then(() => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
if (duration !== 0) {
|
|
28
|
+
setTimeout(() => {
|
|
29
|
+
resolve()
|
|
30
|
+
}, duration)
|
|
31
|
+
}
|
|
28
32
|
})
|
|
29
33
|
.catch((error) => {
|
|
30
34
|
reject(error)
|
package/tsconfig.json
CHANGED