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,1392 +0,0 @@
1
- /* v8 ignore start */
2
-
3
- import Buffalo from "../../../buffalo/buffalo";
4
- import {GP_SINK_LIST_ENTRIES} from "../consts";
5
- import {EmberGpApplicationId, EmberGpSinkType, EzspStatus, SLStatus} from "../enums";
6
- import type {
7
- Ember802154RadioPriorities,
8
- EmberAesMmoHashContext,
9
- EmberApsFrame,
10
- EmberBeaconClassificationParams,
11
- EmberBeaconData,
12
- EmberBeaconIterator,
13
- EmberBindingTableEntry,
14
- EmberCertificate283k1Data,
15
- EmberCertificateData,
16
- EmberChildData,
17
- EmberCurrentSecurityState,
18
- EmberDutyCycleLimits,
19
- EmberEndpointDescription,
20
- EmberGpAddress,
21
- EmberGpProxyTableEntry,
22
- EmberGpSinkListEntry,
23
- EmberGpSinkTableEntry,
24
- EmberInitialSecurityState,
25
- EmberKeyData,
26
- EmberMessageDigest,
27
- EmberMulticastTableEntry,
28
- EmberMultiPhyRadioParameters,
29
- EmberMultiprotocolPriorities,
30
- EmberNeighborTableEntry,
31
- EmberNetworkInitStruct,
32
- EmberNetworkParameters,
33
- EmberPerDeviceDutyCycle,
34
- EmberPrivateKey283k1Data,
35
- EmberPrivateKeyData,
36
- EmberPublicKey283k1Data,
37
- EmberPublicKeyData,
38
- EmberRouteTableEntry,
39
- EmberRxPacketInfo,
40
- EmberSignature283k1Data,
41
- EmberSignatureData,
42
- EmberSmacData,
43
- EmberTokenData,
44
- EmberTokenInfo,
45
- EmberTokTypeStackZllData,
46
- EmberTokTypeStackZllSecurity,
47
- EmberZigbeeNetwork,
48
- EmberZllAddressAssignment,
49
- EmberZllDeviceInfoRecord,
50
- EmberZllInitialSecurityState,
51
- EmberZllNetwork,
52
- EmberZllSecurityAlgorithmData,
53
- SecManAPSKeyMetadata,
54
- SecManContext,
55
- SecManKey,
56
- SecManNetworkKeyInfo,
57
- } from "../types";
58
- import {highByte} from "../utils/math";
59
- import {
60
- EMBER_AES_HASH_BLOCK_SIZE,
61
- EMBER_CERTIFICATE_283K1_SIZE,
62
- EMBER_CERTIFICATE_SIZE,
63
- EMBER_ENCRYPTION_KEY_SIZE,
64
- EMBER_PRIVATE_KEY_283K1_SIZE,
65
- EMBER_PRIVATE_KEY_SIZE,
66
- EMBER_PUBLIC_KEY_283K1_SIZE,
67
- EMBER_PUBLIC_KEY_SIZE,
68
- EMBER_SIGNATURE_283K1_SIZE,
69
- EMBER_SIGNATURE_SIZE,
70
- EMBER_SMAC_SIZE,
71
- EXTENDED_PAN_ID_SIZE,
72
- EZSP_EXTENDED_FRAME_CONTROL_HB_INDEX,
73
- EZSP_EXTENDED_FRAME_CONTROL_LB_INDEX,
74
- EZSP_EXTENDED_FRAME_CONTROL_RESERVED_MASK,
75
- EZSP_EXTENDED_FRAME_FORMAT_VERSION,
76
- EZSP_EXTENDED_FRAME_FORMAT_VERSION_MASK,
77
- EZSP_EXTENDED_FRAME_ID_HB_INDEX,
78
- EZSP_EXTENDED_FRAME_ID_LB_INDEX,
79
- EZSP_EXTENDED_PARAMETERS_INDEX,
80
- EZSP_FRAME_CONTROL_INDEX,
81
- EZSP_FRAME_ID_INDEX,
82
- EZSP_PARAMETERS_INDEX,
83
- } from "./consts";
84
- import type {EzspFrameID} from "./enums";
85
-
86
- /**
87
- * Handle EmberStatus deprecation in v14+ for previous versions
88
- */
89
- const EMBER_TO_SL_STATUS_MAP: ReadonlyMap<number, SLStatus> = new Map([
90
- [0x02 /*BAD_ARGUMENT*/, SLStatus.INVALID_PARAMETER],
91
- [0x18 /*NO_BUFFERS*/, SLStatus.ALLOCATION_FAILED],
92
- [0x19 /*PACKET_HANDOFF_DROP_PACKET*/, SLStatus.ZIGBEE_PACKET_HANDOFF_DROPPED],
93
- [0x66 /*DELIVERY_FAILED*/, SLStatus.ZIGBEE_DELIVERY_FAILED],
94
- [0x70 /*INVALID_CALL*/, SLStatus.INVALID_STATE],
95
- [0x72 /*MAX_MESSAGE_LIMIT_REACHED*/, SLStatus.ZIGBEE_MAX_MESSAGE_LIMIT_REACHED],
96
- [0x74 /*MESSAGE_TOO_LONG*/, SLStatus.MESSAGE_TOO_LONG],
97
- [0x75 /*BINDING_IS_ACTIVE*/, SLStatus.ZIGBEE_BINDING_IS_ACTIVE],
98
- [0x76 /*ADDRESS_TABLE_ENTRY_IS_ACTIVE*/, SLStatus.ZIGBEE_ADDRESS_TABLE_ENTRY_IS_ACTIVE],
99
- [0x90 /*NETWORK_UP*/, SLStatus.NETWORK_UP],
100
- [0x91 /*NETWORK_DOWN*/, SLStatus.NETWORK_DOWN],
101
- [0x93 /*NOT_JOINED*/, SLStatus.NOT_JOINED],
102
- [0x95 /*INVALID_SECURITY_LEVEL*/, SLStatus.ZIGBEE_INVALID_SECURITY_LEVEL],
103
- [0x96 /*MOVE_FAILED*/, SLStatus.ZIGBEE_MOVE_FAILED],
104
- [0x99 /*NODE_ID_CHANGED*/, SLStatus.ZIGBEE_NODE_ID_CHANGED],
105
- [0x9a /*PAN_ID_CHANGED*/, SLStatus.ZIGBEE_PAN_ID_CHANGED],
106
- [0x9b /*CHANNEL_CHANGED*/, SLStatus.ZIGBEE_CHANNEL_CHANGED],
107
- [0x9c /*NETWORK_OPENED*/, SLStatus.ZIGBEE_NETWORK_OPENED],
108
- [0x9d /*NETWORK_CLOSED*/, SLStatus.ZIGBEE_NETWORK_CLOSED],
109
- [0xa1 /*NETWORK_BUSY*/, SLStatus.BUSY],
110
- [0xa4 /*BINDING_HAS_CHANGED*/, SLStatus.ZIGBEE_BINDING_HAS_CHANGED],
111
- [0xa5 /*INSUFFICIENT_RANDOM_DATA*/, SLStatus.ZIGBEE_INSUFFICIENT_RANDOM_DATA],
112
- [0xa6 /*APS_ENCRYPTION_ERROR*/, SLStatus.ZIGBEE_APS_ENCRYPTION_ERROR],
113
- [0xa9 /*SOURCE_ROUTE_FAILURE*/, SLStatus.ZIGBEE_SOURCE_ROUTE_FAILURE],
114
- [0xa8 /*SECURITY_STATE_NOT_SET*/, SLStatus.ZIGBEE_SECURITY_STATE_NOT_SET],
115
- [0xaa /*MANY_TO_ONE_ROUTE_FAILURE*/, SLStatus.ZIGBEE_MANY_TO_ONE_ROUTE_FAILURE],
116
- [0xac /*RECEIVED_KEY_IN_THE_CLEAR*/, SLStatus.ZIGBEE_RECEIVED_KEY_IN_THE_CLEAR],
117
- [0xad /*NO_NETWORK_KEY_RECEIVED*/, SLStatus.ZIGBEE_NO_NETWORK_KEY_RECEIVED],
118
- [0xae /*NO_LINK_KEY_RECEIVED*/, SLStatus.ZIGBEE_NO_LINK_KEY_RECEIVED],
119
- [0xaf /*PRECONFIGURED_KEY_REQUIRED*/, SLStatus.ZIGBEE_PRECONFIGURED_KEY_REQUIRED],
120
- [0xb0 /*STACK_AND_HARDWARE_MISMATCH*/, SLStatus.ZIGBEE_STACK_AND_HARDWARE_MISMATCH],
121
- [0xb5 /*LIBRARY_NOT_PRESENT*/, SLStatus.NOT_AVAILABLE],
122
- [0xb8 /*TOO_SOON_FOR_SWITCH_KEY*/, SLStatus.ZIGBEE_TOO_SOON_FOR_SWITCH_KEY],
123
- [0xb9 /*SIGNATURE_VERIFY_FAILURE*/, SLStatus.ZIGBEE_SIGNATURE_VERIFY_FAILURE],
124
- [0xbb /*KEY_NOT_AUTHORIZED*/, SLStatus.ZIGBEE_KEY_NOT_AUTHORIZED],
125
- [0xbc /*TRUST_CENTER_EUI_HAS_CHANGED*/, SLStatus.ZIGBEE_TRUST_CENTER_SWAP_EUI_HAS_CHANGED],
126
- [0xbe /*IEEE_ADDRESS_DISCOVERY_IN_PROGRESS*/, SLStatus.ZIGBEE_IEEE_ADDRESS_DISCOVERY_IN_PROGRESS],
127
- [0xbf /*TRUST_CENTER_SWAPPED_OUT_EUI_HAS_NOT_CHANGED*/, SLStatus.ZIGBEE_TRUST_CENTER_SWAP_EUI_HAS_NOT_CHANGED],
128
- ]);
129
-
130
- export class EzspBuffalo extends Buffalo {
131
- public getBufferLength(): number {
132
- return this.buffer.length;
133
- }
134
-
135
- /**
136
- * Set the byte at given position without affecting the internal position tracker.
137
- * @param position
138
- * @param value
139
- */
140
- public setCommandByte(position: number, value: number): void {
141
- this.buffer.writeUInt8(value, position);
142
- }
143
-
144
- /**
145
- * Get the byte at given position without affecting the internal position tracker.
146
- * @param position
147
- * @returns
148
- */
149
- public getCommandByte(position: number): number {
150
- return this.buffer.readUInt8(position);
151
- }
152
-
153
- /**
154
- * Get the byte at given position without affecting the internal position tracker.
155
- * @param position
156
- * @returns
157
- */
158
- public getResponseByte(position: number): number {
159
- return this.buffer.readUInt8(position);
160
- }
161
-
162
- public getExtFrameControl(): number {
163
- return (this.getResponseByte(EZSP_EXTENDED_FRAME_CONTROL_HB_INDEX) << 8) | this.getResponseByte(EZSP_EXTENDED_FRAME_CONTROL_LB_INDEX);
164
- }
165
-
166
- public getExtFrameId(): EzspFrameID {
167
- return (this.getResponseByte(EZSP_EXTENDED_FRAME_ID_HB_INDEX) << 8) | this.getResponseByte(EZSP_EXTENDED_FRAME_ID_LB_INDEX);
168
- }
169
-
170
- public getFrameId(): EzspFrameID {
171
- if (
172
- (this.getResponseByte(EZSP_EXTENDED_FRAME_CONTROL_HB_INDEX) & EZSP_EXTENDED_FRAME_FORMAT_VERSION_MASK) ===
173
- EZSP_EXTENDED_FRAME_FORMAT_VERSION
174
- ) {
175
- return this.getExtFrameId();
176
- }
177
-
178
- return this.getResponseByte(EZSP_FRAME_ID_INDEX) as EzspFrameID;
179
- }
180
-
181
- /**
182
- * Get the frame control, ID and params index according to format version.
183
- * Throws if frame control is unsupported (using reserved).
184
- * @returns Anything but SUCCESS should stop further processing.
185
- */
186
- public getResponseMetadata(): [status: EzspStatus, frameControl: number, frameId: EzspFrameID, parametersIndex: number] {
187
- let status: EzspStatus = EzspStatus.SUCCESS;
188
- let frameControl: number;
189
- let frameId: EzspFrameID;
190
- let parametersIndex: number;
191
-
192
- if (
193
- (this.getResponseByte(EZSP_EXTENDED_FRAME_CONTROL_HB_INDEX) & EZSP_EXTENDED_FRAME_FORMAT_VERSION_MASK) ===
194
- EZSP_EXTENDED_FRAME_FORMAT_VERSION
195
- ) {
196
- // use extended ezsp frame format
197
- frameControl = this.getExtFrameControl();
198
- frameId = this.getExtFrameId();
199
- parametersIndex = EZSP_EXTENDED_PARAMETERS_INDEX;
200
-
201
- if (highByte(frameControl) & EZSP_EXTENDED_FRAME_CONTROL_RESERVED_MASK) {
202
- // reject if unsupported frame
203
- status = EzspStatus.ERROR_UNSUPPORTED_CONTROL;
204
- }
205
- } else {
206
- // use legacy ezsp frame format
207
- frameControl = this.getResponseByte(EZSP_FRAME_CONTROL_INDEX);
208
- frameId = this.getResponseByte(EZSP_FRAME_ID_INDEX) as EzspFrameID;
209
- parametersIndex = EZSP_PARAMETERS_INDEX;
210
- }
211
-
212
- return [status, frameControl, frameId, parametersIndex];
213
- }
214
-
215
- /**
216
- * Get a copy of the rest of the buffer (from current position to end).
217
- * WARNING: Make sure the length is appropriate, if alloc'ed longer, it will return everything until the end.
218
- * @returns
219
- */
220
- public readRest(): Buffer {
221
- return Buffer.from(this.buffer.subarray(this.position));
222
- }
223
-
224
- /**
225
- * This is mostly used for payload/encryption stuff.
226
- * Copies the buffer to avoid memory referencing issues since Ezsp has a single buffer allocated.
227
- * @param length
228
- * @returns
229
- */
230
- protected readBufferCopy(length: number): Buffer {
231
- return Buffer.from(this.readBuffer(length));
232
- }
233
-
234
- /**
235
- * Write a uint8_t for payload length, followed by payload buffer (copied at post-length position).
236
- *
237
- * WARNING: `payload` must have a valid length (as in, not a Buffer allocated to longer length).
238
- * Should be passed with getWritten() in most cases.
239
- * @param payload
240
- */
241
- public writePayload(payload: Buffer): void {
242
- this.writeUInt8(payload.length);
243
-
244
- this.position += payload.copy(this.buffer, this.position);
245
- }
246
-
247
- /**
248
- * Read a uint8_t for payload length, followed by payload buffer (using post-length position).
249
- * @returns
250
- */
251
- public readPayload(): Buffer {
252
- const messageLength = this.readUInt8();
253
-
254
- return this.readBufferCopy(messageLength);
255
- }
256
-
257
- public writeEmberNetworkParameters(value: EmberNetworkParameters): void {
258
- this.writeListUInt8(value.extendedPanId);
259
- this.writeUInt16(value.panId);
260
- this.writeUInt8(value.radioTxPower);
261
- this.writeUInt8(value.radioChannel);
262
- this.writeUInt8(value.joinMethod);
263
- this.writeUInt16(value.nwkManagerId);
264
- this.writeUInt8(value.nwkUpdateId);
265
- this.writeUInt32(value.channels);
266
- }
267
-
268
- public readEmberNetworkParameters(): EmberNetworkParameters {
269
- const extendedPanId = this.readListUInt8(EXTENDED_PAN_ID_SIZE);
270
- const panId = this.readUInt16();
271
- const radioTxPower = this.readUInt8();
272
- const radioChannel = this.readUInt8();
273
- const joinMethod = this.readUInt8();
274
- const nwkManagerId = this.readUInt16();
275
- const nwkUpdateId = this.readUInt8();
276
- const channels = this.readUInt32();
277
-
278
- return {
279
- extendedPanId,
280
- panId,
281
- radioTxPower,
282
- radioChannel,
283
- joinMethod,
284
- nwkManagerId,
285
- nwkUpdateId,
286
- channels,
287
- };
288
- }
289
-
290
- public writeEmberMultiPhyRadioParameters(value: EmberMultiPhyRadioParameters): void {
291
- this.writeUInt8(value.radioTxPower);
292
- this.writeUInt8(value.radioPage);
293
- this.writeUInt8(value.radioChannel);
294
- }
295
-
296
- public readEmberMultiPhyRadioParameters(): EmberMultiPhyRadioParameters {
297
- const radioTxPower = this.readUInt8();
298
- const radioPage = this.readUInt8();
299
- const radioChannel = this.readUInt8();
300
-
301
- return {radioTxPower, radioPage, radioChannel};
302
- }
303
-
304
- public writeEmberApsFrame(value: EmberApsFrame): void {
305
- this.writeUInt16(value.profileId);
306
- this.writeUInt16(value.clusterId);
307
- this.writeUInt8(value.sourceEndpoint);
308
- this.writeUInt8(value.destinationEndpoint);
309
- this.writeUInt16(value.options);
310
- this.writeUInt16(value.groupId);
311
- this.writeUInt8(value.sequence);
312
- // this.writeUInt8(value.radius);// XXX: not in gecko_sdk, appended with separate param
313
- }
314
-
315
- public readEmberApsFrame(): EmberApsFrame {
316
- const profileId = this.readUInt16();
317
- const clusterId = this.readUInt16();
318
- const sourceEndpoint = this.readUInt8();
319
- const destinationEndpoint = this.readUInt8();
320
- const options = this.readUInt16();
321
- const groupId = this.readUInt16();
322
- const sequence = this.readUInt8();
323
- // const radius = this.readUInt8();// XXX: not in gecko_sdk, appended with separate param
324
-
325
- return {
326
- profileId,
327
- clusterId,
328
- sourceEndpoint,
329
- destinationEndpoint,
330
- options,
331
- groupId,
332
- sequence,
333
- // radius,
334
- };
335
- }
336
-
337
- public writeEmberBindingTableEntry(value: EmberBindingTableEntry): void {
338
- this.writeUInt8(value.type);
339
- this.writeUInt8(value.local);
340
- this.writeUInt16(value.clusterId);
341
- this.writeUInt8(value.remote);
342
- this.writeIeeeAddr(value.identifier);
343
- this.writeUInt8(value.networkIndex);
344
- }
345
-
346
- public readEmberBindingTableEntry(): EmberBindingTableEntry {
347
- const type = this.readUInt8();
348
- const local = this.readUInt8();
349
- const clusterId = this.readUInt16();
350
- const remote = this.readUInt8();
351
- const identifier = this.readIeeeAddr();
352
- const networkIndex = this.readUInt8();
353
-
354
- return {
355
- type,
356
- local,
357
- clusterId,
358
- remote,
359
- identifier,
360
- networkIndex,
361
- };
362
- }
363
-
364
- public writeEmberMulticastTableEntry(value: EmberMulticastTableEntry): void {
365
- this.writeUInt16(value.multicastId);
366
- this.writeUInt8(value.endpoint);
367
- this.writeUInt8(value.networkIndex);
368
- }
369
-
370
- public readEmberMulticastTableEntry(): EmberMulticastTableEntry {
371
- const multicastId = this.readUInt16();
372
- const endpoint = this.readUInt8();
373
- // XXX: not in gecko_sdk? as workaround check length for now since used at end in just one place
374
- const networkIndex = this.isMore() ? this.readUInt8() : 0x00;
375
-
376
- return {multicastId, endpoint, networkIndex};
377
- }
378
-
379
- public writeEmberBeaconClassificationParams(value: EmberBeaconClassificationParams): void {
380
- this.writeUInt8(value.minRssiForReceivingPkts);
381
- this.writeUInt16(value.beaconClassificationMask);
382
- }
383
-
384
- public readEmberBeaconClassificationParams(): EmberBeaconClassificationParams {
385
- const minRssiForReceivingPkts = this.readUInt8(); // Int8...
386
- const beaconClassificationMask = this.readUInt16();
387
-
388
- return {minRssiForReceivingPkts, beaconClassificationMask};
389
- }
390
-
391
- public writeEmberNeighborTableEntry(value: EmberNeighborTableEntry): void {
392
- this.writeUInt16(value.shortId);
393
- this.writeUInt8(value.averageLqi);
394
- this.writeUInt8(value.inCost);
395
- this.writeUInt8(value.outCost);
396
- this.writeUInt8(value.age);
397
- this.writeIeeeAddr(value.longId);
398
- }
399
-
400
- public readEmberNeighborTableEntry(): EmberNeighborTableEntry {
401
- const shortId = this.readUInt16();
402
- const averageLqi = this.readUInt8();
403
- const inCost = this.readUInt8();
404
- const outCost = this.readUInt8();
405
- const age = this.readUInt8();
406
- const longId = this.readIeeeAddr();
407
-
408
- return {
409
- shortId,
410
- averageLqi,
411
- inCost,
412
- outCost,
413
- age,
414
- longId,
415
- };
416
- }
417
-
418
- public writeEmberRouteTableEntry(value: EmberRouteTableEntry): void {
419
- this.writeUInt16(value.destination);
420
- this.writeUInt16(value.nextHop);
421
- this.writeUInt8(value.status);
422
- this.writeUInt8(value.age);
423
- this.writeUInt8(value.concentratorType);
424
- this.writeUInt8(value.routeRecordState);
425
- }
426
-
427
- public readEmberRouteTableEntry(): EmberRouteTableEntry {
428
- const destination = this.readUInt16();
429
- const nextHop = this.readUInt16();
430
- const status = this.readUInt8();
431
- const age = this.readUInt8();
432
- const concentratorType = this.readUInt8();
433
- const routeRecordState = this.readUInt8();
434
-
435
- return {
436
- destination,
437
- nextHop,
438
- status,
439
- age,
440
- concentratorType,
441
- routeRecordState,
442
- };
443
- }
444
-
445
- public writeEmberKeyData(value: EmberKeyData): void {
446
- this.writeBuffer(value.contents, EMBER_ENCRYPTION_KEY_SIZE);
447
- }
448
-
449
- public readEmberKeyData(): EmberKeyData {
450
- const contents = this.readBufferCopy(EMBER_ENCRYPTION_KEY_SIZE);
451
-
452
- return {contents};
453
- }
454
-
455
- public writeSecManKey(value: SecManKey): void {
456
- this.writeEmberKeyData(value);
457
- }
458
-
459
- public readSecManKey(): SecManKey {
460
- return this.readEmberKeyData();
461
- }
462
-
463
- public writeSecManContext(value: SecManContext): void {
464
- this.writeUInt8(value.coreKeyType);
465
- this.writeUInt8(value.keyIndex);
466
- this.writeUInt16(value.derivedType);
467
- this.writeIeeeAddr(value.eui64);
468
- this.writeUInt8(value.multiNetworkIndex);
469
- this.writeUInt8(value.flags);
470
- this.writeUInt32(value.psaKeyAlgPermission);
471
- }
472
-
473
- public readSecManContext(): SecManContext {
474
- const coreKeyType = this.readUInt8();
475
- const keyIndex = this.readUInt8();
476
- const derivedType = this.readUInt16();
477
- const eui64 = this.readIeeeAddr();
478
- const multiNetworkIndex = this.readUInt8();
479
- const flags = this.readUInt8();
480
- const psaKeyAlgPermission = this.readUInt32();
481
-
482
- return {
483
- coreKeyType,
484
- keyIndex,
485
- derivedType,
486
- eui64,
487
- multiNetworkIndex,
488
- flags,
489
- psaKeyAlgPermission,
490
- };
491
- }
492
-
493
- public writeSecManNetworkKeyInfo(value: SecManNetworkKeyInfo): void {
494
- this.writeUInt8(value.networkKeySet ? 1 : 0);
495
- this.writeUInt8(value.alternateNetworkKeySet ? 1 : 0);
496
- this.writeUInt8(value.networkKeySequenceNumber);
497
- this.writeUInt8(value.altNetworkKeySequenceNumber);
498
- this.writeUInt32(value.networkKeyFrameCounter);
499
- }
500
-
501
- public readSecManNetworkKeyInfo(): SecManNetworkKeyInfo {
502
- const networkKeySet = this.readUInt8() !== 0;
503
- const alternateNetworkKeySet = this.readUInt8() !== 0;
504
- const networkKeySequenceNumber = this.readUInt8();
505
- const altNetworkKeySequenceNumber = this.readUInt8();
506
- const networkKeyFrameCounter = this.readUInt32();
507
-
508
- return {
509
- networkKeySet: networkKeySet,
510
- alternateNetworkKeySet: alternateNetworkKeySet,
511
- networkKeySequenceNumber: networkKeySequenceNumber,
512
- altNetworkKeySequenceNumber: altNetworkKeySequenceNumber,
513
- networkKeyFrameCounter: networkKeyFrameCounter,
514
- };
515
- }
516
-
517
- public writeSecManAPSKeyMetadata(value: SecManAPSKeyMetadata): void {
518
- this.writeUInt16(value.bitmask);
519
- this.writeUInt32(value.outgoingFrameCounter);
520
- this.writeUInt32(value.incomingFrameCounter);
521
- this.writeUInt16(value.ttlInSeconds);
522
- }
523
-
524
- public readSecManAPSKeyMetadata(): SecManAPSKeyMetadata {
525
- const bitmask = this.readUInt16();
526
- const outgoingFrameCounter = this.readUInt32();
527
- const incomingFrameCounter = this.readUInt32();
528
- const ttlInSeconds = this.readUInt16();
529
-
530
- return {
531
- bitmask,
532
- outgoingFrameCounter,
533
- incomingFrameCounter,
534
- ttlInSeconds,
535
- };
536
- }
537
-
538
- public writeEmberInitialSecurityState(value: EmberInitialSecurityState): void {
539
- this.writeUInt16(value.bitmask);
540
- this.writeEmberKeyData(value.preconfiguredKey);
541
- this.writeEmberKeyData(value.networkKey);
542
- this.writeUInt8(value.networkKeySequenceNumber);
543
- this.writeIeeeAddr(value.preconfiguredTrustCenterEui64);
544
- }
545
-
546
- public readEmberInitialSecurityState(): EmberInitialSecurityState {
547
- const bitmask = this.readUInt16();
548
- const preconfiguredKey = this.readEmberKeyData();
549
- const networkKey = this.readEmberKeyData();
550
- const networkKeySequenceNumber = this.readUInt8();
551
- const preconfiguredTrustCenterEui64 = this.readIeeeAddr();
552
-
553
- return {
554
- bitmask,
555
- preconfiguredKey,
556
- networkKey,
557
- networkKeySequenceNumber,
558
- preconfiguredTrustCenterEui64,
559
- };
560
- }
561
-
562
- public writeEmberCurrentSecurityState(value: EmberCurrentSecurityState): void {
563
- this.writeUInt16(value.bitmask);
564
- this.writeIeeeAddr(value.trustCenterLongAddress);
565
- }
566
-
567
- public readEmberCurrentSecurityState(): EmberCurrentSecurityState {
568
- const bitmask = this.readUInt16();
569
- const trustCenterLongAddress = this.readIeeeAddr();
570
-
571
- return {bitmask, trustCenterLongAddress};
572
- }
573
-
574
- public writeEmberChildData(value: EmberChildData): void {
575
- this.writeIeeeAddr(value.eui64);
576
- this.writeUInt8(value.type);
577
- this.writeUInt16(value.id);
578
- this.writeUInt8(value.phy);
579
- this.writeUInt8(value.power);
580
- this.writeUInt8(value.timeout);
581
- this.writeUInt32(value.remainingTimeout);
582
- }
583
-
584
- public readEmberChildData(): EmberChildData {
585
- const eui64 = this.readIeeeAddr();
586
- const type = this.readUInt8();
587
- const id = this.readUInt16();
588
- const phy = this.readUInt8();
589
- const power = this.readUInt8();
590
- const timeout = this.readUInt8();
591
- const remainingTimeout = this.readUInt32();
592
-
593
- return {
594
- eui64,
595
- type,
596
- id,
597
- phy,
598
- power,
599
- timeout,
600
- remainingTimeout,
601
- };
602
- }
603
-
604
- public readEmberZigbeeNetwork(): EmberZigbeeNetwork {
605
- const channel = this.readUInt8();
606
- const panId = this.readUInt16();
607
- const extendedPanId = this.readListUInt8(EXTENDED_PAN_ID_SIZE);
608
- const allowingJoin = this.readUInt8() !== 0;
609
- const stackProfile = this.readUInt8();
610
- const nwkUpdateId = this.readUInt8();
611
-
612
- return {
613
- channel,
614
- panId,
615
- extendedPanId,
616
- allowingJoin,
617
- stackProfile,
618
- nwkUpdateId,
619
- };
620
- }
621
-
622
- public writeEmberZigbeeNetwork(value: EmberZigbeeNetwork): void {
623
- this.writeUInt8(value.channel);
624
- this.writeUInt16(value.panId);
625
- this.writeListUInt8(value.extendedPanId);
626
- this.writeUInt8(value.allowingJoin ? 1 : 0);
627
- this.writeUInt8(value.stackProfile);
628
- this.writeUInt8(value.nwkUpdateId);
629
- }
630
-
631
- public writeEmberCertificateData(value: EmberCertificateData): void {
632
- this.writeBuffer(value.contents, EMBER_CERTIFICATE_SIZE);
633
- }
634
-
635
- public readEmberCertificateData(): EmberCertificateData {
636
- const contents = this.readBufferCopy(EMBER_CERTIFICATE_SIZE);
637
-
638
- return {contents};
639
- }
640
-
641
- public writeEmberPublicKeyData(value: EmberPublicKeyData): void {
642
- this.writeBuffer(value.contents, EMBER_PUBLIC_KEY_SIZE);
643
- }
644
-
645
- public readEmberPublicKeyData(): EmberPublicKeyData {
646
- const contents = this.readBufferCopy(EMBER_PUBLIC_KEY_SIZE);
647
-
648
- return {contents};
649
- }
650
-
651
- public writeEmberPrivateKeyData(value: EmberPrivateKeyData): void {
652
- this.writeBuffer(value.contents, EMBER_PRIVATE_KEY_SIZE);
653
- }
654
-
655
- public readEmberPrivateKeyData(): EmberPrivateKeyData {
656
- const contents = this.readBufferCopy(EMBER_PRIVATE_KEY_SIZE);
657
-
658
- return {contents};
659
- }
660
-
661
- public writeEmberSmacData(value: EmberSmacData): void {
662
- this.writeBuffer(value.contents, EMBER_SMAC_SIZE);
663
- }
664
-
665
- public readEmberSmacData(): EmberSmacData {
666
- const contents = this.readBufferCopy(EMBER_SMAC_SIZE);
667
-
668
- return {contents};
669
- }
670
-
671
- public writeEmberSignatureData(value: EmberSignatureData): void {
672
- this.writeBuffer(value.contents, EMBER_SIGNATURE_SIZE);
673
- }
674
-
675
- public readEmberSignatureData(): EmberSignatureData {
676
- const contents = this.readBufferCopy(EMBER_SIGNATURE_SIZE);
677
-
678
- return {contents};
679
- }
680
-
681
- public writeEmberCertificate283k1Data(value: EmberCertificate283k1Data): void {
682
- this.writeBuffer(value.contents, EMBER_CERTIFICATE_283K1_SIZE);
683
- }
684
-
685
- public readEmberCertificate283k1Data(): EmberCertificate283k1Data {
686
- const contents = this.readBufferCopy(EMBER_CERTIFICATE_283K1_SIZE);
687
-
688
- return {contents};
689
- }
690
-
691
- public writeEmberPublicKey283k1Data(value: EmberPublicKey283k1Data): void {
692
- this.writeBuffer(value.contents, EMBER_PUBLIC_KEY_283K1_SIZE);
693
- }
694
-
695
- public readEmberPublicKey283k1Data(): EmberPublicKey283k1Data {
696
- const contents = this.readBufferCopy(EMBER_PUBLIC_KEY_283K1_SIZE);
697
-
698
- return {contents};
699
- }
700
-
701
- public writeEmberPrivateKey283k1Data(value: EmberPrivateKey283k1Data): void {
702
- this.writeBuffer(value.contents, EMBER_PRIVATE_KEY_283K1_SIZE);
703
- }
704
-
705
- public readEmberPrivateKey283k1Data(): EmberPrivateKey283k1Data {
706
- const contents = this.readBufferCopy(EMBER_PRIVATE_KEY_283K1_SIZE);
707
-
708
- return {contents};
709
- }
710
-
711
- public writeEmberSignature283k1Data(value: EmberSignature283k1Data): void {
712
- this.writeBuffer(value.contents, EMBER_SIGNATURE_283K1_SIZE);
713
- }
714
-
715
- public readEmberSignature283k1Data(): EmberSignature283k1Data {
716
- const contents = this.readBufferCopy(EMBER_SIGNATURE_283K1_SIZE);
717
-
718
- return {contents};
719
- }
720
-
721
- public writeEmberAesMmoHashContext(context: EmberAesMmoHashContext): void {
722
- this.writeBuffer(context.result, EMBER_AES_HASH_BLOCK_SIZE);
723
- this.writeUInt32(context.length);
724
- }
725
-
726
- public readEmberAesMmoHashContext(): EmberAesMmoHashContext {
727
- const result = this.readBufferCopy(EMBER_AES_HASH_BLOCK_SIZE);
728
- const length = this.readUInt32();
729
-
730
- return {result, length};
731
- }
732
-
733
- public writeEmberMessageDigest(value: EmberMessageDigest): void {
734
- this.writeBuffer(value.contents, EMBER_AES_HASH_BLOCK_SIZE);
735
- }
736
-
737
- public readEmberMessageDigest(): EmberMessageDigest {
738
- const contents = this.readBufferCopy(EMBER_AES_HASH_BLOCK_SIZE);
739
-
740
- return {contents};
741
- }
742
-
743
- public writeEmberNetworkInitStruct(networkInitStruct: EmberNetworkInitStruct): void {
744
- this.writeUInt16(networkInitStruct.bitmask);
745
- }
746
-
747
- public readEmberNetworkInitStruct(): EmberNetworkInitStruct {
748
- const bitmask = this.readUInt16();
749
-
750
- return {bitmask};
751
- }
752
-
753
- public writeEmberZllNetwork(network: EmberZllNetwork): void {
754
- this.writeEmberZigbeeNetwork(network.zigbeeNetwork);
755
- this.writeEmberZllSecurityAlgorithmData(network.securityAlgorithm);
756
- this.writeIeeeAddr(network.eui64);
757
- this.writeUInt16(network.nodeId);
758
- this.writeUInt16(network.state);
759
- this.writeUInt8(network.nodeType);
760
- this.writeUInt8(network.numberSubDevices);
761
- this.writeUInt8(network.totalGroupIdentifiers);
762
- this.writeUInt8(network.rssiCorrection);
763
- }
764
-
765
- public readEmberZllNetwork(): EmberZllNetwork {
766
- const zigbeeNetwork = this.readEmberZigbeeNetwork();
767
- const securityAlgorithm = this.readEmberZllSecurityAlgorithmData();
768
- const eui64 = this.readIeeeAddr();
769
- const nodeId = this.readUInt16();
770
- const state = this.readUInt16();
771
- const nodeType = this.readUInt8();
772
- const numberSubDevices = this.readUInt8();
773
- const totalGroupIdentifiers = this.readUInt8();
774
- const rssiCorrection = this.readUInt8();
775
-
776
- return {
777
- zigbeeNetwork,
778
- securityAlgorithm,
779
- eui64,
780
- nodeId,
781
- state,
782
- nodeType,
783
- numberSubDevices,
784
- totalGroupIdentifiers,
785
- rssiCorrection,
786
- };
787
- }
788
-
789
- public writeEmberZllSecurityAlgorithmData(data: EmberZllSecurityAlgorithmData): void {
790
- this.writeUInt32(data.transactionId);
791
- this.writeUInt32(data.responseId);
792
- this.writeUInt16(data.bitmask);
793
- }
794
-
795
- public readEmberZllSecurityAlgorithmData(): EmberZllSecurityAlgorithmData {
796
- const transactionId = this.readUInt32();
797
- const responseId = this.readUInt32();
798
- const bitmask = this.readUInt16();
799
-
800
- return {transactionId, responseId, bitmask};
801
- }
802
-
803
- public writeEmberZllInitialSecurityState(state: EmberZllInitialSecurityState): void {
804
- this.writeUInt32(state.bitmask);
805
- this.writeUInt8(state.keyIndex);
806
- this.writeEmberKeyData(state.encryptionKey);
807
- this.writeEmberKeyData(state.preconfiguredKey);
808
- }
809
-
810
- public writeEmberTokTypeStackZllData(data: EmberTokTypeStackZllData): void {
811
- this.writeUInt32(data.bitmask);
812
- this.writeUInt16(data.freeNodeIdMin);
813
- this.writeUInt16(data.freeNodeIdMax);
814
- this.writeUInt16(data.myGroupIdMin);
815
- this.writeUInt16(data.freeGroupIdMin);
816
- this.writeUInt16(data.freeGroupIdMax);
817
- this.writeUInt8(data.rssiCorrection);
818
- }
819
-
820
- public readEmberTokTypeStackZllData(): EmberTokTypeStackZllData {
821
- const bitmask = this.readUInt32();
822
- const freeNodeIdMin = this.readUInt16();
823
- const freeNodeIdMax = this.readUInt16();
824
- const myGroupIdMin = this.readUInt16();
825
- const freeGroupIdMin = this.readUInt16();
826
- const freeGroupIdMax = this.readUInt16();
827
- const rssiCorrection = this.readUInt8();
828
-
829
- return {
830
- bitmask,
831
- freeNodeIdMin,
832
- freeNodeIdMax,
833
- myGroupIdMin,
834
- freeGroupIdMin,
835
- freeGroupIdMax,
836
- rssiCorrection,
837
- };
838
- }
839
-
840
- public writeEmberTokTypeStackZllSecurity(security: EmberTokTypeStackZllSecurity): void {
841
- this.writeUInt32(security.bitmask);
842
- this.writeUInt8(security.keyIndex);
843
- this.writeBuffer(security.encryptionKey, EMBER_ENCRYPTION_KEY_SIZE);
844
- this.writeBuffer(security.preconfiguredKey, EMBER_ENCRYPTION_KEY_SIZE);
845
- }
846
-
847
- public readEmberTokTypeStackZllSecurity(): EmberTokTypeStackZllSecurity {
848
- const bitmask = this.readUInt32();
849
- const keyIndex = this.readUInt8();
850
- const encryptionKey = this.readBufferCopy(EMBER_ENCRYPTION_KEY_SIZE);
851
- const preconfiguredKey = this.readBufferCopy(EMBER_ENCRYPTION_KEY_SIZE);
852
-
853
- return {
854
- bitmask,
855
- keyIndex,
856
- encryptionKey,
857
- preconfiguredKey,
858
- };
859
- }
860
-
861
- public writeEmberGpAddress(value: EmberGpAddress): void {
862
- this.writeUInt8(value.applicationId);
863
-
864
- if (value.applicationId === EmberGpApplicationId.SOURCE_ID) {
865
- this.writeUInt32(value.sourceId);
866
- this.writeUInt32(value.sourceId); // filler
867
- } else if (value.applicationId === EmberGpApplicationId.IEEE_ADDRESS) {
868
- this.writeIeeeAddr(value.gpdIeeeAddress);
869
- }
870
-
871
- this.writeUInt8(value.endpoint);
872
- }
873
-
874
- public readEmberGpAddress(): EmberGpAddress {
875
- const applicationId = this.readUInt8();
876
-
877
- if (applicationId === EmberGpApplicationId.SOURCE_ID) {
878
- const sourceId = this.readUInt32();
879
- this.readUInt32(); // filler
880
- const endpoint = this.readUInt8();
881
-
882
- return {applicationId, sourceId, endpoint};
883
- }
884
-
885
- if (applicationId === EmberGpApplicationId.IEEE_ADDRESS) {
886
- const gpdIeeeAddress = this.readIeeeAddr();
887
- const endpoint = this.readUInt8();
888
-
889
- return {applicationId, gpdIeeeAddress, endpoint};
890
- }
891
-
892
- throw new Error(`Invalid GP applicationId ${applicationId}.`);
893
- }
894
-
895
- public readEmberGpSinkList(): EmberGpSinkListEntry[] {
896
- const list: EmberGpSinkListEntry[] = [];
897
-
898
- for (let i = 0; i < GP_SINK_LIST_ENTRIES; i++) {
899
- const type: EmberGpSinkType = this.readUInt8();
900
-
901
- switch (type) {
902
- case EmberGpSinkType.D_GROUPCAST:
903
- case EmberGpSinkType.GROUPCAST: {
904
- const alias = this.readUInt16();
905
- const groupID = this.readUInt16();
906
-
907
- // fillers
908
- this.readUInt16();
909
- this.readUInt16();
910
- this.readUInt16();
911
-
912
- list.push({
913
- type,
914
- groupcast: {
915
- alias,
916
- groupID,
917
- },
918
- });
919
- break;
920
- }
921
- // case EmberGpSinkType.FULL_UNICAST:
922
- // case EmberGpSinkType.LW_UNICAST:
923
- // case EmberGpSinkType.UNUSED:
924
- default: {
925
- const sinkNodeId = this.readUInt16();
926
- const sinkEUI = this.readIeeeAddr();
927
-
928
- list.push({
929
- type,
930
- unicast: {
931
- sinkNodeId,
932
- sinkEUI,
933
- },
934
- });
935
- break;
936
- }
937
- }
938
- }
939
-
940
- return list;
941
- }
942
-
943
- public writeEmberGpSinkList(value: EmberGpSinkListEntry[]): void {
944
- for (let i = 0; i < GP_SINK_LIST_ENTRIES; i++) {
945
- const entry = value[i];
946
-
947
- this.writeUInt8(entry.type);
948
-
949
- switch (entry.type) {
950
- case EmberGpSinkType.D_GROUPCAST:
951
- case EmberGpSinkType.GROUPCAST: {
952
- this.writeUInt16(entry.groupcast.alias);
953
- this.writeUInt16(entry.groupcast.groupID);
954
- //fillers
955
- this.writeUInt16(entry.groupcast.alias);
956
- this.writeUInt16(entry.groupcast.groupID);
957
- this.writeUInt16(entry.groupcast.alias);
958
- break;
959
- }
960
-
961
- // case EmberGpSinkType.FULL_UNICAST:
962
- // case EmberGpSinkType.LW_UNICAST:
963
- // case EmberGpSinkType.UNUSED:
964
- default: {
965
- this.writeUInt16(entry.unicast.sinkNodeId);
966
- this.writeIeeeAddr(entry.unicast.sinkEUI);
967
-
968
- break;
969
- }
970
- }
971
- }
972
- }
973
-
974
- public readEmberGpProxyTableEntry(): EmberGpProxyTableEntry {
975
- const status = this.readUInt8();
976
- const options = this.readUInt32();
977
- const gpd = this.readEmberGpAddress();
978
- const assignedAlias = this.readUInt16();
979
- const securityOptions = this.readUInt8();
980
- const gpdSecurityFrameCounter = this.readUInt32();
981
- const gpdKey = this.readEmberKeyData();
982
- const sinkList = this.readEmberGpSinkList();
983
- const groupcastRadius = this.readUInt8();
984
- const searchCounter = this.readUInt8();
985
-
986
- return {
987
- status,
988
- options,
989
- gpd,
990
- assignedAlias,
991
- securityOptions,
992
- gpdSecurityFrameCounter,
993
- gpdKey,
994
- sinkList,
995
- groupcastRadius,
996
- searchCounter,
997
- };
998
- }
999
-
1000
- public writeEmberGpProxyTableEntry(value: EmberGpProxyTableEntry): void {
1001
- this.writeUInt8(value.status);
1002
- this.writeUInt32(value.options);
1003
- this.writeEmberGpAddress(value.gpd);
1004
- this.writeUInt16(value.assignedAlias);
1005
- this.writeUInt8(value.securityOptions);
1006
- this.writeUInt32(value.gpdSecurityFrameCounter);
1007
- this.writeEmberKeyData(value.gpdKey);
1008
- this.writeEmberGpSinkList(value.sinkList);
1009
- this.writeUInt8(value.groupcastRadius);
1010
- this.writeUInt8(value.searchCounter);
1011
- }
1012
-
1013
- public readEmberGpSinkTableEntry(): EmberGpSinkTableEntry {
1014
- const status = this.readUInt8();
1015
- const options = this.readUInt16();
1016
- const gpd = this.readEmberGpAddress();
1017
- const deviceId = this.readUInt8();
1018
- const sinkList = this.readEmberGpSinkList();
1019
- const assignedAlias = this.readUInt16();
1020
- const groupcastRadius = this.readUInt8();
1021
- const securityOptions = this.readUInt8();
1022
- const gpdSecurityFrameCounter = this.readUInt32();
1023
- const gpdKey = this.readEmberKeyData();
1024
-
1025
- return {
1026
- status,
1027
- options,
1028
- gpd,
1029
- deviceId,
1030
- sinkList,
1031
- assignedAlias,
1032
- groupcastRadius,
1033
- securityOptions,
1034
- gpdSecurityFrameCounter,
1035
- gpdKey,
1036
- };
1037
- }
1038
-
1039
- public writeEmberGpSinkTableEntry(value: EmberGpSinkTableEntry): void {
1040
- this.writeUInt8(value.status);
1041
- this.writeUInt16(value.options);
1042
- this.writeEmberGpAddress(value.gpd);
1043
- this.writeUInt8(value.deviceId);
1044
- this.writeEmberGpSinkList(value.sinkList);
1045
- this.writeUInt16(value.assignedAlias);
1046
- this.writeUInt8(value.groupcastRadius);
1047
- this.writeUInt8(value.securityOptions);
1048
- this.writeUInt32(value.gpdSecurityFrameCounter);
1049
- this.writeEmberKeyData(value.gpdKey);
1050
- }
1051
-
1052
- public writeEmberDutyCycleLimits(limits: EmberDutyCycleLimits): void {
1053
- this.writeUInt16(limits.limitThresh);
1054
- this.writeUInt16(limits.critThresh);
1055
- this.writeUInt16(limits.suspLimit);
1056
- }
1057
-
1058
- public readEmberDutyCycleLimits(): EmberDutyCycleLimits {
1059
- const limitThresh = this.readUInt16();
1060
- const critThresh = this.readUInt16();
1061
- const suspLimit = this.readUInt16();
1062
-
1063
- return {
1064
- limitThresh,
1065
- critThresh,
1066
- suspLimit,
1067
- };
1068
- }
1069
-
1070
- public writeEmberPerDeviceDutyCycle(maxDevices: number, arrayOfDeviceDutyCycles: EmberPerDeviceDutyCycle[]): void {
1071
- this.writeUInt16(maxDevices);
1072
-
1073
- for (let i = 0; i < maxDevices; i++) {
1074
- this.writeUInt16(arrayOfDeviceDutyCycles[i].nodeId);
1075
- this.writeUInt16(arrayOfDeviceDutyCycles[i].dutyCycleConsumed);
1076
- }
1077
- }
1078
-
1079
- public readEmberPerDeviceDutyCycle(): EmberPerDeviceDutyCycle[] {
1080
- const maxDevices = this.readUInt8();
1081
- const arrayOfDeviceDutyCycles: EmberPerDeviceDutyCycle[] = [];
1082
-
1083
- for (let i = 0; i < maxDevices; i++) {
1084
- const nodeId = this.readUInt16();
1085
- const dutyCycleConsumed = this.readUInt16();
1086
-
1087
- arrayOfDeviceDutyCycles.push({nodeId, dutyCycleConsumed});
1088
- }
1089
-
1090
- return arrayOfDeviceDutyCycles;
1091
- }
1092
-
1093
- public readEmberZllDeviceInfoRecord(): EmberZllDeviceInfoRecord {
1094
- const ieeeAddress = this.readIeeeAddr();
1095
- const endpointId = this.readUInt8();
1096
- const profileId = this.readUInt16();
1097
- const deviceId = this.readUInt16();
1098
- const version = this.readUInt8();
1099
- const groupIdCount = this.readUInt8();
1100
-
1101
- return {
1102
- ieeeAddress,
1103
- endpointId,
1104
- profileId,
1105
- deviceId,
1106
- version,
1107
- groupIdCount,
1108
- };
1109
- }
1110
-
1111
- public readEmberZllInitialSecurityState(): EmberZllInitialSecurityState {
1112
- const bitmask = this.readUInt32();
1113
- const keyIndex = this.readUInt8();
1114
- const encryptionKey = this.readEmberKeyData();
1115
- const preconfiguredKey = this.readEmberKeyData();
1116
-
1117
- return {
1118
- bitmask,
1119
- keyIndex,
1120
- encryptionKey,
1121
- preconfiguredKey,
1122
- };
1123
- }
1124
-
1125
- public readEmberZllAddressAssignment(): EmberZllAddressAssignment {
1126
- const nodeId = this.readUInt16();
1127
- const freeNodeIdMin = this.readUInt16();
1128
- const freeNodeIdMax = this.readUInt16();
1129
- const groupIdMin = this.readUInt16();
1130
- const groupIdMax = this.readUInt16();
1131
- const freeGroupIdMin = this.readUInt16();
1132
- const freeGroupIdMax = this.readUInt16();
1133
-
1134
- return {
1135
- nodeId,
1136
- freeNodeIdMin,
1137
- freeNodeIdMax,
1138
- groupIdMin,
1139
- groupIdMax,
1140
- freeGroupIdMin,
1141
- freeGroupIdMax,
1142
- };
1143
- }
1144
-
1145
- public writeEmberBeaconIterator(value: EmberBeaconIterator): void {
1146
- this.writeUInt8(value.beacon.channel);
1147
- this.writeUInt8(value.beacon.lqi);
1148
- this.writeUInt8(value.beacon.rssi);
1149
- this.writeUInt8(value.beacon.depth);
1150
- this.writeUInt8(value.beacon.nwkUpdateId);
1151
- this.writeUInt8(value.beacon.power);
1152
- this.writeUInt8(value.beacon.parentPriority);
1153
- this.writeUInt8(value.beacon.enhanced ? 1 : 0);
1154
- this.writeUInt8(value.beacon.permitJoin ? 1 : 0);
1155
- this.writeUInt8(value.beacon.hasCapacity ? 1 : 0);
1156
- this.writeUInt16(value.beacon.panId);
1157
- this.writeUInt16(value.beacon.sender);
1158
- this.writeListUInt8(value.beacon.extendedPanId);
1159
- this.writeUInt8(value.index);
1160
- }
1161
-
1162
- public readEmberBeaconIterator(): EmberBeaconIterator {
1163
- const channel = this.readUInt8();
1164
- const lqi = this.readUInt8();
1165
- const rssi = this.readUInt8();
1166
- const depth = this.readUInt8();
1167
- const nwkUpdateId = this.readUInt8();
1168
- const power = this.readUInt8();
1169
- const parentPriority = this.readUInt8();
1170
- const enhanced = this.readUInt8() !== 0;
1171
- const permitJoin = this.readUInt8() !== 0;
1172
- const hasCapacity = this.readUInt8() !== 0;
1173
- const panId = this.readUInt16();
1174
- const sender = this.readUInt16();
1175
- const extendedPanId = this.readListUInt8(EXTENDED_PAN_ID_SIZE);
1176
- const index = this.readUInt8();
1177
-
1178
- return {
1179
- beacon: {
1180
- channel,
1181
- lqi,
1182
- rssi,
1183
- depth,
1184
- nwkUpdateId,
1185
- power,
1186
- parentPriority,
1187
- enhanced,
1188
- permitJoin,
1189
- hasCapacity,
1190
- panId,
1191
- sender,
1192
- extendedPanId,
1193
- supportedKeyNegotiationMethods: 0,
1194
- extendedBeacon: false,
1195
- tcConnectivity: true,
1196
- longUptime: true,
1197
- preferParent: true,
1198
- macDataPollKeepalive: true,
1199
- endDeviceKeepalive: true,
1200
- },
1201
- index,
1202
- };
1203
- }
1204
-
1205
- public writeEmberBeaconData(value: EmberBeaconData): void {
1206
- this.writeUInt8(value.channel);
1207
- this.writeUInt8(value.lqi);
1208
- this.writeUInt8(value.rssi);
1209
- this.writeUInt8(value.depth);
1210
- this.writeUInt8(value.nwkUpdateId);
1211
- this.writeUInt8(value.power);
1212
- this.writeUInt8(value.parentPriority);
1213
- this.writeUInt8(value.enhanced ? 1 : 0);
1214
- this.writeUInt8(value.permitJoin ? 1 : 0);
1215
- this.writeUInt8(value.hasCapacity ? 1 : 0);
1216
- this.writeUInt16(value.panId);
1217
- this.writeUInt16(value.sender);
1218
- this.writeListUInt8(value.extendedPanId);
1219
- }
1220
-
1221
- public readEmberBeaconData(): EmberBeaconData {
1222
- const channel = this.readUInt8();
1223
- const lqi = this.readUInt8();
1224
- const rssi = this.readUInt8();
1225
- const depth = this.readUInt8();
1226
- const nwkUpdateId = this.readUInt8();
1227
- const power = this.readUInt8();
1228
- const parentPriority = this.readUInt8();
1229
- const enhanced = this.readUInt8() !== 0;
1230
- const permitJoin = this.readUInt8() !== 0;
1231
- const hasCapacity = this.readUInt8() !== 0;
1232
- const panId = this.readUInt16();
1233
- const sender = this.readUInt16();
1234
- const extendedPanId = this.readListUInt8(EXTENDED_PAN_ID_SIZE);
1235
-
1236
- return {
1237
- channel,
1238
- lqi,
1239
- rssi,
1240
- depth,
1241
- nwkUpdateId,
1242
- power,
1243
- parentPriority,
1244
- enhanced,
1245
- permitJoin,
1246
- hasCapacity,
1247
- panId,
1248
- sender,
1249
- extendedPanId,
1250
- supportedKeyNegotiationMethods: 0,
1251
- extendedBeacon: false,
1252
- tcConnectivity: true,
1253
- longUptime: true,
1254
- preferParent: true,
1255
- macDataPollKeepalive: true,
1256
- endDeviceKeepalive: true,
1257
- };
1258
- }
1259
-
1260
- public writeEmberTokenData(tokenData: EmberTokenData): void {
1261
- this.writeUInt32(tokenData.size);
1262
- this.writeBuffer(tokenData.data, tokenData.size);
1263
- }
1264
-
1265
- public readEmberTokenData(): EmberTokenData {
1266
- const size = this.readUInt32();
1267
- const data = this.readBufferCopy(size);
1268
-
1269
- return {size, data};
1270
- }
1271
-
1272
- public readEmberTokenInfo(): EmberTokenInfo {
1273
- const nvm3Key = this.readUInt32();
1274
- const isCnt = this.readUInt8() !== 0;
1275
- const isIdx = this.readUInt8() !== 0;
1276
- const size = this.readUInt8();
1277
- const arraySize = this.readUInt8();
1278
-
1279
- return {
1280
- nvm3Key,
1281
- isCnt,
1282
- isIdx,
1283
- size,
1284
- arraySize,
1285
- };
1286
- }
1287
-
1288
- public writeEmberTokenInfo(tokenInfo: EmberTokenInfo): void {
1289
- this.writeUInt32(tokenInfo.nvm3Key);
1290
- this.writeUInt8(tokenInfo.isCnt ? 1 : 0);
1291
- this.writeUInt8(tokenInfo.isIdx ? 1 : 0);
1292
- this.writeUInt8(tokenInfo.size);
1293
- this.writeUInt8(tokenInfo.arraySize);
1294
- }
1295
-
1296
- /**
1297
- * EZSP switched to using SLStatus for command returns from version 14.
1298
- * @param version EZSP protocol version in use
1299
- * @param mapFromEmber If true, map from EmberStatus, otherwise map from EzspStatus
1300
- * @returns EzspStatus, EmberStatus or SLStatus as SLStatus
1301
- */
1302
- public readStatus(version: number, mapFromEmber = true): SLStatus {
1303
- if (version < 0x0e) {
1304
- const status = this.readUInt8();
1305
-
1306
- // skip lookup if SUCCESS (always zero)
1307
- if (status === SLStatus.OK) {
1308
- return status;
1309
- }
1310
-
1311
- if (mapFromEmber) {
1312
- // use mapped value, or pass as-is if none found
1313
- return EMBER_TO_SL_STATUS_MAP.get(status) ?? status;
1314
- }
1315
-
1316
- // EzspStatus mapping to SLStatus is always same code
1317
- return SLStatus.ZIGBEE_EZSP_ERROR;
1318
- }
1319
-
1320
- return this.readUInt32();
1321
- }
1322
-
1323
- public readEmberEndpointDescription(): EmberEndpointDescription {
1324
- const profileId = this.readUInt16();
1325
- const deviceId = this.readUInt16();
1326
- const deviceVersion = this.readUInt8();
1327
- const inputClusterCount = this.readUInt8();
1328
- const outputClusterCount = this.readUInt8();
1329
-
1330
- return {
1331
- profileId,
1332
- deviceId,
1333
- deviceVersion,
1334
- inputClusterCount,
1335
- outputClusterCount,
1336
- };
1337
- }
1338
-
1339
- /** @deprecated removed in EZSP v16 in favor of @see readEmber802154RadioPriorities */
1340
- public readEmberMultiprotocolPriorities(): EmberMultiprotocolPriorities {
1341
- const backgroundRx = this.readUInt8();
1342
- const tx = this.readUInt8();
1343
- const activeRx = this.readUInt8();
1344
-
1345
- return {backgroundRx, tx, activeRx};
1346
- }
1347
-
1348
- /** @deprecated removed in EZSP v16 in favor of @see writeEmber802154RadioPriorities */
1349
- public writeEmberMultiprotocolPriorities(priorities: EmberMultiprotocolPriorities): void {
1350
- this.writeUInt8(priorities.backgroundRx);
1351
- this.writeUInt8(priorities.tx);
1352
- this.writeUInt8(priorities.activeRx);
1353
- }
1354
-
1355
- public readEmber802154RadioPriorities(): Ember802154RadioPriorities {
1356
- const backgroundRx = this.readUInt8();
1357
- const minTxPriority = this.readUInt8();
1358
- const txStep = this.readUInt8();
1359
- const maxTxPriority = this.readUInt8();
1360
- const activeRx = this.readUInt8();
1361
-
1362
- return {backgroundRx, minTxPriority, txStep, maxTxPriority, activeRx};
1363
- }
1364
-
1365
- public writeEmber802154RadioPriorities(priorities: Ember802154RadioPriorities): void {
1366
- this.writeUInt8(priorities.backgroundRx);
1367
- this.writeUInt8(priorities.minTxPriority);
1368
- this.writeUInt8(priorities.txStep);
1369
- this.writeUInt8(priorities.maxTxPriority);
1370
- this.writeUInt8(priorities.activeRx);
1371
- }
1372
-
1373
- public readEmberRxPacketInfo(): EmberRxPacketInfo {
1374
- const senderShortId = this.readUInt16();
1375
- const senderLongId = this.readIeeeAddr();
1376
- const bindingIndex = this.readUInt8();
1377
- const addressIndex = this.readUInt8();
1378
- const lastHopLqi = this.readUInt8();
1379
- const lastHopRssi = this.readInt8(); // SDK: (int8_t)fetchInt8u();
1380
- const lastHopTimestamp = this.readUInt32();
1381
-
1382
- return {
1383
- senderShortId,
1384
- senderLongId,
1385
- bindingIndex,
1386
- addressIndex,
1387
- lastHopLqi,
1388
- lastHopRssi,
1389
- lastHopTimestamp,
1390
- };
1391
- }
1392
- }