tirecheck-device-sdk 0.1.1 → 0.1.2

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 (2) hide show
  1. package/README.md +49 -0
  2. package/package.json +23 -3
package/README.md CHANGED
@@ -62,12 +62,49 @@ implementation so that test passes.
62
62
  Focus on one small improvement at a time - one failing test, then make it pass, then another failing test, etc. Mentally
63
63
  this approach is much easier because you don't need to think about system as a whole
64
64
 
65
+ ### Local testing in app
66
+
67
+ To test the library in your application, without publishing them to npm, please, run following commands:
68
+
69
+ ```
70
+ // From /Work/tirecheck-device-sdk
71
+ pnpm build
72
+
73
+ // From /Work/my-app
74
+ pnpm link ../tirecheck-device-sdk
75
+ ```
76
+
77
+ This will temporarily ensure that package is taken from your local directory and not from package.json.
78
+
65
79
  ### Conventions
66
80
 
67
81
  - use `deviceMeta` for storing generic device info and methods for processing advertisement for all supported devices
68
82
  - this is to avoid importing full device services before we're connected to them
69
83
  - use `devices/*` for exposed logic related to devices after they're connected. That includes methods `connect` and
70
84
  `disconnect`.
85
+ - For more complicated devices, such as `bridge`, it is useful to create `bridgeCommands` file, that contain _commands_.
86
+ Command = method that accepts human-readable arguments and converts them to _single_ low-level call of `ble` (i.e. it
87
+ just converts human-readable data to binary data and sends them to `ble`).
88
+
89
+ ```
90
+ // bridge.ts - methods from this file are exposed to library users
91
+ import bridgeCommands from './bridgeCommands'
92
+
93
+ export default {
94
+ // You can expose command directly...
95
+ getMeasurement: bridgeCommands.getMeasurement,
96
+
97
+ // Or expose method that calls sequence of commands
98
+ async getVehicleSchema() {
99
+ const axles = await bridgeCommands.getVehicleAxles()
100
+ for(let i = 0; i < axles.length; i++) {
101
+ const tyres = await bridgeCommands.getVehicleTyres(i)
102
+ }
103
+ return { axles, tyres }
104
+ }
105
+ }
106
+ ```
107
+
71
108
  - use `services/*` for logic shared between devices. Those files won't be exposed in the build.
72
109
  - expose only top-level functions. So, expose `bridge.writeConfiguration` or `bridge.writeAxleSetup` instead of generic
73
110
  `bridge.writeMessage`
@@ -96,6 +133,14 @@ export default {
96
133
  function foo() {}
97
134
  ```
98
135
 
136
+ ### Simulator
137
+
138
+ For each supported device, you must provide a simulator. It is important for testing final apps. **Simulator replaces
139
+ high-level calls** - i.e. it works with human-readable data and doesn't need to convert data to binary
140
+
141
+ - For complex devices with `commands` layer, such as bridge example above, we advice to simulate only `commands` layer,
142
+ and leave top-level as is
143
+
99
144
  ### Submitting changes
100
145
 
101
146
  If you wish to include a new change, process is as follows:
@@ -117,6 +162,10 @@ You can contact tirecheck if you need support - admin@tirecheck.com
117
162
 
118
163
  [x] Initial structure
119
164
 
165
+ [x] Simulators
166
+
167
+ [x] Ability to test against real devices
168
+
120
169
  [] Full CAN bridge support
121
170
 
122
171
  [] CAN Bridge Firmware Update support
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tirecheck-device-sdk",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "SDK for working with various devices produced by Tirecheck via Bluetooth (CAN Bridge, Routers, Sensors, FlexiGauge, PressureStick, etc)",
5
5
  "author": "Leonid Buneev <leonid.buneev@tirecheck.com>",
6
6
  "license": "ISC",
@@ -11,22 +11,42 @@
11
11
  "files": [
12
12
  "dist"
13
13
  ],
14
+ "engines": {
15
+ "node": ">=18"
16
+ },
14
17
  "dependencies": {
15
- "lodash": "^4.17.21"
18
+ "crypto-js": "^4.2.0",
19
+ "lodash": "^4.17.21",
20
+ "uuid": "^10.0.0"
16
21
  },
17
22
  "devDependencies": {
18
23
  "@antfu/eslint-config": "^2.25.1",
24
+ "@types/express": "^4.17.21",
19
25
  "@types/lodash": "^4.17.7",
26
+ "@types/websocket": "^1.0.10",
20
27
  "@vitest/ui": "^2.0.5",
28
+ "chalk": "^5.3.0",
21
29
  "eslint": "^9.9.0",
22
30
  "eslint-plugin-format": "^0.1.2",
23
31
  "eslint-plugin-tyrecheck": "^2.64.0",
32
+ "express": "^4.19.2",
33
+ "express-ws": "^5.0.2",
34
+ "h3": "^1.12.0",
35
+ "ngrok": "5.0.0-beta.2",
36
+ "ts-node": "^10.9.2",
37
+ "typescript": "^5.6.2",
24
38
  "unbuild": "^2.0.0",
25
- "vitest": "^2.0.5"
39
+ "uqr": "^0.1.2",
40
+ "vitest": "^2.0.5",
41
+ "websocket": "^1.0.35"
26
42
  },
27
43
  "scripts": {
28
44
  "test": "vitest --ui",
45
+ "typecheck": "pnpm tsc --noEmit",
29
46
  "dev": "pnpm install && vitest --ui",
47
+ "dev-server-old": "ts-node ./devServer/devServer.ts",
48
+ "dev-server": "npx --yes listhen -w --ws --open ./devServer/devServer.ts",
49
+ "dev-ngrok": "node --loader ts-node/esm ./devServer/ngrok.mts",
30
50
  "build": "unbuild"
31
51
  }
32
52
  }