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,109 +0,0 @@
1
- import {EZSP_MAX_FRAME_LENGTH, EZSP_MIN_FRAME_LENGTH} from "../ezsp/consts";
2
-
3
- /**
4
- * Define the size of the receive buffer pool on the EZSP host.
5
- *
6
- * The number of receive buffers does not need to be greater than the number of packet buffers available on the NCP,
7
- * because this in turn is the maximum number of callbacks that could be received between commands.
8
- * In reality a value of 20 is a generous allocation.
9
- */
10
- export const EZSP_HOST_RX_POOL_SIZE = 32;
11
- /**
12
- * The number of transmit buffers must be set to the number of receive buffers
13
- * -- to hold the immediate ACKs sent for each callabck frame received --
14
- * plus 3 buffers for the retransmit queue and one each for an automatic ACK
15
- * (due to data flow control) and a command.
16
- */
17
- export const TX_POOL_BUFFERS = EZSP_HOST_RX_POOL_SIZE + 5;
18
-
19
- /** protocol version */
20
- export const ASH_VERSION = 2;
21
-
22
- /**
23
- * Timeouts before link is judged down.
24
- *
25
- * Consecutive ACK timeouts (minus 1) needed to enter the ERROR state.
26
- *
27
- * Is 3 in ash-ncp.h
28
- */
29
- export const ASH_MAX_TIMEOUTS = 6;
30
- /** max time in msecs for ncp to wake */
31
- export const ASH_MAX_WAKE_TIME = 150;
32
-
33
- /**
34
- * Define the units used by the Not Ready timer as 2**n msecs
35
- * log2 of msecs per NR timer unit
36
- */
37
- export const ASH_NR_TIMER_BIT = 4;
38
-
39
- /** Control byte mask for DATA frame */
40
- export const ASH_DFRAME_MASK = 0x80;
41
- /** Control byte mask for short frames (ACK/NAK) */
42
- export const ASH_SHFRAME_MASK = 0xe0;
43
-
44
- /** Acknowledge frame number */
45
- export const ASH_ACKNUM_MASK = 0x07;
46
- export const ASH_ACKNUM_BIT = 0;
47
- /** Retransmitted frame flag */
48
- export const ASH_RFLAG_MASK = 0x08;
49
- export const ASH_RFLAG_BIT = 3;
50
- /** Receiver not ready flag */
51
- export const ASH_NFLAG_MASK = 0x08;
52
- export const ASH_NFLAG_BIT = 3;
53
- /** Reserved for future use */
54
- export const ASH_PFLAG_MASK = 0x10;
55
- export const ASH_PFLAG_BIT = 4;
56
- /** DATA frame number */
57
- export const ASH_FRMNUM_MASK = 0x70;
58
- export const ASH_FRMNUM_BIT = 4;
59
-
60
- /**
61
- * The wake byte special function applies only when in between frames,
62
- * so it does not need to be escaped within a frame.
63
- * (also means NCP data pending)
64
- */
65
- export const ASH_WAKE = 0xff; /*!< */
66
-
67
- /** Constant used in byte-stuffing (XOR mask used in byte stuffing) */
68
- export const ASH_FLIP = 0x20;
69
-
70
- // Field and frame lengths, excluding flag byte and any byte stuffing overhead
71
- // All limits are inclusive
72
- export const ASH_MIN_DATA_FIELD_LEN = EZSP_MIN_FRAME_LENGTH;
73
- export const ASH_MAX_DATA_FIELD_LEN = EZSP_MAX_FRAME_LENGTH;
74
- /** with control */
75
- export const ASH_MIN_DATA_FRAME_LEN = ASH_MIN_DATA_FIELD_LEN + 1;
76
- /** control plus data field, but not CRC */
77
- export const ASH_MIN_FRAME_LEN = 1;
78
- export const ASH_MAX_FRAME_LEN = ASH_MAX_DATA_FIELD_LEN + 1;
79
- export const ASH_CRC_LEN = 2;
80
- export const ASH_MIN_FRAME_WITH_CRC_LEN = ASH_MIN_FRAME_LEN + ASH_CRC_LEN;
81
- export const ASH_MAX_FRAME_WITH_CRC_LEN = ASH_MAX_FRAME_LEN + ASH_CRC_LEN;
82
-
83
- // Lengths for each frame type: includes control and data field (if any), excludes the CRC and flag bytes
84
- /** ash frame len data min */
85
- export const ASH_FRAME_LEN_DATA_MIN = ASH_MIN_DATA_FIELD_LEN + 1;
86
- /** [control] */
87
- export const ASH_FRAME_LEN_ACK = 1;
88
- /** [control] */
89
- export const ASH_FRAME_LEN_NAK = 1;
90
- /** [control] */
91
- export const ASH_FRAME_LEN_RST = 1;
92
- /** [control, version, reset reason] */
93
- export const ASH_FRAME_LEN_RSTACK = 3;
94
- /** [control, version, error] */
95
- export const ASH_FRAME_LEN_ERROR = 3;
96
-
97
- // Define lengths of short frames - includes control byte and data field
98
- /** longest non-data frame sent */
99
- export const SH_TX_BUFFER_LEN = 2;
100
- /** longest non-data frame received */
101
- export const SH_RX_BUFFER_LEN = 3;
102
-
103
- // Define constants for the LFSR in randomizeBuffer()
104
- /** polynomial */
105
- export const LFSR_POLY = 0xb8;
106
- /** initial value (seed) */
107
- export const LFSR_SEED = 0x42;
108
-
109
- export const VALID_BAUDRATES = [600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800];
@@ -1,192 +0,0 @@
1
- /**
2
- * Identify the type of frame from control byte.
3
- *
4
- * Control byte formats
5
- * +---------+----+----+----+----+----+----+----+----++---------+
6
- * | | B7 | B6 | B5 | B4 | B3 | B2 | B1 | B0 || Range |
7
- * +---------+----+----+----+----+----+----+----+----++---------+
8
- * | DATA | 0 | frameNum | rF | ackNum ||0x00-0x7F|
9
- * +---------+----+----+----+----+----+----+----+----++---------+
10
- * | ACK | 1 | 0 | 0 | pF | nF | ackNum ||0x80-0x9F|
11
- * | NAK | 1 | 0 | 1 | pF | nF | ackNum ||0xA0-0xBF|
12
- * +---------+----+----+----+----+----+----+----+----++---------+
13
- * | RST | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 || 0xC0 |
14
- * | RSTACK | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 || 0xC1 |
15
- * | ERROR | 1 | 1 | 0 | 0 | 0 | 0 | 1 | 0 || 0xC2 |
16
- * +---------+----+----+----+----+----+----+----+----++---------+
17
- * rF = rFlag (retransmission flag)
18
- * nF = nFlag (receiver not ready flag, always 0 in frames sent by the NCP)
19
- * pF = flag reserved for future use
20
- * frameNum = DATA frame’s 3-bit sequence number
21
- * ackNum = acknowledges receipt of DATA frames up to, but not including, ackNum
22
- * Control byte values 0xC3-0xFE are unused, 0xFF is reserved.
23
- */
24
- export enum AshFrameType {
25
- INVALID = -1,
26
- /**
27
- * Carries all EZSP frames.
28
- *
29
- * [CONTROL, EZSP 0, EZSP 1, EZSP 2, EZSP n, CRC high, CRC low, FLAG]
30
- *
31
- * Notation used in documentation: DATA(F, A, R)
32
- * - F: frame number (frmNum)
33
- * - A: acknowledge number (ackNum)
34
- * - R: retransmit flag (reTx)
35
- *
36
- * Example without pseudo-random sequence applied to Data Field:
37
- * - EZSP “version” command: 00 00 00 02
38
- * - DATA(2, 5, 0) = 25 00 00 00 02 1A AD 7E
39
- * - EZSP “version” response: 00 80 00 02 02 11 30
40
- * - DATA(5, 3, 0) = 53 00 80 00 02 02 11 30 63 16 7E
41
- *
42
- * Example with pseudo-random sequence applied to Data Field:
43
- * - EZSP “version” command: 00 00 00 02
44
- * - DATA(2, 5, 0) = 25 42 21 A8 56 A6 09 7E
45
- * - EZSP “version” response: 00 80 00 02 02 11 30
46
- * - DATA(5, 3, 0) = 53 42 A1 A8 56 28 04 82 96 23 7E
47
- *
48
- * Sent by: NCP, Host
49
- */
50
- DATA = 0,
51
- /**
52
- * Acknowledges receipt of a valid DATA frame.
53
- *
54
- * [CONTROL, CRC high, CRC low, FLAG]
55
- *
56
- * Notation used in documentation: ACK(A)+/-
57
- * - A: acknowledge number (ackNum)
58
- * - +/-: not ready flag (nRdy); “+” = “0” = “ready”; “-” = “1” = “not ready”
59
- *
60
- * Examples:
61
- * - ACK(1)+ :81 60 59 7E
62
- * - ACK(6)– : 8E 91 B6 7E
63
- *
64
- * Sent by: NCP, Host
65
- */
66
- ACK = 0x80, // 0b10000000
67
- /**
68
- * Indicates receipt of a DATA frame with an error or that was discarded due to lack of memory.
69
- *
70
- * [CONTROL, CRC high, CRC low, FLAG]
71
- *
72
- * Notation used in documentation: NAK(A)+/-
73
- * - A: acknowledge number (ackNum)
74
- * - +/-: not ready flag (nRdy); “+” = “0” = “ready”; “-” = “1” = “not ready”
75
- *
76
- * Examples:
77
- * - NAK(6)+ : A6 34 DC 7E
78
- * - NAK(5)- : AD 85 B7 7E
79
- *
80
- * Sent by: NCP, Host
81
- */
82
- NAK = 0xa0, // 0b10100000
83
- /**
84
- * Requests the NCP to perform a software reset (valid even if the NCP is in the FAILED state).
85
- *
86
- * [CONTROL, CRC high, CRC low, FLAG]
87
- *
88
- * Notation used in documentation: RST()
89
- *
90
- * Example: C0 38 BC 7E
91
- *
92
- * Sent by: Host
93
- */
94
- RST = 0xc0, // 0b11000000
95
- /**
96
- * Informs the Host that the NCP has reset and the reason for the reset.
97
- *
98
- * [CONTROL, version, reset code, CRC high, CRC low, FLAG]
99
- *
100
- * Notation used in documentation: RSTACK(V, C)
101
- * - V: version
102
- * - C: reset code
103
- *
104
- * Example: C1 02 02 9B 7B 7E
105
- *
106
- * Sent by: NCP
107
- */
108
- RSTACK = 0xc1, // 0b11000001
109
- /**
110
- * Informs the Host that the NCP detected a fatal error and is in the FAILED state.
111
- *
112
- * [CONTROL, version, error code, CRC high, CRC low, FLAG]
113
- *
114
- * Notation used in documentation: ERROR(V, C )
115
- * - V: version
116
- * - C: reset code
117
- *
118
- * Example: C2 01 52 FA BD 7E
119
- *
120
- * Sent by: NCP
121
- */
122
- ERROR = 0xc2, // 0b11000010
123
- }
124
-
125
- export enum AshReservedByte {
126
- /**
127
- * Marks the end of a frame.
128
- *
129
- * When a Flag Byte is received, the data received since the last Flag Byte or Cancel Byte
130
- * is tested to see whether it is a valid frame. */
131
- FLAG = 0x7e,
132
- /**
133
- * Indicates that the following byte is escaped.
134
- *
135
- * If the byte after the Escape Byte is not a reserved byte,
136
- * bit 5 of the byte is complemented to restore its original value.
137
- * If the byte after the Escape Byte is a reserved value, the Escape Byte has no effect. */
138
- ESCAPE = 0x7d,
139
- /**
140
- * Resume transmission.
141
- *
142
- * Used in XON/XOFF flow control. Always ignored if received by the NCP.
143
- */
144
- XON = 0x11,
145
- /**
146
- * Stop transmission.
147
- *
148
- * Used in XON/XOFF flow control. Always ignored if received by the NCP
149
- */
150
- XOFF = 0x13,
151
- /**
152
- * Replaces a byte received with a low-level communication error (e.g., framing error) from the UART.
153
- *
154
- * When a Substitute Byte is processed, the data between the previous and the next Flag Bytes is ignored.
155
- */
156
- SUBSTITUTE = 0x18,
157
- /**
158
- * Terminates a frame in progress.
159
- *
160
- * A Cancel Byte causes all data received since the previous Flag Byte to be ignored.
161
- * Note that as a special case, RST and RSTACK frames are preceded by Cancel Bytes to ignore any link startup noise.
162
- */
163
- CANCEL = 0x1a,
164
- }
165
-
166
- /**
167
- * The NCP enters the FAILED state if it detects one of the following errors:
168
- * - An abnormal internal reset due to an error, failed assertion, or fault.
169
- * - Exceeding the maximum number of consecutive acknowledgement timeouts.
170
- *
171
- * When the NCP enters the FAILED state, the NCP sends an ERROR frame containing a reset or error code
172
- * and will reply to all subsequent frames received, except RST, with an ERROR frame.
173
- * To reinitialize the ASH protocol, the Host must reset the NCP by either asserting the nRESET pin or sending the RST frame.
174
- *
175
- * The codes are returned by the NCP in the:
176
- * - Reset Code byte of a RSTACK frame
177
- * - Error Code byte of an ERROR frame.
178
- *
179
- * Silicon Labs wireless mesh chips can detect numerous reset fault causes beyond those in the table.
180
- * When sent to the host, these new reset codes have 0x80 added to the value returned by their HAL’s reset code.
181
- */
182
- export enum NcpFailedCode {
183
- RESET_UNKNOWN_REASON = 0,
184
- RESET_EXTERNAL = 1,
185
- RESET_POWERON = 2,
186
- RESET_WATCHDOG = 3,
187
- RESET_ASSERT = 6,
188
- RESET_BOOTLOADER = 9,
189
- RESET_SOFTWARE = 11,
190
- ERROR_EXCEEDED_MAXIMUM_ACK_TIMEOUT_COUNT = 0x51,
191
- CHIP_SPECIFIC_ERROR_RESET_CODE = 0x80,
192
- }
@@ -1,48 +0,0 @@
1
- /* v8 ignore start */
2
-
3
- import {Transform, type TransformCallback, type TransformOptions} from "node:stream";
4
-
5
- // import {logger} from '../../../utils/logger';
6
- import {AshReservedByte} from "./enums";
7
-
8
- // const NS = 'zh:ember:uart:ash:parser';
9
-
10
- export class AshParser extends Transform {
11
- private buffer: Buffer;
12
-
13
- public constructor(opts?: TransformOptions) {
14
- super(opts);
15
-
16
- this.buffer = Buffer.alloc(0);
17
- }
18
-
19
- override _transform(chunk: Buffer, _encoding: BufferEncoding, cb: TransformCallback): void {
20
- let data = Buffer.concat([this.buffer, chunk]);
21
- let position: number;
22
-
23
- // biome-ignore lint/suspicious/noAssignInExpressions: shorter
24
- while ((position = data.indexOf(AshReservedByte.FLAG)) !== -1) {
25
- // emit the frame via 'data' event
26
- const frame = data.subarray(0, position + 1);
27
-
28
- // expensive and very verbose, enable locally only if necessary
29
- // logger.debug(`<<<< [FRAME raw=${frame.toString('hex')}]`, NS);
30
- this.push(frame);
31
-
32
- // remove the frame from internal buffer (set below)
33
- data = data.subarray(position + 1);
34
- }
35
-
36
- this.buffer = data;
37
-
38
- cb();
39
- }
40
-
41
- override _flush(cb: TransformCallback): void {
42
- this.push(this.buffer);
43
-
44
- this.buffer = Buffer.alloc(0);
45
-
46
- cb();
47
- }
48
- }
@@ -1,247 +0,0 @@
1
- /* v8 ignore start */
2
-
3
- import {logger} from "../../../utils/logger";
4
- import {EZSP_MAX_FRAME_LENGTH} from "../ezsp/consts";
5
-
6
- const NS = "zh:ember:uart:queues";
7
-
8
- /**
9
- * Buffer to hold a DATA frame.
10
- * Allocates `data` to `EZSP_MAX_FRAME_LENGTH` filled with zeroes.
11
- */
12
- export class EzspBuffer {
13
- /** uint8_t[EZSP_MAX_FRAME_LENGTH] */
14
- public data: Buffer;
15
- public link?: EzspBuffer;
16
- /** uint8_t */
17
- public len: number;
18
-
19
- constructor() {
20
- this.data = Buffer.alloc(EZSP_MAX_FRAME_LENGTH); // inits to all-zeroes
21
- this.link = undefined;
22
- this.len = 0;
23
- }
24
- }
25
-
26
- /**
27
- * Simple queue (singly-linked list)
28
- */
29
- export class EzspQueue {
30
- public tail?: EzspBuffer;
31
-
32
- constructor() {
33
- this.tail = undefined;
34
- }
35
-
36
- /**
37
- * Get the number of buffers in the queue.
38
- * @returns
39
- */
40
- get length(): number {
41
- let head = this.tail;
42
- let count = 0;
43
-
44
- for (count; head !== undefined; count++) {
45
- head = head.link;
46
- }
47
-
48
- return count;
49
- }
50
-
51
- get empty(): boolean {
52
- return this.tail === undefined;
53
- }
54
-
55
- /**
56
- * Get a pointer to the buffer at the head of the queue.
57
- * @returns
58
- */
59
- get head(): EzspBuffer {
60
- let head = this.tail;
61
-
62
- if (head === undefined) {
63
- throw new Error("Tried to get head from an empty queue.");
64
- }
65
-
66
- while (head.link !== undefined) {
67
- head = head.link;
68
- }
69
-
70
- return head;
71
- }
72
-
73
- /**
74
- * Get a pointer to the Nth entry in the queue (the tail corresponds to N = 1).
75
- *
76
- * @param n
77
- * @returns
78
- */
79
- public getNthEntry(n: number): EzspBuffer | undefined {
80
- if (n === 0) {
81
- throw new Error("Asked for 0th element in queue.");
82
- }
83
-
84
- let buf = this.tail;
85
-
86
- while (--n) {
87
- if (buf === undefined) {
88
- throw new Error("Less than N entries in queue.");
89
- }
90
-
91
- buf = buf.link;
92
- }
93
-
94
- return buf;
95
- }
96
-
97
- /**
98
- * Get a pointer to the entry before the specified entry (closer to the tail).
99
- * If the buffer specified is undefined, the head entry is returned.
100
- * If the buffer specified is the tail, undefined is returned.
101
- * @param entry The buffer to look before.
102
- * @returns
103
- */
104
- public getPrecedingEntry(entry?: EzspBuffer): EzspBuffer | undefined {
105
- let buf = this.tail;
106
-
107
- if (buf === entry) {
108
- return undefined;
109
- }
110
-
111
- if (buf === undefined) {
112
- throw new Error("Tried to get preceding entry from an empty queue.");
113
- }
114
-
115
- do {
116
- if (buf.link === entry) {
117
- return buf;
118
- }
119
-
120
- buf = buf.link;
121
- } while (buf !== undefined);
122
-
123
- throw new Error("Buffer not in queue.");
124
- }
125
-
126
- /**
127
- * Add a buffer to the tail of the queue.
128
- * @param buf
129
- */
130
- public addTail(buf: EzspBuffer): void {
131
- if (buf) {
132
- buf.link = this.tail;
133
- this.tail = buf;
134
- } else {
135
- throw new Error("Called addTail with undefined buffer");
136
- }
137
- }
138
-
139
- /**
140
- * Remove the buffer at the head of the queue.
141
- * @returns The removed buffer.
142
- */
143
- public removeHead(): EzspBuffer {
144
- let head = this.tail;
145
-
146
- if (head === undefined) {
147
- throw new Error("Tried to remove head from an empty queue.");
148
- }
149
-
150
- if (head.link === undefined) {
151
- this.tail = undefined;
152
- } else {
153
- let prev: EzspBuffer;
154
-
155
- do {
156
- prev = head;
157
- head = head.link;
158
- } while (head.link !== undefined);
159
-
160
- prev.link = undefined;
161
- }
162
-
163
- return head;
164
- }
165
-
166
- /**
167
- * Remove the specified entry from the queue.
168
- * @param entry
169
- * @returns A pointer to the preceding entry (if any).
170
- */
171
- public removeEntry(entry: EzspBuffer): EzspBuffer | undefined {
172
- const buf = this.getPrecedingEntry(entry);
173
-
174
- if (buf !== undefined) {
175
- buf.link = entry.link;
176
- } else {
177
- this.tail = entry.link;
178
- }
179
-
180
- return buf;
181
- }
182
- }
183
-
184
- /**
185
- * Simple free list (singly-linked list)
186
- */
187
- export class EzspFreeList {
188
- public link?: EzspBuffer;
189
-
190
- constructor() {
191
- this.link = undefined;
192
- }
193
-
194
- /**
195
- * Get the number of buffers in the free list.
196
- * @returns
197
- */
198
- get length(): number {
199
- let next = this.link;
200
- let count = 0;
201
-
202
- for (count; next !== undefined; count++) {
203
- next = next.link;
204
- }
205
-
206
- return count;
207
- }
208
-
209
- /**
210
- * Add a buffer to the free list.
211
- * @param buf
212
- */
213
- public freeBuffer(buf: EzspBuffer): void {
214
- if (buf) {
215
- buf.link = this.link;
216
- this.link = buf;
217
- } else {
218
- throw new Error("Called freeBuffer with undefined buffer");
219
- }
220
- }
221
-
222
- /**
223
- * Get a buffer from the free list.
224
- * @returns
225
- */
226
- public allocBuffer(): EzspBuffer | undefined {
227
- const buf = this.link;
228
-
229
- if (buf !== undefined) {
230
- this.link = buf.link;
231
- buf.len = 0;
232
-
233
- if (buf.data.length !== EZSP_MAX_FRAME_LENGTH) {
234
- // should never happen if buffers are handled properly, but just in case, re-alloc to max length
235
- buf.data = Buffer.alloc(EZSP_MAX_FRAME_LENGTH);
236
-
237
- const e = new Error();
238
- logger.error(`Pre-allocated buffer had improper size and had to be re-allocated. ${e.stack}`, NS);
239
- } else {
240
- // (void) memset(buffer->data, 0, EZSP_MAX_FRAME_LENGTH);
241
- buf.data.fill(0);
242
- }
243
- }
244
-
245
- return buf;
246
- }
247
- }
@@ -1,53 +0,0 @@
1
- /* v8 ignore start */
2
-
3
- import {Readable, type ReadableOptions} from "node:stream";
4
-
5
- // import {logger} from '../../../utils/logger';
6
-
7
- // const NS = 'zh:ember:uart:ash:writer';
8
-
9
- export class AshWriter extends Readable {
10
- private bytesToWrite: number[];
11
-
12
- constructor(opts?: ReadableOptions) {
13
- super(opts);
14
-
15
- this.bytesToWrite = [];
16
- }
17
-
18
- private writeBytes(): void {
19
- const buffer = Buffer.from(this.bytesToWrite);
20
- this.bytesToWrite = [];
21
-
22
- // expensive and very verbose, enable locally only if necessary
23
- // logger.debug(`>>>> [FRAME raw=${buffer.toString('hex')}]`, NS);
24
-
25
- // this.push(buffer);
26
- this.emit("data", buffer);
27
- }
28
-
29
- public writeByte(byte: number): void {
30
- this.bytesToWrite.push(byte);
31
- }
32
-
33
- public writeAvailable(): boolean {
34
- if (this.readableLength < this.readableHighWaterMark) {
35
- return true;
36
- }
37
-
38
- this.writeFlush();
39
-
40
- return false;
41
- }
42
-
43
- /**
44
- * If there is anything to send, send to the port.
45
- */
46
- public writeFlush(): void {
47
- if (this.bytesToWrite.length) {
48
- this.writeBytes();
49
- }
50
- }
51
-
52
- public override _read(): void {}
53
- }
@@ -1,58 +0,0 @@
1
- /* v8 ignore start */
2
-
3
- import * as ZSpec from "../../../zspec";
4
- import type {NetworkCache} from "../adapter/emberAdapter";
5
- import {INVALID_RADIO_CHANNEL, ZB_PSA_ALG} from "../consts";
6
- import {EmberJoinMethod, SecManDerivedKeyType, SecManFlag, SecManKeyType} from "../enums";
7
- import {EMBER_AES_HASH_BLOCK_SIZE} from "../ezsp/consts";
8
- import type {EmberAesMmoHashContext, SecManContext} from "../types";
9
-
10
- /**
11
- * Initialize a network cache index with proper "invalid" values.
12
- * @returns
13
- */
14
- export const initNetworkCache = (): NetworkCache => {
15
- return {
16
- eui64: ZSpec.BLANK_EUI64,
17
- parameters: {
18
- extendedPanId: ZSpec.BLANK_EXTENDED_PAN_ID.slice(), // copy
19
- panId: ZSpec.INVALID_PAN_ID,
20
- radioTxPower: 0,
21
- radioChannel: INVALID_RADIO_CHANNEL,
22
- joinMethod: EmberJoinMethod.MAC_ASSOCIATION,
23
- nwkManagerId: ZSpec.NULL_NODE_ID,
24
- nwkUpdateId: 0,
25
- channels: ZSpec.ALL_802_15_4_CHANNELS_MASK,
26
- },
27
- };
28
- };
29
-
30
- /**
31
- * This routine will initialize a Security Manager context correctly for use in subsequent function calls.
32
- * @returns
33
- */
34
- export const initSecurityManagerContext = (): SecManContext => {
35
- return {
36
- coreKeyType: SecManKeyType.NONE,
37
- keyIndex: 0,
38
- derivedType: SecManDerivedKeyType.NONE,
39
- eui64: "0x0000000000000000",
40
- multiNetworkIndex: 0,
41
- flags: SecManFlag.NONE,
42
- psaKeyAlgPermission: ZB_PSA_ALG, // unused for classic key storage
43
- };
44
- };
45
-
46
- /**
47
- * This routine clears the passed context so that a new hash calculation
48
- * can be performed.
49
- *
50
- * @returns context A pointer to the location of hash context to clear.
51
- */
52
- export const aesMmoHashInit = (): EmberAesMmoHashContext => {
53
- // MEMSET(context, 0, sizeof(EmberAesMmoHashContext));
54
- return {
55
- result: Buffer.alloc(EMBER_AES_HASH_BLOCK_SIZE), // uint8_t[EMBER_AES_HASH_BLOCK_SIZE]
56
- length: 0x00000000, // uint32_t
57
- };
58
- };