@nordicsemiconductor/pc-nrfconnect-shared 60.0.0-pre1 → 60.0.0-pre2

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 (232) hide show
  1. package/dist/bootstrap.css +8951 -0
  2. package/dist/index.css +1451 -0
  3. package/dist/index.js +122119 -0
  4. package/{src/Logo/nordic-logo-blue-icon-only.png → dist/nordic-logo-blue-icon-only-H7BABN6D.png} +0 -0
  5. package/{src/Logo/nordic-logo-gray-icon-only.png → dist/nordic-logo-gray-icon-only-GATOTR3L.png} +0 -0
  6. package/package.json +12 -3
  7. package/typings/generated/src/Device/deviceInfo/deviceInfo.d.ts +1 -2
  8. package/.github/ISSUE_TEMPLATE/custom.md +0 -10
  9. package/.husky/pre-push +0 -3
  10. package/.renovaterc.json +0 -10
  11. package/Changelog.md +0 -2973
  12. package/azure-pipelines.yml +0 -34
  13. package/config/eslintrc.js +0 -190
  14. package/config/jest.config.js +0 -41
  15. package/config/prettier.config.js +0 -13
  16. package/config/tsconfig.json +0 -15
  17. package/fw/bootloader/graviton_bootloader_v1.0.1-[nRF5_SDK_15.0.1-1.alpha_f76d012].zip +0 -0
  18. package/jest.config.js +0 -7
  19. package/main/index.ts +0 -32
  20. package/mocks/deviceLibMock.ts +0 -21
  21. package/mocks/electronMock.ts +0 -15
  22. package/mocks/electronStoreMock.ts +0 -19
  23. package/mocks/emptyMock.ts +0 -7
  24. package/mocks/fileMock.ts +0 -13
  25. package/mocks/gaMock.ts +0 -9
  26. package/mocks/mockTests.test.ts +0 -15
  27. package/mocks/packageJsonMock.ts +0 -10
  28. package/mocks/remoteMock.ts +0 -17
  29. package/scripts/esbuild-bootstrap.js +0 -15
  30. package/scripts/esbuild-renderer.js +0 -131
  31. package/scripts/installHusky.ts +0 -17
  32. package/scripts/prepare-shared-release.ts +0 -122
  33. package/scripts/release-shared.test.ts +0 -132
  34. package/scripts/release-shared.ts +0 -207
  35. package/src/About/About.tsx +0 -25
  36. package/src/About/AboutButton.tsx +0 -28
  37. package/src/About/ApplicationCard.tsx +0 -83
  38. package/src/About/DeviceCard.tsx +0 -74
  39. package/src/About/DocumentationCard.tsx +0 -18
  40. package/src/About/DocumentationSection.tsx +0 -24
  41. package/src/About/Section.tsx +0 -21
  42. package/src/About/ShortcutButton.tsx +0 -41
  43. package/src/About/SupportCard.tsx +0 -97
  44. package/src/About/about.scss +0 -40
  45. package/src/About/documentationSlice.ts +0 -41
  46. package/src/About/section.scss +0 -15
  47. package/src/About/shortcutSlice.ts +0 -52
  48. package/src/Alert/Alert.module.scss +0 -29
  49. package/src/Alert/Alert.tsx +0 -37
  50. package/src/App/App.test.tsx +0 -47
  51. package/src/App/App.tsx +0 -227
  52. package/src/App/ConnectedToStore.tsx +0 -19
  53. package/src/App/VisibilityBar.tsx +0 -103
  54. package/src/App/app.scss +0 -83
  55. package/src/App/appLayout.ts +0 -95
  56. package/src/App/shared.scss +0 -49
  57. package/src/App/visibility-bar.scss +0 -55
  58. package/src/Button/Button.tsx +0 -66
  59. package/src/Button/button.module.scss +0 -154
  60. package/src/Card/Card.tsx +0 -26
  61. package/src/Card/card.module.scss +0 -28
  62. package/src/Device/BrokenDeviceDialog/BrokenDeviceDialog.tsx +0 -58
  63. package/src/Device/BrokenDeviceDialog/broken-device-dialog.scss +0 -18
  64. package/src/Device/BrokenDeviceDialog/brokenDeviceDialogSlice.tsx +0 -48
  65. package/src/Device/DeviceSelector/BasicDeviceInfo.tsx +0 -115
  66. package/src/Device/DeviceSelector/DeviceIcon.tsx +0 -27
  67. package/src/Device/DeviceSelector/DeviceList/AnimatedList.tsx +0 -62
  68. package/src/Device/DeviceSelector/DeviceList/BrokenDevice.tsx +0 -34
  69. package/src/Device/DeviceSelector/DeviceList/Device.tsx +0 -84
  70. package/src/Device/DeviceSelector/DeviceList/DeviceList.tsx +0 -113
  71. package/src/Device/DeviceSelector/DeviceList/EditDeviceButtons.tsx +0 -28
  72. package/src/Device/DeviceSelector/DeviceList/MoreDeviceInfo.tsx +0 -65
  73. package/src/Device/DeviceSelector/DeviceList/RenameDevice.tsx +0 -22
  74. package/src/Device/DeviceSelector/DeviceList/broken-device.scss +0 -32
  75. package/src/Device/DeviceSelector/DeviceList/device-list.scss +0 -64
  76. package/src/Device/DeviceSelector/DeviceList/device.scss +0 -28
  77. package/src/Device/DeviceSelector/DeviceList/edit-device-buttons.scss +0 -31
  78. package/src/Device/DeviceSelector/DeviceList/more-device-info.scss +0 -33
  79. package/src/Device/DeviceSelector/DeviceList/rename-device.scss +0 -13
  80. package/src/Device/DeviceSelector/DeviceSelector.test.tsx +0 -342
  81. package/src/Device/DeviceSelector/DeviceSelector.tsx +0 -173
  82. package/src/Device/DeviceSelector/Favorite.tsx +0 -49
  83. package/src/Device/DeviceSelector/SelectDevice.tsx +0 -36
  84. package/src/Device/DeviceSelector/SelectedDevice.tsx +0 -65
  85. package/src/Device/DeviceSelector/arrow-down.svg +0 -1
  86. package/src/Device/DeviceSelector/basic-device-info.scss +0 -62
  87. package/src/Device/DeviceSelector/device-icon.scss +0 -27
  88. package/src/Device/DeviceSelector/favorite.scss +0 -17
  89. package/src/Device/DeviceSelector/select-device.scss +0 -38
  90. package/src/Device/DeviceSelector/selected-device.scss +0 -57
  91. package/src/Device/DeviceSetup/DeviceSetupView.tsx +0 -102
  92. package/src/Device/deviceAutoSelectSlice.ts +0 -144
  93. package/src/Device/deviceInfo/deviceInfo.ts +0 -254
  94. package/src/Device/deviceInfo/nRF51-Series-logo.svg +0 -1
  95. package/src/Device/deviceInfo/nRF52-Series-logo.svg +0 -1
  96. package/src/Device/deviceInfo/nRF53-Series-logo.svg +0 -1
  97. package/src/Device/deviceInfo/nRF70-Series_no-background_RGB.svg +0 -36
  98. package/src/Device/deviceInfo/nRF91-Series-logo.svg +0 -1
  99. package/src/Device/deviceInfo/ppk-logo.svg +0 -1
  100. package/src/Device/deviceInfo/unknown-logo.svg +0 -30
  101. package/src/Device/deviceInfo/unknown-nordic-logo.svg +0 -25
  102. package/src/Device/deviceLibWrapper.test.ts +0 -97
  103. package/src/Device/deviceLibWrapper.ts +0 -133
  104. package/src/Device/deviceLister.test.ts +0 -89
  105. package/src/Device/deviceLister.ts +0 -396
  106. package/src/Device/deviceSetup.ts +0 -264
  107. package/src/Device/deviceSetupSlice.ts +0 -94
  108. package/src/Device/deviceSlice.ts +0 -248
  109. package/src/Device/dfu-cc.ts +0 -162
  110. package/src/Device/initPacket.ts +0 -402
  111. package/src/Device/jprogOperations.ts +0 -206
  112. package/src/Device/sdfuOperations.ts +0 -601
  113. package/src/Dialog/Dialog.test.tsx +0 -134
  114. package/src/Dialog/Dialog.tsx +0 -236
  115. package/src/Dialog/dialog.scss +0 -60
  116. package/src/Dropdown/Dropdown.module.scss +0 -83
  117. package/src/Dropdown/Dropdown.test.tsx +0 -62
  118. package/src/Dropdown/Dropdown.tsx +0 -106
  119. package/src/ErrorBoundary/ErrorBoundary.test.tsx +0 -105
  120. package/src/ErrorBoundary/ErrorBoundary.tsx +0 -186
  121. package/src/ErrorBoundary/bug.svg +0 -1
  122. package/src/ErrorBoundary/error-boundary.scss +0 -102
  123. package/src/ErrorDialog/ErrorDialog.test.tsx +0 -70
  124. package/src/ErrorDialog/ErrorDialog.tsx +0 -94
  125. package/src/ErrorDialog/error.scss +0 -14
  126. package/src/ErrorDialog/errorDialogSlice.test.ts +0 -64
  127. package/src/ErrorDialog/errorDialogSlice.ts +0 -80
  128. package/src/FactoryReset/FactoryResetButton.test.tsx +0 -46
  129. package/src/FactoryReset/FactoryResetButton.tsx +0 -81
  130. package/src/InlineInput/InlineInput.tsx +0 -170
  131. package/src/InlineInput/NumberInlineInput.tsx +0 -107
  132. package/src/InlineInput/inline-input.scss +0 -38
  133. package/src/InlineInput/number-inline-input.scss +0 -15
  134. package/src/Log/LogEntry.tsx +0 -62
  135. package/src/Log/LogViewer.tsx +0 -54
  136. package/src/Log/log-entry.scss +0 -30
  137. package/src/Log/log-viewer.scss +0 -24
  138. package/src/Log/logSlice.ts +0 -73
  139. package/src/Log/syncLogToStore.ts +0 -36
  140. package/src/Logo/Logo.tsx +0 -48
  141. package/src/Logo/logo.scss +0 -11
  142. package/src/Main/Main.tsx +0 -13
  143. package/src/Main/main.scss +0 -13
  144. package/src/MasonryLayout/MasonryLayout.tsx +0 -234
  145. package/src/MasonryLayout/masonryLayout.module.scss +0 -46
  146. package/src/NavBar/NavBar.tsx +0 -22
  147. package/src/NavBar/NavMenu.test.tsx +0 -41
  148. package/src/NavBar/NavMenu.tsx +0 -53
  149. package/src/NavBar/NavMenuItem.tsx +0 -41
  150. package/src/NavBar/nav-bar.scss +0 -26
  151. package/src/NavBar/nav-menu-item.scss +0 -34
  152. package/src/OpenApp/openApp.ts +0 -18
  153. package/src/Panes/FeedbackPane.tsx +0 -149
  154. package/src/PseudoButton/PseudoButton.tsx +0 -56
  155. package/src/PseudoButton/pseudo-button.scss +0 -11
  156. package/src/SerialPort/ConflictingSettingsDialog.tsx +0 -242
  157. package/src/SerialPort/SerialPort.test.ts +0 -54
  158. package/src/SerialPort/SerialPort.ts +0 -202
  159. package/src/Shortcuts/Shortcut-item.scss +0 -33
  160. package/src/Shortcuts/Shortcut-modal.scss +0 -20
  161. package/src/Shortcuts/ShortcutItem.tsx +0 -48
  162. package/src/Shortcuts/ShortcutModal.tsx +0 -67
  163. package/src/SidePanel/Group.tsx +0 -106
  164. package/src/SidePanel/SidePanel.tsx +0 -19
  165. package/src/SidePanel/group.scss +0 -42
  166. package/src/SidePanel/sidepanel.scss +0 -20
  167. package/src/Slider/Bar.tsx +0 -24
  168. package/src/Slider/Factor.test.ts +0 -48
  169. package/src/Slider/Handle.tsx +0 -121
  170. package/src/Slider/Slider.test.tsx +0 -25
  171. package/src/Slider/Slider.tsx +0 -91
  172. package/src/Slider/Ticks.tsx +0 -54
  173. package/src/Slider/__snapshots__/Slider.test.tsx.snap +0 -50
  174. package/src/Slider/bar.scss +0 -24
  175. package/src/Slider/factor.ts +0 -24
  176. package/src/Slider/handle.scss +0 -32
  177. package/src/Slider/percentage.ts +0 -67
  178. package/src/Slider/range.ts +0 -92
  179. package/src/Slider/slider.scss +0 -14
  180. package/src/Slider/ticks.scss +0 -28
  181. package/src/Slider/variables.scss +0 -16
  182. package/src/StartStopButton/StartStopButton.tsx +0 -60
  183. package/src/StartStopButton/play-circle.svg +0 -1
  184. package/src/StartStopButton/start-stop-button.scss +0 -47
  185. package/src/StartStopButton/stop-circle.svg +0 -1
  186. package/src/StateSelector/StateSelector.tsx +0 -64
  187. package/src/StateSelector/state-selector.scss +0 -38
  188. package/src/Stepper/Stepper.tsx +0 -139
  189. package/src/Stepper/stepper.scss +0 -127
  190. package/src/Toggle/Toggle.tsx +0 -120
  191. package/src/Toggle/toggle.scss +0 -109
  192. package/src/bootstrap.scss +0 -14
  193. package/src/index.ts +0 -146
  194. package/src/logging/appTransport.test.ts +0 -78
  195. package/src/logging/appTransport.ts +0 -41
  196. package/src/logging/describeError.test.ts +0 -38
  197. package/src/logging/describeError.ts +0 -56
  198. package/src/logging/index.ts +0 -103
  199. package/src/logging/logBuffer.test.ts +0 -41
  200. package/src/logging/logBuffer.ts +0 -24
  201. package/src/logging/sendInitialLogMessages.ts +0 -64
  202. package/src/store.ts +0 -60
  203. package/src/svg.d.ts +0 -15
  204. package/src/utils/AppTypes.ts +0 -60
  205. package/src/utils/appDirs.ts +0 -78
  206. package/src/utils/bleChannels.ts +0 -16
  207. package/src/utils/classNames.test.ts +0 -29
  208. package/src/utils/classNames.ts +0 -25
  209. package/src/utils/colors.scss +0 -46
  210. package/src/utils/colors.ts +0 -38
  211. package/src/utils/describeVersion.ts +0 -21
  212. package/src/utils/environment.ts +0 -6
  213. package/src/utils/logLibVersions.ts +0 -103
  214. package/src/utils/open.ts +0 -46
  215. package/src/utils/packageJson.ts +0 -60
  216. package/src/utils/persistentStore.ts +0 -144
  217. package/src/utils/systemReport.ts +0 -160
  218. package/src/utils/truncateMiddle.test.ts +0 -21
  219. package/src/utils/truncateMiddle.ts +0 -20
  220. package/src/utils/usageData.ts +0 -189
  221. package/src/utils/useHotKey.ts +0 -62
  222. package/src/utils/useStopwatch.test.tsx +0 -311
  223. package/src/utils/useStopwatch.ts +0 -140
  224. package/src/variables.scss +0 -820
  225. package/styles.scss +0 -88
  226. package/test/dispatchTo.ts +0 -23
  227. package/test/index.ts +0 -7
  228. package/test/jestResolver.js +0 -28
  229. package/test/setupTests.ts +0 -27
  230. package/test/testUtil.ts +0 -20
  231. package/test/testrenderer.tsx +0 -39
  232. /package/{src/Logo/nordic-logo-white-icon-only.png → dist/nordic-logo-white-icon-only-XIZBW537.png} +0 -0
@@ -1,162 +0,0 @@
1
- /*
2
- * Copyright (c) 2021 Nordic Semiconductor ASA
3
- *
4
- * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5
- */
6
-
7
- import * as $protobuf from 'protobufjs/light';
8
-
9
- const $root = (
10
- $protobuf.roots.default || ($protobuf.roots.default = new $protobuf.Root())
11
- ).addJSON({
12
- dfu: {
13
- nested: {
14
- OpCode: {
15
- values: {
16
- RESET: 0,
17
- INIT: 1,
18
- },
19
- },
20
- FwType: {
21
- values: {
22
- APPLICATION: 0,
23
- SOFTDEVICE: 1,
24
- BOOTLOADER: 2,
25
- SOFTDEVICE_BOOTLOADER: 3,
26
- },
27
- },
28
- HashType: {
29
- values: {
30
- NO_HASH: 0,
31
- CRC: 1,
32
- SHA128: 2,
33
- SHA256: 3,
34
- SHA512: 4,
35
- },
36
- },
37
- Hash: {
38
- fields: {
39
- hashType: {
40
- rule: 'required',
41
- type: 'HashType',
42
- id: 1,
43
- },
44
- hash: {
45
- rule: 'required',
46
- type: 'bytes',
47
- id: 2,
48
- },
49
- },
50
- },
51
- InitCommand: {
52
- fields: {
53
- fwVersion: {
54
- type: 'uint32',
55
- id: 1,
56
- },
57
- hwVersion: {
58
- type: 'uint32',
59
- id: 2,
60
- },
61
- sdReq: {
62
- rule: 'repeated',
63
- type: 'uint32',
64
- id: 3,
65
- },
66
- type: {
67
- type: 'FwType',
68
- id: 4,
69
- },
70
- sdSize: {
71
- type: 'uint32',
72
- id: 5,
73
- },
74
- blSize: {
75
- type: 'uint32',
76
- id: 6,
77
- },
78
- appSize: {
79
- type: 'uint32',
80
- id: 7,
81
- },
82
- hash: {
83
- type: 'Hash',
84
- id: 8,
85
- },
86
- isDebug: {
87
- type: 'bool',
88
- id: 9,
89
- options: {
90
- default: false,
91
- },
92
- },
93
- },
94
- },
95
- ResetCommand: {
96
- fields: {
97
- timeout: {
98
- rule: 'required',
99
- type: 'uint32',
100
- id: 1,
101
- },
102
- },
103
- },
104
- Command: {
105
- fields: {
106
- opCode: {
107
- type: 'OpCode',
108
- id: 1,
109
- },
110
- init: {
111
- type: 'InitCommand',
112
- id: 2,
113
- },
114
- reset: {
115
- type: 'ResetCommand',
116
- id: 3,
117
- },
118
- },
119
- },
120
- SignatureType: {
121
- values: {
122
- ECDSA_P256_SHA256: 0,
123
- ED25519: 1,
124
- },
125
- },
126
- SignedCommand: {
127
- fields: {
128
- command: {
129
- rule: 'required',
130
- type: 'Command',
131
- id: 1,
132
- },
133
- signatureType: {
134
- rule: 'required',
135
- type: 'SignatureType',
136
- id: 2,
137
- },
138
- signature: {
139
- rule: 'required',
140
- type: 'bytes',
141
- id: 3,
142
- },
143
- },
144
- },
145
- Packet: {
146
- fields: {
147
- command: {
148
- type: 'Command',
149
- id: 1,
150
- },
151
- signedCommand: {
152
- type: 'SignedCommand',
153
- id: 2,
154
- },
155
- },
156
- },
157
- },
158
- },
159
- });
160
-
161
- // export { $root as default };
162
- export default $root;
@@ -1,402 +0,0 @@
1
- /*
2
- * Copyright (c) 2015 Nordic Semiconductor ASA
3
- *
4
- * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5
- */
6
-
7
- import protobuf from 'protobufjs';
8
-
9
- import dfuCcProto from './dfu-cc';
10
-
11
- const root = protobuf.Root.fromJSON(dfuCcProto);
12
-
13
- export enum FwType {
14
- APPLICATION,
15
- SOFTDEVICE,
16
- BOOTLOADER,
17
- SOFTDEVICE_BOOTLOADER,
18
- }
19
-
20
- export enum HashType {
21
- NO_HASH,
22
- CRC,
23
- SHA128,
24
- SHA256,
25
- SHA512,
26
- }
27
-
28
- export const OpCode = {
29
- RESET: 0,
30
- INIT: 1,
31
- };
32
-
33
- export const SignatureType = {
34
- ECDSA_P256_SHA256: 0,
35
- ED25519: 1,
36
- };
37
-
38
- export interface InitPacket {
39
- fwVersion?: number;
40
- hwVersion?: number;
41
- sdReq?: number[];
42
- fwType?: number;
43
- sdSize: number;
44
- blSize: number;
45
- appSize: number;
46
- hashType: number;
47
- hash?: Buffer;
48
- isDebug: boolean;
49
- signatureType?: number;
50
- signature?: [];
51
- }
52
-
53
- export const defaultInitPacket: InitPacket = {
54
- fwVersion: 0xffffffff,
55
- hwVersion: undefined,
56
- sdReq: undefined,
57
- fwType: undefined,
58
- sdSize: 0,
59
- blSize: 0,
60
- appSize: 0,
61
- hashType: HashType.NO_HASH,
62
- hash: undefined,
63
- isDebug: true,
64
- signatureType: undefined,
65
- signature: undefined,
66
- };
67
-
68
- export interface DfuImage {
69
- name: string;
70
- initPacket: InitPacket;
71
- firmwareImage: Buffer;
72
- }
73
-
74
- // Create hash by using hash type and bytes
75
- const createHash = (hashType: number, hashInput: Buffer): protobuf.Message => {
76
- const hashMessage = root.lookupType('dfu.Hash');
77
- const hashPayload = {
78
- hashType,
79
- hash: hashInput,
80
- };
81
- const hash = hashMessage.create(hashPayload);
82
-
83
- return hash;
84
- };
85
-
86
- // Create reset command
87
- const createResetCommand = (timeout: number): protobuf.Message => {
88
- const resetCommandMessage = root.lookupType('dfu.ResetCommand');
89
- const resetCommandPayload = {
90
- timeout,
91
- };
92
- const resetCommand = resetCommandMessage.create(resetCommandPayload);
93
-
94
- return resetCommand;
95
- };
96
-
97
- // Create init command
98
- const createInitCommand = (
99
- fwVersion: number | undefined,
100
- hwVersion: number | undefined,
101
- sdReq: number[] | undefined,
102
- type: number | undefined,
103
- sdSize: number | undefined,
104
- blSize: number | undefined,
105
- appSize: number | undefined,
106
- hash: protobuf.Message | undefined,
107
- isDebug = false
108
- ): protobuf.Message => {
109
- const initCommandMessage = root.lookupType('dfu.InitCommand');
110
- const initCommandPayload = {
111
- ...defaultInitPacket,
112
- fwVersion,
113
- hwVersion,
114
- sdReq,
115
- type: type || FwType.APPLICATION,
116
- sdSize,
117
- blSize,
118
- appSize,
119
- hash,
120
- isDebug,
121
- };
122
-
123
- return initCommandMessage.create(initCommandPayload);
124
- };
125
-
126
- // Create command
127
- const createCommand = (
128
- opCode: number,
129
- commandInput: protobuf.Message
130
- ): protobuf.Message => {
131
- const commandMessage = root.lookupType('dfu.Command');
132
- const commandPayload = {
133
- opCode,
134
- [opCode === OpCode.INIT ? 'init' : 'reset']: commandInput,
135
- };
136
- const command = commandMessage.create(commandPayload);
137
-
138
- return command;
139
- };
140
-
141
- // Create signed command
142
- const createSignedCommand = (
143
- command: protobuf.Message,
144
- signatureType: number,
145
- signature: []
146
- ): protobuf.Message => {
147
- const signedCommandMessage = root.lookupType('dfu.SignedCommand');
148
- const signedCommandPayload = {
149
- command,
150
- signatureType,
151
- signature,
152
- };
153
- const signedCommand = signedCommandMessage.create(signedCommandPayload);
154
-
155
- return signedCommand;
156
- };
157
-
158
- // Create packet
159
- const createPacket = (
160
- command: protobuf.Message,
161
- isSigned: boolean
162
- ): protobuf.Message => {
163
- const packetPayload = {
164
- [isSigned ? 'signedCommand' : 'command']: command,
165
- };
166
- const packetMessage = root.lookupType('dfu.Packet');
167
- const packet = packetMessage.create(packetPayload);
168
-
169
- return packet;
170
- };
171
-
172
- // Convert protocol buffer message to buffer
173
- const messageToBuffer = (type: string, message: protobuf.Message) => {
174
- if (!message) {
175
- throw Error('The message to be converted is undefined.');
176
- }
177
-
178
- const dfuMessage = root.lookup(`dfu.${type}`) as protobuf.Type;
179
- if (!dfuMessage) {
180
- throw Error('DFU type not found.');
181
- }
182
-
183
- const buffer = dfuMessage.encode(message).finish();
184
-
185
- return buffer as Buffer;
186
- };
187
-
188
- /**
189
- * Create reset command packet
190
- *
191
- * @param {Integer} timeout the timeout for reset
192
- * @param {Integer} signatureType the type of signature
193
- * @param {Array} signature the signature in bytes
194
- *
195
- * @returns {protobuf.Message | undefined} reset command packet
196
- */
197
- export const createResetPacket = (
198
- timeout: number,
199
- signatureType: number,
200
- signature: []
201
- ): protobuf.Message => {
202
- // Check input parameters
203
- if (timeout === undefined) {
204
- throw new Error('Timeout is not set');
205
- }
206
-
207
- // It checks both null and undefined here
208
- if (
209
- (signatureType == null && signature != null) ||
210
- (signatureType != null && signature == null)
211
- ) {
212
- throw new Error('Either signature type or signature is not set');
213
- }
214
-
215
- // Create reset command
216
- const resetCommand = createResetCommand(timeout);
217
- let isSigned = false;
218
- let command = createCommand(OpCode.RESET, resetCommand);
219
-
220
- // Create signed command if it is signed
221
- // It checks both null and undefined here
222
- if (signatureType != null && signature != null) {
223
- isSigned = true;
224
- command = createSignedCommand(command, signatureType, signature);
225
- }
226
-
227
- // Create packet
228
- const packet = createPacket(command, isSigned);
229
-
230
- return packet;
231
- };
232
-
233
- /**
234
- * Create reset command buffer
235
- *
236
- * @param {Integer} timeout the timeout for reset
237
- * @param {Integer} signatureType the type of signature
238
- * @param {Array} signature the signature in bytes
239
- *
240
- * @returns {Uint8Array} converted from reset command packet
241
- */
242
- export const createResetPacketBuffer = (
243
- timeout: number,
244
- signatureType: number,
245
- signature: []
246
- ): Uint8Array => {
247
- const packet = createResetPacket(timeout, signatureType, signature);
248
- const buffer = messageToBuffer('Packet', packet);
249
-
250
- return buffer;
251
- };
252
-
253
- /**
254
- * Create init command packet
255
- *
256
- * @param {Integer} fwVersion the firmware version
257
- * @param {Integer} hwVersion the hardware version
258
- * @param {Array} sdReq the softdevice requirements
259
- * @param {FwType} fwType the firmware type
260
- * @param {Integer} sdSize the size of softDevice
261
- * @param {Integer} blSize the size of bootloader
262
- * @param {Integer} appSize the size of application
263
- * @param {HashType} hashType the type of hash
264
- * @param {Array} hash the hash in bytes
265
- * @param {Boolean} isDebug whether it is in debug mode or not
266
- * @param {SignatureType} signatureType the type of signature
267
- * @param {Array} signature the signature in bytes
268
- *
269
- * @returns {protobuf.Message} init command packet
270
- */
271
- export const createInitPacket = (
272
- fwVersion: number | undefined,
273
- hwVersion: number | undefined,
274
- sdReq: number[] | undefined,
275
- fwType: number | undefined,
276
- sdSize: number | undefined,
277
- blSize: number | undefined,
278
- appSize: number | undefined,
279
- hashType: number | undefined,
280
- hash: Buffer | undefined,
281
- isDebug: boolean,
282
- signatureType: number | undefined,
283
- signature: [] | undefined
284
- ): protobuf.Message => {
285
- // It checks both null and undefined here
286
- if (
287
- (signatureType == null && signature != null) ||
288
- (signatureType != null && signature == null)
289
- ) {
290
- throw new Error('Either signature type or signature is not set');
291
- }
292
-
293
- // Create init command
294
- const hashInput = createHash(
295
- hashType || HashType.NO_HASH,
296
- hash ?? Buffer.from([])
297
- );
298
- const initCommand = createInitCommand(
299
- fwVersion,
300
- hwVersion,
301
- sdReq,
302
- fwType,
303
- sdSize,
304
- blSize,
305
- appSize,
306
- hashInput,
307
- isDebug
308
- );
309
- let command = createCommand(OpCode.INIT, initCommand);
310
- let isSigned = false;
311
-
312
- // Create signed command if it is signed
313
- if (signatureType != null && signature != null) {
314
- command = createSignedCommand(command, signatureType, signature);
315
- isSigned = true;
316
- }
317
-
318
- // Create packet
319
- const packet = createPacket(command, isSigned);
320
-
321
- return packet;
322
- };
323
-
324
- /**
325
- * Create init command buffer
326
- *
327
- * @param {Integer} fwVersion the firmware version
328
- * @param {Integer} hwVersion the hardware version
329
- * @param {Array} sdReq the softdevice requirements
330
- * @param {FwType} fwType the firmware type
331
- * @param {Integer} sdSize the size of softdevice
332
- * @param {Integer} blSize the size of bootloader
333
- * @param {Integer} appSize the size of application
334
- * @param {HashType} hashType the type of hash
335
- * @param {Array} hash the hash in bytes
336
- * @param {Boolean} isDebug whether it is in debug mode or not
337
- * @param {SignatureType} signatureType the type of signature
338
- * @param {Array} signature the signature in bytes
339
- *
340
- * @returns {Uint8Array} converted from init command packet
341
- */
342
- export const createInitPacketBuffer = (
343
- fwVersion: number,
344
- hwVersion: number,
345
- sdReq: number[],
346
- fwType: number,
347
- sdSize: number,
348
- blSize: number,
349
- appSize: number,
350
- hashType: number,
351
- hash: Buffer,
352
- isDebug: boolean,
353
- signatureType: number,
354
- signature: []
355
- ): Buffer => {
356
- const packet = createInitPacket(
357
- fwVersion,
358
- hwVersion,
359
- sdReq,
360
- fwType,
361
- sdSize,
362
- blSize,
363
- appSize,
364
- hashType,
365
- hash,
366
- isDebug,
367
- signatureType,
368
- signature
369
- );
370
- const buffer = messageToBuffer('Packet', packet);
371
-
372
- return buffer;
373
- };
374
-
375
- /**
376
- * Create init command packet Uint8Array
377
- *
378
- * @param {InitPacket} packetParams the InitPacket which carries all information
379
- *
380
- * @returns {Uint8Array} converted from init command packet buffer
381
- */
382
- export const createInitPacketUint8Array = (
383
- packetParams: InitPacket
384
- ): Uint8Array => {
385
- const packet = createInitPacket(
386
- packetParams.fwVersion,
387
- packetParams.hwVersion,
388
- packetParams.sdReq,
389
- packetParams.fwType,
390
- packetParams.sdSize,
391
- packetParams.blSize,
392
- packetParams.appSize,
393
- packetParams.hashType,
394
- packetParams.hash,
395
- packetParams.isDebug,
396
- packetParams.signatureType,
397
- packetParams.signature
398
- );
399
- const buffer = messageToBuffer('Packet', packet);
400
-
401
- return new Uint8Array(buffer);
402
- };