zigbee-herdsman 6.0.1 → 6.0.3

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 (260) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/adapter/ezsp/driver/uart.js +1 -1
  3. package/dist/adapter/ezsp/driver/uart.js.map +1 -1
  4. package/dist/adapter/z-stack/adapter/zStackAdapter.js +4 -4
  5. package/dist/adapter/z-stack/adapter/zStackAdapter.js.map +1 -1
  6. package/dist/adapter/zigate/adapter/zigateAdapter.js +4 -4
  7. package/dist/adapter/zigate/adapter/zigateAdapter.js.map +1 -1
  8. package/dist/controller/model/device.d.ts.map +1 -1
  9. package/dist/controller/model/device.js +1 -0
  10. package/dist/controller/model/device.js.map +1 -1
  11. package/package.json +14 -6
  12. package/.github/ISSUE_TEMPLATE/config.yml +0 -5
  13. package/.github/dependabot.yml +0 -22
  14. package/.github/workflows/ci.yml +0 -64
  15. package/.github/workflows/release-please.yml +0 -18
  16. package/.github/workflows/stale.yml +0 -20
  17. package/.github/workflows/typedoc.yaml +0 -47
  18. package/.release-please-manifest.json +0 -3
  19. package/.vscode/extensions.json +0 -3
  20. package/.vscode/settings.json +0 -11
  21. package/biome.json +0 -98
  22. package/examples/join-and-log.js +0 -24
  23. package/release-please-config.json +0 -9
  24. package/src/adapter/adapter.ts +0 -189
  25. package/src/adapter/adapterDiscovery.ts +0 -666
  26. package/src/adapter/const.ts +0 -12
  27. package/src/adapter/deconz/adapter/deconzAdapter.ts +0 -877
  28. package/src/adapter/deconz/driver/constants.ts +0 -246
  29. package/src/adapter/deconz/driver/driver.ts +0 -1540
  30. package/src/adapter/deconz/driver/frame.ts +0 -11
  31. package/src/adapter/deconz/driver/frameParser.ts +0 -753
  32. package/src/adapter/deconz/driver/parser.ts +0 -45
  33. package/src/adapter/deconz/driver/writer.ts +0 -22
  34. package/src/adapter/deconz/types.d.ts +0 -13
  35. package/src/adapter/ember/adapter/emberAdapter.ts +0 -2265
  36. package/src/adapter/ember/adapter/endpoints.ts +0 -86
  37. package/src/adapter/ember/adapter/oneWaitress.ts +0 -324
  38. package/src/adapter/ember/adapter/tokensManager.ts +0 -782
  39. package/src/adapter/ember/consts.ts +0 -178
  40. package/src/adapter/ember/enums.ts +0 -1746
  41. package/src/adapter/ember/ezsp/buffalo.ts +0 -1392
  42. package/src/adapter/ember/ezsp/consts.ts +0 -148
  43. package/src/adapter/ember/ezsp/enums.ts +0 -1114
  44. package/src/adapter/ember/ezsp/ezsp.ts +0 -9061
  45. package/src/adapter/ember/ezspError.ts +0 -10
  46. package/src/adapter/ember/types.ts +0 -866
  47. package/src/adapter/ember/uart/ash.ts +0 -1960
  48. package/src/adapter/ember/uart/consts.ts +0 -109
  49. package/src/adapter/ember/uart/enums.ts +0 -192
  50. package/src/adapter/ember/uart/parser.ts +0 -48
  51. package/src/adapter/ember/uart/queues.ts +0 -247
  52. package/src/adapter/ember/uart/writer.ts +0 -53
  53. package/src/adapter/ember/utils/initters.ts +0 -58
  54. package/src/adapter/ember/utils/math.ts +0 -73
  55. package/src/adapter/events.ts +0 -21
  56. package/src/adapter/ezsp/adapter/backup.ts +0 -109
  57. package/src/adapter/ezsp/adapter/ezspAdapter.ts +0 -614
  58. package/src/adapter/ezsp/driver/commands.ts +0 -2497
  59. package/src/adapter/ezsp/driver/consts.ts +0 -11
  60. package/src/adapter/ezsp/driver/driver.ts +0 -1002
  61. package/src/adapter/ezsp/driver/ezsp.ts +0 -802
  62. package/src/adapter/ezsp/driver/frame.ts +0 -101
  63. package/src/adapter/ezsp/driver/index.ts +0 -4
  64. package/src/adapter/ezsp/driver/multicast.ts +0 -78
  65. package/src/adapter/ezsp/driver/parser.ts +0 -81
  66. package/src/adapter/ezsp/driver/types/basic.ts +0 -201
  67. package/src/adapter/ezsp/driver/types/index.ts +0 -239
  68. package/src/adapter/ezsp/driver/types/named.ts +0 -2330
  69. package/src/adapter/ezsp/driver/types/struct.ts +0 -844
  70. package/src/adapter/ezsp/driver/uart.ts +0 -460
  71. package/src/adapter/ezsp/driver/utils/crc16ccitt.ts +0 -44
  72. package/src/adapter/ezsp/driver/utils/index.ts +0 -32
  73. package/src/adapter/ezsp/driver/writer.ts +0 -64
  74. package/src/adapter/index.ts +0 -3
  75. package/src/adapter/serialPort.ts +0 -58
  76. package/src/adapter/socketPortUtils.ts +0 -16
  77. package/src/adapter/tstype.ts +0 -78
  78. package/src/adapter/z-stack/adapter/adapter-backup.ts +0 -519
  79. package/src/adapter/z-stack/adapter/adapter-nv-memory.ts +0 -457
  80. package/src/adapter/z-stack/adapter/endpoints.ts +0 -57
  81. package/src/adapter/z-stack/adapter/manager.ts +0 -543
  82. package/src/adapter/z-stack/adapter/tstype.ts +0 -6
  83. package/src/adapter/z-stack/adapter/zStackAdapter.ts +0 -1190
  84. package/src/adapter/z-stack/constants/af.ts +0 -27
  85. package/src/adapter/z-stack/constants/common.ts +0 -285
  86. package/src/adapter/z-stack/constants/dbg.ts +0 -23
  87. package/src/adapter/z-stack/constants/index.ts +0 -11
  88. package/src/adapter/z-stack/constants/mac.ts +0 -128
  89. package/src/adapter/z-stack/constants/sapi.ts +0 -25
  90. package/src/adapter/z-stack/constants/sys.ts +0 -72
  91. package/src/adapter/z-stack/constants/util.ts +0 -82
  92. package/src/adapter/z-stack/constants/utils.ts +0 -14
  93. package/src/adapter/z-stack/constants/zdo.ts +0 -103
  94. package/src/adapter/z-stack/models/startup-options.ts +0 -13
  95. package/src/adapter/z-stack/structs/entries/address-manager-entry.ts +0 -44
  96. package/src/adapter/z-stack/structs/entries/address-manager-table.ts +0 -19
  97. package/src/adapter/z-stack/structs/entries/aps-link-key-data-entry.ts +0 -12
  98. package/src/adapter/z-stack/structs/entries/aps-link-key-data-table.ts +0 -21
  99. package/src/adapter/z-stack/structs/entries/aps-tc-link-key-entry.ts +0 -19
  100. package/src/adapter/z-stack/structs/entries/aps-tc-link-key-table.ts +0 -21
  101. package/src/adapter/z-stack/structs/entries/channel-list.ts +0 -8
  102. package/src/adapter/z-stack/structs/entries/has-configured.ts +0 -16
  103. package/src/adapter/z-stack/structs/entries/index.ts +0 -16
  104. package/src/adapter/z-stack/structs/entries/nib.ts +0 -66
  105. package/src/adapter/z-stack/structs/entries/nwk-key-descriptor.ts +0 -15
  106. package/src/adapter/z-stack/structs/entries/nwk-key.ts +0 -13
  107. package/src/adapter/z-stack/structs/entries/nwk-pan-id.ts +0 -8
  108. package/src/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-entry.ts +0 -20
  109. package/src/adapter/z-stack/structs/entries/nwk-sec-material-descriptor-table.ts +0 -19
  110. package/src/adapter/z-stack/structs/entries/security-manager-entry.ts +0 -33
  111. package/src/adapter/z-stack/structs/entries/security-manager-table.ts +0 -22
  112. package/src/adapter/z-stack/structs/index.ts +0 -4
  113. package/src/adapter/z-stack/structs/serializable-memory-object.ts +0 -14
  114. package/src/adapter/z-stack/structs/struct.ts +0 -367
  115. package/src/adapter/z-stack/structs/table.ts +0 -198
  116. package/src/adapter/z-stack/unpi/constants.ts +0 -33
  117. package/src/adapter/z-stack/unpi/frame.ts +0 -62
  118. package/src/adapter/z-stack/unpi/index.ts +0 -4
  119. package/src/adapter/z-stack/unpi/parser.ts +0 -56
  120. package/src/adapter/z-stack/unpi/writer.ts +0 -21
  121. package/src/adapter/z-stack/utils/channel-list.ts +0 -40
  122. package/src/adapter/z-stack/utils/index.ts +0 -2
  123. package/src/adapter/z-stack/utils/network-options.ts +0 -26
  124. package/src/adapter/z-stack/znp/buffaloZnp.ts +0 -175
  125. package/src/adapter/z-stack/znp/definition.ts +0 -2713
  126. package/src/adapter/z-stack/znp/index.ts +0 -2
  127. package/src/adapter/z-stack/znp/parameterType.ts +0 -22
  128. package/src/adapter/z-stack/znp/tstype.ts +0 -44
  129. package/src/adapter/z-stack/znp/utils.ts +0 -10
  130. package/src/adapter/z-stack/znp/znp.ts +0 -342
  131. package/src/adapter/z-stack/znp/zpiObject.ts +0 -148
  132. package/src/adapter/zboss/adapter/zbossAdapter.ts +0 -526
  133. package/src/adapter/zboss/commands.ts +0 -1184
  134. package/src/adapter/zboss/consts.ts +0 -9
  135. package/src/adapter/zboss/driver.ts +0 -422
  136. package/src/adapter/zboss/enums.ts +0 -360
  137. package/src/adapter/zboss/frame.ts +0 -227
  138. package/src/adapter/zboss/reader.ts +0 -65
  139. package/src/adapter/zboss/types.ts +0 -0
  140. package/src/adapter/zboss/uart.ts +0 -428
  141. package/src/adapter/zboss/utils.ts +0 -58
  142. package/src/adapter/zboss/writer.ts +0 -49
  143. package/src/adapter/zigate/adapter/patchZdoBuffaloBE.ts +0 -27
  144. package/src/adapter/zigate/adapter/zigateAdapter.ts +0 -618
  145. package/src/adapter/zigate/driver/LICENSE +0 -17
  146. package/src/adapter/zigate/driver/buffaloZiGate.ts +0 -212
  147. package/src/adapter/zigate/driver/commandType.ts +0 -418
  148. package/src/adapter/zigate/driver/constants.ts +0 -150
  149. package/src/adapter/zigate/driver/frame.ts +0 -197
  150. package/src/adapter/zigate/driver/messageType.ts +0 -287
  151. package/src/adapter/zigate/driver/parameterType.ts +0 -32
  152. package/src/adapter/zigate/driver/ziGateObject.ts +0 -146
  153. package/src/adapter/zigate/driver/zigate.ts +0 -423
  154. package/src/adapter/zoh/adapter/utils.ts +0 -27
  155. package/src/adapter/zoh/adapter/zohAdapter.ts +0 -838
  156. package/src/buffalo/buffalo.ts +0 -342
  157. package/src/buffalo/index.ts +0 -1
  158. package/src/controller/controller.ts +0 -1022
  159. package/src/controller/database.ts +0 -124
  160. package/src/controller/events.ts +0 -52
  161. package/src/controller/greenPower.ts +0 -603
  162. package/src/controller/helpers/index.ts +0 -1
  163. package/src/controller/helpers/installCodes.ts +0 -107
  164. package/src/controller/helpers/request.ts +0 -96
  165. package/src/controller/helpers/requestQueue.ts +0 -125
  166. package/src/controller/helpers/zclFrameConverter.ts +0 -47
  167. package/src/controller/helpers/zclTransactionSequenceNumber.ts +0 -19
  168. package/src/controller/index.ts +0 -6
  169. package/src/controller/model/device.ts +0 -1248
  170. package/src/controller/model/endpoint.ts +0 -1105
  171. package/src/controller/model/entity.ts +0 -23
  172. package/src/controller/model/group.ts +0 -424
  173. package/src/controller/model/index.ts +0 -5
  174. package/src/controller/model/zigbeeEntity.ts +0 -30
  175. package/src/controller/touchlink.ts +0 -189
  176. package/src/controller/tstype.ts +0 -274
  177. package/src/index.ts +0 -12
  178. package/src/models/backup-storage-legacy.ts +0 -48
  179. package/src/models/backup-storage-unified.ts +0 -47
  180. package/src/models/backup.ts +0 -37
  181. package/src/models/index.ts +0 -5
  182. package/src/models/network-options.ts +0 -11
  183. package/src/utils/backup.ts +0 -152
  184. package/src/utils/index.ts +0 -5
  185. package/src/utils/logger.ts +0 -20
  186. package/src/utils/patchBigIntSerialization.ts +0 -8
  187. package/src/utils/queue.ts +0 -76
  188. package/src/utils/types.d.ts +0 -3
  189. package/src/utils/utils.ts +0 -19
  190. package/src/utils/wait.ts +0 -5
  191. package/src/utils/waitress.ts +0 -96
  192. package/src/zspec/consts.ts +0 -84
  193. package/src/zspec/enums.ts +0 -22
  194. package/src/zspec/index.ts +0 -3
  195. package/src/zspec/tstypes.ts +0 -18
  196. package/src/zspec/utils.ts +0 -247
  197. package/src/zspec/zcl/buffaloZcl.ts +0 -1220
  198. package/src/zspec/zcl/definition/cluster.ts +0 -5915
  199. package/src/zspec/zcl/definition/clusters-typegen.ts +0 -588
  200. package/src/zspec/zcl/definition/clusters-types.ts +0 -7331
  201. package/src/zspec/zcl/definition/consts.ts +0 -24
  202. package/src/zspec/zcl/definition/enums.ts +0 -203
  203. package/src/zspec/zcl/definition/foundation.ts +0 -329
  204. package/src/zspec/zcl/definition/manufacturerCode.ts +0 -729
  205. package/src/zspec/zcl/definition/status.ts +0 -69
  206. package/src/zspec/zcl/definition/tstype.ts +0 -377
  207. package/src/zspec/zcl/index.ts +0 -11
  208. package/src/zspec/zcl/utils.ts +0 -321
  209. package/src/zspec/zcl/zclFrame.ts +0 -356
  210. package/src/zspec/zcl/zclHeader.ts +0 -102
  211. package/src/zspec/zcl/zclStatusError.ts +0 -10
  212. package/src/zspec/zdo/buffaloZdo.ts +0 -2336
  213. package/src/zspec/zdo/definition/clusters.ts +0 -722
  214. package/src/zspec/zdo/definition/consts.ts +0 -16
  215. package/src/zspec/zdo/definition/enums.ts +0 -99
  216. package/src/zspec/zdo/definition/status.ts +0 -105
  217. package/src/zspec/zdo/definition/tstypes.ts +0 -1062
  218. package/src/zspec/zdo/index.ts +0 -7
  219. package/src/zspec/zdo/utils.ts +0 -76
  220. package/src/zspec/zdo/zdoStatusError.ts +0 -10
  221. package/test/adapter/adapter.test.ts +0 -1062
  222. package/test/adapter/ember/ash.test.ts +0 -337
  223. package/test/adapter/ember/consts.ts +0 -131
  224. package/test/adapter/ember/emberAdapter.test.ts +0 -3449
  225. package/test/adapter/ember/ezsp.test.ts +0 -385
  226. package/test/adapter/ember/ezspBuffalo.test.ts +0 -93
  227. package/test/adapter/ember/ezspError.test.ts +0 -12
  228. package/test/adapter/ember/math.test.ts +0 -206
  229. package/test/adapter/ezsp/frame.test.ts +0 -30
  230. package/test/adapter/ezsp/uart.test.ts +0 -181
  231. package/test/adapter/z-stack/adapter.test.ts +0 -3984
  232. package/test/adapter/z-stack/constants.test.ts +0 -33
  233. package/test/adapter/z-stack/structs.test.ts +0 -115
  234. package/test/adapter/z-stack/unpi.test.ts +0 -213
  235. package/test/adapter/z-stack/znp.test.ts +0 -1284
  236. package/test/adapter/zboss/fixZdoResponse.test.ts +0 -179
  237. package/test/adapter/zigate/patchZdoBuffaloBE.test.ts +0 -81
  238. package/test/adapter/zigate/zdo.test.ts +0 -187
  239. package/test/adapter/zoh/utils.test.ts +0 -36
  240. package/test/adapter/zoh/zohAdapter.test.ts +0 -1307
  241. package/test/buffalo.test.ts +0 -431
  242. package/test/controller.bench.ts +0 -193
  243. package/test/controller.test.ts +0 -8702
  244. package/test/greenpower.test.ts +0 -1408
  245. package/test/mockAdapters.ts +0 -65
  246. package/test/mockDevices.ts +0 -598
  247. package/test/requests.bench.ts +0 -206
  248. package/test/testUtils.ts +0 -20
  249. package/test/tsconfig.json +0 -9
  250. package/test/utils/math.ts +0 -19
  251. package/test/utils.test.ts +0 -279
  252. package/test/vitest.config.mts +0 -27
  253. package/test/zcl.test.ts +0 -2831
  254. package/test/zspec/utils.test.ts +0 -68
  255. package/test/zspec/zcl/buffalo.test.ts +0 -1374
  256. package/test/zspec/zcl/frame.test.ts +0 -960
  257. package/test/zspec/zcl/utils.test.ts +0 -273
  258. package/test/zspec/zdo/buffalo.test.ts +0 -1850
  259. package/test/zspec/zdo/utils.test.ts +0 -241
  260. package/tsconfig.json +0 -24
@@ -1,431 +0,0 @@
1
- import {describe, expect, it} from "vitest";
2
- import {Buffalo} from "../src/buffalo";
3
- import {ieeeaAddr1, ieeeaAddr2} from "./testUtils";
4
-
5
- describe("Buffalo", () => {
6
- it("is more", () => {
7
- const buffalo = new Buffalo(Buffer.from([0, 1, 2]), 1);
8
- expect(buffalo.getPosition()).toEqual(1);
9
- expect(buffalo.isMore()).toStrictEqual(true);
10
- buffalo.readUInt16();
11
- expect(buffalo.isMore()).toStrictEqual(false);
12
- });
13
-
14
- it("gets written", () => {
15
- const buffalo = new Buffalo(Buffer.alloc(3), 1);
16
- buffalo.writeUInt8(240);
17
- expect(buffalo.getWritten()).toStrictEqual(Buffer.from([0, 240]));
18
- });
19
-
20
- it("UINT8 write", () => {
21
- const buffalo = new Buffalo(Buffer.alloc(3), 1);
22
- buffalo.writeUInt8(240);
23
- expect(buffalo.getPosition()).toEqual(2);
24
- expect(buffalo.getBuffer()).toStrictEqual(Buffer.from([0x00, 0xf0, 0x00]));
25
- });
26
-
27
- it("UINT8 read", () => {
28
- const buffalo = new Buffalo(Buffer.from([0x00, 0x03, 0x00, 0x00]), 1);
29
- const value = buffalo.readUInt8();
30
- expect(buffalo.getPosition()).toEqual(2);
31
- expect(value).toStrictEqual(3);
32
- });
33
-
34
- it("INT8 write", () => {
35
- const buffalo = new Buffalo(Buffer.alloc(3), 1);
36
- buffalo.writeInt8(127);
37
- expect(buffalo.getPosition()).toEqual(2);
38
- expect(buffalo.getBuffer()).toStrictEqual(Buffer.from([0x00, 0x7f, 0x00]));
39
- });
40
-
41
- it("INT8 read", () => {
42
- const buffalo = new Buffalo(Buffer.from([0x00, 0xf0, 0x00, 0x00]), 1);
43
- const value = buffalo.readInt8();
44
- expect(buffalo.getPosition()).toEqual(2);
45
- expect(value).toStrictEqual(-16);
46
- });
47
-
48
- it("INT16 write", () => {
49
- const buffalo = new Buffalo(Buffer.alloc(3), 1);
50
- buffalo.writeInt16(256);
51
- expect(buffalo.getPosition()).toEqual(3);
52
- expect(buffalo.getBuffer()).toStrictEqual(Buffer.from([0x00, 0x00, 0x01]));
53
- });
54
-
55
- it("INT16 read", () => {
56
- const buffalo = new Buffalo(Buffer.from([0x00, 0xff, 0xff, 0x00]), 1);
57
- const value = buffalo.readInt16();
58
- expect(buffalo.getPosition()).toEqual(3);
59
- expect(value).toStrictEqual(-1);
60
- });
61
-
62
- it("UINT16 write", () => {
63
- const buffalo = new Buffalo(Buffer.alloc(3), 1);
64
- buffalo.writeUInt16(1020);
65
- expect(buffalo.getPosition()).toEqual(3);
66
- expect(buffalo.getBuffer()).toStrictEqual(Buffer.from([0x00, 0xfc, 0x03]));
67
- });
68
-
69
- it("UINT16 read", () => {
70
- const buffalo = new Buffalo(Buffer.from([0x00, 0x03, 0xff, 0x00]), 1);
71
- const value = buffalo.readUInt16();
72
- expect(buffalo.getPosition()).toEqual(3);
73
- expect(value).toStrictEqual(65283);
74
- });
75
-
76
- it("INT32 write", () => {
77
- const buffalo = new Buffalo(Buffer.alloc(6), 2);
78
- buffalo.writeInt32(1065283);
79
- expect(buffalo.getPosition()).toEqual(6);
80
- expect(buffalo.getBuffer()).toStrictEqual(Buffer.from([0x00, 0x00, 0x43, 0x41, 0x10, 0x00]));
81
- });
82
-
83
- it("INT32 read", () => {
84
- const buffalo = new Buffalo(Buffer.from([0x01, 0x03, 0xff, 0xff]));
85
- const value = buffalo.readInt32();
86
- expect(buffalo.getPosition()).toEqual(4);
87
- expect(value).toStrictEqual(-64767);
88
- });
89
-
90
- it("UINT32 write", () => {
91
- const buffalo = new Buffalo(Buffer.alloc(6), 2);
92
- buffalo.writeUInt32(1065283);
93
- expect(buffalo.getPosition()).toEqual(6);
94
- expect(buffalo.getBuffer()).toStrictEqual(Buffer.from([0x00, 0x00, 0x43, 0x41, 0x10, 0x00]));
95
- });
96
-
97
- it("UINT32 read", () => {
98
- const buffalo = new Buffalo(Buffer.from([0x01, 0x03, 0xff, 0xff]));
99
- const value = buffalo.readUInt32();
100
- expect(buffalo.getPosition()).toEqual(4);
101
- expect(value).toStrictEqual(4294902529);
102
- });
103
-
104
- it("INT40 write", () => {
105
- const buffalo = new Buffalo(Buffer.alloc(7), 2);
106
- buffalo.writeInt40(21542142465);
107
- expect(buffalo.getPosition()).toEqual(7);
108
- expect(buffalo.getBuffer()).toStrictEqual(Buffer.from([0, 0, 1, 2, 3, 4, 5]));
109
- });
110
-
111
- it("INT40 read", () => {
112
- const buffalo = new Buffalo(Buffer.from([1, 2, 3, 4, 5]));
113
- const value = buffalo.readInt40();
114
- expect(buffalo.getPosition()).toEqual(5);
115
- expect(value).toStrictEqual(21542142465);
116
- });
117
-
118
- it("UINT40 write", () => {
119
- const buffalo = new Buffalo(Buffer.alloc(7), 2);
120
- buffalo.writeUInt40(21542142465);
121
- expect(buffalo.getPosition()).toEqual(7);
122
- expect(buffalo.getBuffer()).toStrictEqual(Buffer.from([0, 0, 1, 2, 3, 4, 5]));
123
- });
124
-
125
- it("UINT40 read", () => {
126
- const buffalo = new Buffalo(Buffer.from([1, 2, 3, 4, 5]));
127
- const value = buffalo.readUInt40();
128
- expect(buffalo.getPosition()).toEqual(5);
129
- expect(value).toStrictEqual(21542142465);
130
- });
131
-
132
- it("INT48 write", () => {
133
- const buffalo = new Buffalo(Buffer.alloc(8), 2);
134
- buffalo.writeInt48(6618611909121);
135
- expect(buffalo.getPosition()).toEqual(8);
136
- expect(buffalo.getBuffer()).toStrictEqual(Buffer.from([0, 0, 1, 2, 3, 4, 5, 6]));
137
- });
138
-
139
- it("INT48 read", () => {
140
- const buffalo = new Buffalo(Buffer.from([1, 2, 3, 4, 5, 6]));
141
- const value = buffalo.readInt48();
142
- expect(buffalo.getPosition()).toEqual(6);
143
- expect(value).toStrictEqual(6618611909121);
144
- });
145
-
146
- it("UINT48 write", () => {
147
- const buffalo = new Buffalo(Buffer.alloc(8), 2);
148
- buffalo.writeUInt48(6618611909121);
149
- expect(buffalo.getPosition()).toEqual(8);
150
- expect(buffalo.getBuffer()).toStrictEqual(Buffer.from([0, 0, 1, 2, 3, 4, 5, 6]));
151
- });
152
-
153
- it("UINT48 read", () => {
154
- const buffalo = new Buffalo(Buffer.from([1, 2, 3, 4, 5, 6]));
155
- const value = buffalo.readUInt48();
156
- expect(buffalo.getPosition()).toEqual(6);
157
- expect(value).toStrictEqual(6618611909121);
158
- });
159
-
160
- it("UINT56 write", () => {
161
- const buffalo = new Buffalo(Buffer.alloc(9), 2);
162
- buffalo.writeUInt56(72057594037927934n);
163
- expect(buffalo.getPosition()).toEqual(9);
164
- expect(buffalo.getBuffer()).toStrictEqual(Buffer.from([0, 0, 254, 255, 255, 255, 255, 255, 255]));
165
- });
166
-
167
- it("UINT56 read", () => {
168
- const buffalo = new Buffalo(Buffer.from([254, 255, 255, 255, 255, 255, 255]));
169
- const value = buffalo.readUInt56();
170
- expect(buffalo.getPosition()).toEqual(7);
171
- expect(value).toStrictEqual(72057594037927934n);
172
- });
173
-
174
- it.each([
175
- [36028797018963964n, [0, 0, 252, 255, 255, 255, 255, 255, 127]],
176
- [-36028797018963964n, [0, 0, 4, 0, 0, 0, 0, 0, 128]],
177
- ])("INT56 write", (value: bigint, expectedValues: number[]) => {
178
- const buffalo = new Buffalo(Buffer.alloc(9), 2);
179
- buffalo.writeInt56(value);
180
- expect(buffalo.getPosition()).toEqual(9);
181
- expect(buffalo.getBuffer()).toStrictEqual(Buffer.from(expectedValues));
182
- });
183
-
184
- it.each([
185
- [36028797018963964n, [252, 255, 255, 255, 255, 255, 127]],
186
- [-36028797018963964n, [4, 0, 0, 0, 0, 0, 128]],
187
- ])("INT56 read", (expectedValue: bigint, values: number[]) => {
188
- const buffalo = new Buffalo(Buffer.from(values));
189
- const value = buffalo.readInt56();
190
- expect(buffalo.getPosition()).toEqual(7);
191
- expect(value).toStrictEqual(expectedValue);
192
- });
193
-
194
- it("UINT64 write", () => {
195
- const buffalo = new Buffalo(Buffer.alloc(10), 2);
196
- buffalo.writeUInt64(18446744073709551613n);
197
- expect(buffalo.getPosition()).toEqual(10);
198
- expect(buffalo.getBuffer()).toStrictEqual(Buffer.from([0, 0, 253, 255, 255, 255, 255, 255, 255, 255]));
199
- });
200
-
201
- it("UINT64 read", () => {
202
- const buffalo = new Buffalo(Buffer.from([253, 255, 255, 255, 255, 255, 255, 255]));
203
- const value = buffalo.readUInt64();
204
- expect(buffalo.getPosition()).toEqual(8);
205
- expect(value).toStrictEqual(18446744073709551613n);
206
- });
207
-
208
- it("INT64 write", () => {
209
- const buffalo = new Buffalo(Buffer.alloc(10), 2);
210
- buffalo.writeInt64(9223372036854775806n);
211
- expect(buffalo.getPosition()).toEqual(10);
212
- expect(buffalo.getBuffer()).toStrictEqual(Buffer.from([0, 0, 254, 255, 255, 255, 255, 255, 255, 127]));
213
- });
214
-
215
- it("INT64 read", () => {
216
- const buffalo = new Buffalo(Buffer.from([254, 255, 255, 255, 255, 255, 255, 127]));
217
- const value = buffalo.readInt64();
218
- expect(buffalo.getPosition()).toEqual(8);
219
- expect(value).toStrictEqual(9223372036854775806n);
220
- });
221
-
222
- it("IEEEADDR write", () => {
223
- const buffalo = new Buffalo(Buffer.alloc(8));
224
- buffalo.writeIeeeAddr(ieeeaAddr1.string);
225
- expect(buffalo.getPosition()).toEqual(8);
226
- expect(buffalo.getBuffer()).toStrictEqual(Buffer.from(ieeeaAddr1.hex));
227
- });
228
-
229
- it("IEEEADDR read", () => {
230
- const buffalo = new Buffalo(Buffer.from(ieeeaAddr2.hex));
231
- const value = buffalo.readIeeeAddr();
232
- expect(buffalo.getPosition()).toEqual(8);
233
- expect(value).toStrictEqual(ieeeaAddr2.string);
234
- });
235
-
236
- it("BUFFER write", () => {
237
- const buffalo = new Buffalo(Buffer.alloc(5), 1);
238
- const payload = Buffer.from([0x00, 0x01, 0x02]);
239
- buffalo.writeBuffer(payload, payload.length);
240
- expect(buffalo.getPosition()).toEqual(4);
241
- expect(buffalo.getBuffer()).toStrictEqual(Buffer.from([0x00, ...payload, 0x00]));
242
- });
243
-
244
- it("BUFFER write as array", () => {
245
- const buffalo = new Buffalo(Buffer.alloc(5), 1);
246
- const payload = [0x00, 0x01, 0x02];
247
- buffalo.writeBuffer(payload, payload.length);
248
- expect(buffalo.getPosition()).toEqual(4);
249
- expect(buffalo.getBuffer()).toStrictEqual(Buffer.from([0x00, ...payload, 0x00]));
250
- });
251
-
252
- it("BUFFER read", () => {
253
- const buffalo = new Buffalo(Buffer.from([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09]), 2);
254
- const value = buffalo.readBuffer(5);
255
- expect(buffalo.getPosition()).toEqual(7);
256
- expect(value).toStrictEqual(Buffer.from([0x02, 0x03, 0x04, 0x05, 0x06]));
257
- });
258
-
259
- it("LIST_UINT8 write", () => {
260
- const buffalo = new Buffalo(Buffer.alloc(4), 1);
261
- const payload = [200, 100];
262
- buffalo.writeListUInt8(payload);
263
- expect(buffalo.getPosition()).toStrictEqual(3);
264
- expect(buffalo.getBuffer()).toStrictEqual(Buffer.from([0x00, 0xc8, 0x64, 0x00]));
265
- });
266
-
267
- it("LIST_UINT8 read", () => {
268
- const buffalo = new Buffalo(Buffer.from([0x00, 0x00, 0x04, 0x08]), 2);
269
- const value = buffalo.readListUInt8(2);
270
- expect(buffalo.getPosition()).toStrictEqual(4);
271
- expect(value).toStrictEqual([4, 8]);
272
- });
273
-
274
- it("LIST_UINT16 write", () => {
275
- const buffalo = new Buffalo(Buffer.alloc(5), 1);
276
- const payload = [1024, 2048];
277
- buffalo.writeListUInt16(payload);
278
- expect(buffalo.getPosition()).toStrictEqual(5);
279
- expect(buffalo.getBuffer()).toStrictEqual(Buffer.from([0x00, 0x00, 0x04, 0x00, 0x08]));
280
- });
281
-
282
- it("LIST_UINT16 read", () => {
283
- const buffalo = new Buffalo(Buffer.from([0x00, 0x00, 0x04, 0x00, 0x08]), 1);
284
- const value = buffalo.readListUInt16(2);
285
- expect(buffalo.getPosition()).toStrictEqual(5);
286
- expect(value).toStrictEqual([1024, 2048]);
287
- });
288
-
289
- it("LIST_UINT24 write", () => {
290
- const buffalo = new Buffalo(Buffer.alloc(8), 1);
291
- const payload = [100000, 110110];
292
- buffalo.writeListUInt24(payload);
293
- expect(buffalo.getPosition()).toStrictEqual(7);
294
- expect(buffalo.getBuffer()).toStrictEqual(Buffer.from([0x00, 0xa0, 0x86, 0x01, 0x1e, 0xae, 0x01, 0x00]));
295
- });
296
-
297
- it("LIST_UINT24 read", () => {
298
- const buffalo = new Buffalo(Buffer.from([0x00, 0xa0, 0x86, 0x01, 0x1e, 0xae, 0x01, 0x00]), 1);
299
- const value = buffalo.readListUInt24(2);
300
- expect(buffalo.getPosition()).toStrictEqual(7);
301
- expect(value).toStrictEqual([100000, 110110]);
302
- });
303
-
304
- it("LIST_UINT32 write", () => {
305
- const buffalo = new Buffalo(Buffer.alloc(8));
306
- const payload = [4294967295, 10];
307
- buffalo.writeListUInt32(payload);
308
- expect(buffalo.getPosition()).toStrictEqual(8);
309
- expect(buffalo.getBuffer()).toStrictEqual(Buffer.from([0xff, 0xff, 0xff, 0xff, 0x0a, 0x00, 0x00, 0x00]));
310
- });
311
-
312
- it("LIST_UINT32 read", () => {
313
- const buffalo = new Buffalo(Buffer.from([0xff, 0xff, 0xff, 0xff, 0x0a, 0x00, 0x00, 0x00]));
314
- const value = buffalo.readListUInt32(2);
315
- expect(buffalo.getPosition()).toStrictEqual(8);
316
- expect(value).toStrictEqual([4294967295, 10]);
317
- });
318
-
319
- it("UINT24 write", () => {
320
- const buffalo = new Buffalo(Buffer.alloc(4), 1);
321
- const payload = 16777200;
322
- buffalo.writeUInt24(payload);
323
- expect(buffalo.getPosition()).toStrictEqual(4);
324
- expect(buffalo.getBuffer()).toStrictEqual(Buffer.from([0x00, 0xf0, 0xff, 0xff]));
325
- });
326
-
327
- it("UINT24 read", () => {
328
- const buffalo = new Buffalo(Buffer.from([0x01, 0xa0, 0x86, 0x01, 0x02]), 1);
329
- const value = buffalo.readUInt24();
330
- expect(buffalo.getPosition()).toStrictEqual(4);
331
- expect(value).toStrictEqual(100000);
332
- });
333
-
334
- it("INT24 write +", () => {
335
- const buffalo = new Buffalo(Buffer.alloc(3));
336
- buffalo.writeInt24(65536);
337
- expect(buffalo.getPosition()).toStrictEqual(3);
338
- expect(buffalo.getBuffer()).toStrictEqual(Buffer.from([0x00, 0x00, 0x01]));
339
- });
340
-
341
- it("INT24 read +", () => {
342
- const buffalo = new Buffalo(Buffer.from([0x7f, 0xff, 0xff, 0x7f]), 1);
343
- const value = buffalo.readInt24();
344
- expect(buffalo.getPosition()).toStrictEqual(4);
345
- expect(value).toStrictEqual(8388607);
346
- });
347
-
348
- it("INT24 write -", () => {
349
- const buffalo = new Buffalo(Buffer.alloc(3));
350
- buffalo.writeInt24(-65536);
351
- expect(buffalo.getPosition()).toStrictEqual(3);
352
- expect(buffalo.getBuffer()).toStrictEqual(Buffer.from([0x00, 0x00, 0xff]));
353
- });
354
-
355
- it("INT24 read -", () => {
356
- const buffalo = new Buffalo(Buffer.from([0x00, 0x00, 0xff]));
357
- const value = buffalo.readInt24();
358
- expect(buffalo.getPosition()).toStrictEqual(3);
359
- expect(value).toStrictEqual(-65536);
360
- });
361
-
362
- it("INT32 write", () => {
363
- const buffalo = new Buffalo(Buffer.alloc(4));
364
- buffalo.writeInt32(2147483647);
365
- expect(buffalo.getPosition()).toStrictEqual(4);
366
- expect(buffalo.getBuffer()).toStrictEqual(Buffer.from([0xff, 0xff, 0xff, 0x7f]));
367
- });
368
-
369
- it("INT32 read", () => {
370
- const buffalo = new Buffalo(Buffer.from([0x08, 0xff, 0x03, 0xff]));
371
- const value = buffalo.readInt32();
372
- expect(buffalo.getPosition()).toStrictEqual(4);
373
- expect(value).toStrictEqual(-16515320);
374
- });
375
-
376
- it("INT48 write", () => {
377
- const buffalo = new Buffalo(Buffer.alloc(6));
378
- buffalo.writeInt48(-1082348273920);
379
- expect(buffalo.getPosition()).toStrictEqual(6);
380
- expect(buffalo.getBuffer()).toStrictEqual(Buffer.from([0x00, 0xff, 0x03, 0xff, 0x03, 0xff]));
381
- });
382
-
383
- it("INT48 read", () => {
384
- const buffalo = new Buffalo(Buffer.from([0x00, 0xff, 0x03, 0xff, 0x03, 0xff]));
385
- const value = buffalo.readInt48();
386
- expect(buffalo.getPosition()).toStrictEqual(6);
387
- expect(value).toStrictEqual(-1082348273920);
388
- });
389
-
390
- it("FLOATLE write", () => {
391
- const buffalo = new Buffalo(Buffer.alloc(4));
392
- buffalo.writeFloatLE(400.5);
393
- expect(buffalo.getPosition()).toStrictEqual(4);
394
- expect(buffalo.getBuffer()).toStrictEqual(Buffer.from([0x00, 0x40, 0xc8, 0x43]));
395
- });
396
-
397
- it("FLOATLE read", () => {
398
- const buffalo = new Buffalo(Buffer.from([0x00, 0x40, 0xc8, 0x43]));
399
- const value = buffalo.readFloatLE();
400
- expect(buffalo.getPosition()).toStrictEqual(4);
401
- expect(value).toStrictEqual(400.5);
402
- });
403
-
404
- it("DOUBLELE write", () => {
405
- const buffalo = new Buffalo(Buffer.alloc(8));
406
- buffalo.writeDoubleLE(809880.6);
407
- expect(buffalo.getPosition()).toStrictEqual(8);
408
- expect(buffalo.getBuffer()).toStrictEqual(Buffer.from([0x33, 0x33, 0x33, 0x33, 0x31, 0xb7, 0x28, 0x41]));
409
- });
410
-
411
- it("DOUBLELE read", () => {
412
- const buffalo = new Buffalo(Buffer.from([0x33, 0x33, 0x33, 0x33, 0x31, 0xb7, 0x28, 0x41]), 0);
413
- const value = buffalo.readDoubleLE();
414
- expect(buffalo.getPosition()).toStrictEqual(8);
415
- expect(value).toStrictEqual(809880.6);
416
- });
417
-
418
- it("UTF8 STRING write", () => {
419
- const buffalo = new Buffalo(Buffer.alloc(4));
420
- buffalo.writeUtf8String("abcd");
421
- expect(buffalo.getPosition()).toStrictEqual(4);
422
- expect(buffalo.getBuffer()).toStrictEqual(Buffer.from([0x61, 0x62, 0x63, 0x64]));
423
- });
424
-
425
- it("UTF8 STRING read", () => {
426
- const buffalo = new Buffalo(Buffer.from([0x61, 0x62, 0x63, 0x64]), 0);
427
- const value = buffalo.readUtf8String(4);
428
- expect(buffalo.getPosition()).toStrictEqual(4);
429
- expect(value).toStrictEqual("abcd");
430
- });
431
- });
@@ -1,193 +0,0 @@
1
- import {bench, describe} from "vitest";
2
- import Adapter from "../src/adapter/adapter";
3
- import {FIXED_ENDPOINTS} from "../src/adapter/ember/adapter/endpoints";
4
- import type {ZclPayload} from "../src/adapter/events";
5
- import {Controller} from "../src/controller";
6
- import Database from "../src/controller/database";
7
- import {setLogger} from "../src/utils/logger";
8
- import * as Zcl from "../src/zspec/zcl";
9
- import * as Zdo from "../src/zspec/zdo";
10
-
11
- // mock necessary functions to avoid system calls / adapter interactions
12
-
13
- // no-op, makes up for too much of the perf loss (with console logging by default)
14
- setLogger({
15
- debug: () => {},
16
- info: () => {},
17
- warning: () => {},
18
- error: () => {},
19
- });
20
-
21
- const NETWORK_OPTIONS = {
22
- panID: 0x1a62,
23
- extendedPanID: [0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd],
24
- channelList: [11],
25
- networkKey: [1, 3, 5, 7, 9, 11, 13, 15, 0, 2, 4, 6, 8, 10, 12, 13],
26
- // networkKeyDistribute?: boolean;
27
- };
28
- const COORD_IEEE = "0x1234567812345678";
29
- const controller = new Controller({
30
- network: NETWORK_OPTIONS,
31
- serialPort: {
32
- baudRate: 115200,
33
- rtscts: false,
34
- path: "/dev/ttyDummy0",
35
- adapter: "ember",
36
- },
37
- databasePath: "database.db",
38
- databaseBackupPath: "database.db.backup",
39
- backupPath: "coordinator_backup.json",
40
- adapter: {
41
- // concurrent?: number;
42
- // delay?: number;
43
- disableLED: false,
44
- // transmitPower?: number;
45
- // forceStartWithInconsistentAdapterConfiguration?: boolean;
46
- },
47
- acceptJoiningDeviceHandler: async () => true,
48
- });
49
- controller.backup = async () => {};
50
- const dbOpen = Database.open;
51
- Database.open = (path) => {
52
- const db = dbOpen(path);
53
- // no-op
54
- db.write = () => {};
55
-
56
- return db;
57
- };
58
- let adapter: Adapter;
59
- const adapterCreate = Adapter.create;
60
- Adapter.create = async (networkOptions, serialPortOptions, backupPath, adapterOptions) => {
61
- adapter = await adapterCreate(networkOptions, serialPortOptions, backupPath, adapterOptions);
62
- adapter.start = async () => await Promise.resolve("resumed");
63
- adapter.getCoordinatorIEEE = async () => await Promise.resolve(COORD_IEEE);
64
- adapter.getNetworkParameters = async () =>
65
- await Promise.resolve({
66
- panID: NETWORK_OPTIONS.panID,
67
- extendedPanID: `${Buffer.from(NETWORK_OPTIONS.extendedPanID!).toString("hex")}`,
68
- channel: NETWORK_OPTIONS.channelList[0],
69
- nwkUpdateID: 1,
70
- });
71
- // @ts-expect-error ignore overrides typing
72
- adapter.sendZdo = async (_ieeeAddress: string, networkAddress: number, clusterId: Zdo.ClusterId, payload: Buffer, _disableResponse: boolean) => {
73
- if (networkAddress === 0x0000) {
74
- switch (clusterId) {
75
- case Zdo.ClusterId.ACTIVE_ENDPOINTS_REQUEST: {
76
- return await Promise.resolve([
77
- Zdo.Status.SUCCESS,
78
- {
79
- nwkAddress: 0x0000,
80
- endpointList: [FIXED_ENDPOINTS[0].endpoint, FIXED_ENDPOINTS[1].endpoint],
81
- },
82
- ]);
83
- }
84
- case Zdo.ClusterId.SIMPLE_DESCRIPTOR_REQUEST: {
85
- if (payload.readUInt8(3) === FIXED_ENDPOINTS[0].endpoint) {
86
- return await Promise.resolve([
87
- Zdo.Status.SUCCESS,
88
- {
89
- nwkAddress: 0x0000,
90
- length: 1, // unused
91
- ...FIXED_ENDPOINTS[0],
92
- },
93
- ]);
94
- }
95
-
96
- if (payload.readUInt8(3) === FIXED_ENDPOINTS[1].endpoint) {
97
- return await Promise.resolve([
98
- Zdo.Status.SUCCESS,
99
- {
100
- nwkAddress: 0x0000,
101
- length: 1, // unused
102
- ...FIXED_ENDPOINTS[1],
103
- },
104
- ]);
105
- }
106
- }
107
- }
108
- }
109
-
110
- return await Promise.resolve([Zdo.Status.NOT_SUPPORTED]);
111
- };
112
-
113
- return adapter;
114
- };
115
-
116
- const BASIC_RESP = Zcl.Frame.create(
117
- 0,
118
- 1,
119
- true,
120
- undefined,
121
- 10,
122
- "readRsp",
123
- 0,
124
- [
125
- {
126
- attrId: 5,
127
- dataType: Zcl.DataType.CHAR_STR,
128
- attrData: "Herd-01",
129
- status: 0,
130
- },
131
- {
132
- attrId: 4,
133
- dataType: Zcl.DataType.CHAR_STR,
134
- attrData: "Herdsman",
135
- status: 0,
136
- },
137
- ],
138
- {},
139
- ).toBuffer();
140
-
141
- describe("Controller", () => {
142
- bench(
143
- "Startup with dummy adapter",
144
- async () => {
145
- await controller.start();
146
- },
147
- {throws: true},
148
- );
149
-
150
- bench(
151
- "Receive ZCL message",
152
- () => {
153
- adapter.emit("zclPayload", {
154
- clusterID: Zcl.Clusters.genBasic.ID,
155
- header: Zcl.Header.fromBuffer(BASIC_RESP),
156
- address: 0x0000,
157
- data: BASIC_RESP,
158
- endpoint: 1,
159
- linkquality: 200,
160
- groupID: 0,
161
- wasBroadcast: false,
162
- destinationEndpoint: 1,
163
- } satisfies ZclPayload);
164
- },
165
- {
166
- setup: async () => {
167
- await controller.start();
168
- },
169
- throws: true,
170
- },
171
- );
172
-
173
- bench(
174
- "Receive ZDO message",
175
- () => {
176
- adapter.emit("zdoResponse", Zdo.ClusterId.NETWORK_ADDRESS_RESPONSE, [
177
- Zdo.Status.SUCCESS,
178
- {
179
- eui64: COORD_IEEE,
180
- nwkAddress: 0x0000,
181
- startIndex: 1,
182
- assocDevList: [],
183
- },
184
- ]);
185
- },
186
- {
187
- setup: async () => {
188
- await controller.start();
189
- },
190
- throws: true,
191
- },
192
- );
193
- });