33 *
44 * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
55 */
6- import { SerialPort } from 'serialport' ;
7-
86import logger from '../logging' ;
97import describeError from '../logging/describeError' ;
108import { Device , RootState , TDispatch } from '../state' ;
@@ -33,7 +31,7 @@ export interface JprogEntry {
3331 fwVersion : string ;
3432}
3533
36- export interface IDeviceSetup {
34+ export interface DeviceSetup {
3735 supportsProgrammingMode : ( device : Device ) => boolean ; // Return true if this device can be programed using this interface e.g. MCU Boot or DFU
3836 getFirmwareOptions : ( device : Device ) => {
3937 key : string ;
@@ -60,17 +58,17 @@ export interface IDeviceSetup {
6058 ) => Promise < Device | null > ; // returns the device after switched to app mode. If this is not possible or not relevant return null
6159}
6260
63- export interface DeviceSetup {
64- deviceSetups : IDeviceSetup [ ] ;
65- allowCustomDevice ?: boolean ; // allow custom J-Link device
61+ export interface DeviceSetupConfig {
62+ deviceSetups : DeviceSetup [ ] ;
63+ allowCustomDevice ?: boolean ;
6664 confirmMessage ?: string ;
6765 choiceMessage ?: string ;
6866}
6967
7068export const prepareDevice =
7169 (
7270 device : Device ,
73- deviceSetupConfig : DeviceSetup ,
71+ deviceSetupConfig : DeviceSetupConfig ,
7472 onSuccess : ( device : Device ) => void ,
7573 onFail : ( reason ?: unknown ) => void ,
7674 checkCurrentFirmwareVersion = true ,
@@ -225,20 +223,18 @@ export const prepareDevice =
225223export const setupDevice =
226224 (
227225 device : Device ,
228- deviceSetup : DeviceSetup ,
226+ deviceSetupConfig : DeviceSetupConfig ,
229227 onDeviceIsReady : ( device : Device ) => void ,
230228 doDeselectDevice : ( ) => void
231229 ) =>
232- ( dispatch : TDispatch , getState : ( ) => RootState ) => {
233- const deviceSetupConfig = {
234- allowCustomDevice : false ,
235- ...deviceSetup ,
236- } ;
237-
230+ ( dispatch : TDispatch , getState : ( ) => RootState ) =>
238231 dispatch (
239232 prepareDevice (
240233 device ,
241- deviceSetupConfig ,
234+ {
235+ allowCustomDevice : false ,
236+ ...deviceSetupConfig ,
237+ } ,
242238 d => {
243239 // Given that this task has async elements to it one might call setupDevice and
244240 // while that is still in progress select some other device
@@ -260,4 +256,3 @@ export const setupDevice =
260256 }
261257 )
262258 ) ;
263- } ;
0 commit comments