@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.
- package/dist/bootstrap.css +8951 -0
- package/dist/index.css +1451 -0
- package/dist/index.js +122119 -0
- package/{src/Logo/nordic-logo-blue-icon-only.png → dist/nordic-logo-blue-icon-only-H7BABN6D.png} +0 -0
- package/{src/Logo/nordic-logo-gray-icon-only.png → dist/nordic-logo-gray-icon-only-GATOTR3L.png} +0 -0
- package/package.json +12 -3
- package/typings/generated/src/Device/deviceInfo/deviceInfo.d.ts +1 -2
- package/.github/ISSUE_TEMPLATE/custom.md +0 -10
- package/.husky/pre-push +0 -3
- package/.renovaterc.json +0 -10
- package/Changelog.md +0 -2973
- package/azure-pipelines.yml +0 -34
- package/config/eslintrc.js +0 -190
- package/config/jest.config.js +0 -41
- package/config/prettier.config.js +0 -13
- package/config/tsconfig.json +0 -15
- package/fw/bootloader/graviton_bootloader_v1.0.1-[nRF5_SDK_15.0.1-1.alpha_f76d012].zip +0 -0
- package/jest.config.js +0 -7
- package/main/index.ts +0 -32
- package/mocks/deviceLibMock.ts +0 -21
- package/mocks/electronMock.ts +0 -15
- package/mocks/electronStoreMock.ts +0 -19
- package/mocks/emptyMock.ts +0 -7
- package/mocks/fileMock.ts +0 -13
- package/mocks/gaMock.ts +0 -9
- package/mocks/mockTests.test.ts +0 -15
- package/mocks/packageJsonMock.ts +0 -10
- package/mocks/remoteMock.ts +0 -17
- package/scripts/esbuild-bootstrap.js +0 -15
- package/scripts/esbuild-renderer.js +0 -131
- package/scripts/installHusky.ts +0 -17
- package/scripts/prepare-shared-release.ts +0 -122
- package/scripts/release-shared.test.ts +0 -132
- package/scripts/release-shared.ts +0 -207
- package/src/About/About.tsx +0 -25
- package/src/About/AboutButton.tsx +0 -28
- package/src/About/ApplicationCard.tsx +0 -83
- package/src/About/DeviceCard.tsx +0 -74
- package/src/About/DocumentationCard.tsx +0 -18
- package/src/About/DocumentationSection.tsx +0 -24
- package/src/About/Section.tsx +0 -21
- package/src/About/ShortcutButton.tsx +0 -41
- package/src/About/SupportCard.tsx +0 -97
- package/src/About/about.scss +0 -40
- package/src/About/documentationSlice.ts +0 -41
- package/src/About/section.scss +0 -15
- package/src/About/shortcutSlice.ts +0 -52
- package/src/Alert/Alert.module.scss +0 -29
- package/src/Alert/Alert.tsx +0 -37
- package/src/App/App.test.tsx +0 -47
- package/src/App/App.tsx +0 -227
- package/src/App/ConnectedToStore.tsx +0 -19
- package/src/App/VisibilityBar.tsx +0 -103
- package/src/App/app.scss +0 -83
- package/src/App/appLayout.ts +0 -95
- package/src/App/shared.scss +0 -49
- package/src/App/visibility-bar.scss +0 -55
- package/src/Button/Button.tsx +0 -66
- package/src/Button/button.module.scss +0 -154
- package/src/Card/Card.tsx +0 -26
- package/src/Card/card.module.scss +0 -28
- package/src/Device/BrokenDeviceDialog/BrokenDeviceDialog.tsx +0 -58
- package/src/Device/BrokenDeviceDialog/broken-device-dialog.scss +0 -18
- package/src/Device/BrokenDeviceDialog/brokenDeviceDialogSlice.tsx +0 -48
- package/src/Device/DeviceSelector/BasicDeviceInfo.tsx +0 -115
- package/src/Device/DeviceSelector/DeviceIcon.tsx +0 -27
- package/src/Device/DeviceSelector/DeviceList/AnimatedList.tsx +0 -62
- package/src/Device/DeviceSelector/DeviceList/BrokenDevice.tsx +0 -34
- package/src/Device/DeviceSelector/DeviceList/Device.tsx +0 -84
- package/src/Device/DeviceSelector/DeviceList/DeviceList.tsx +0 -113
- package/src/Device/DeviceSelector/DeviceList/EditDeviceButtons.tsx +0 -28
- package/src/Device/DeviceSelector/DeviceList/MoreDeviceInfo.tsx +0 -65
- package/src/Device/DeviceSelector/DeviceList/RenameDevice.tsx +0 -22
- package/src/Device/DeviceSelector/DeviceList/broken-device.scss +0 -32
- package/src/Device/DeviceSelector/DeviceList/device-list.scss +0 -64
- package/src/Device/DeviceSelector/DeviceList/device.scss +0 -28
- package/src/Device/DeviceSelector/DeviceList/edit-device-buttons.scss +0 -31
- package/src/Device/DeviceSelector/DeviceList/more-device-info.scss +0 -33
- package/src/Device/DeviceSelector/DeviceList/rename-device.scss +0 -13
- package/src/Device/DeviceSelector/DeviceSelector.test.tsx +0 -342
- package/src/Device/DeviceSelector/DeviceSelector.tsx +0 -173
- package/src/Device/DeviceSelector/Favorite.tsx +0 -49
- package/src/Device/DeviceSelector/SelectDevice.tsx +0 -36
- package/src/Device/DeviceSelector/SelectedDevice.tsx +0 -65
- package/src/Device/DeviceSelector/arrow-down.svg +0 -1
- package/src/Device/DeviceSelector/basic-device-info.scss +0 -62
- package/src/Device/DeviceSelector/device-icon.scss +0 -27
- package/src/Device/DeviceSelector/favorite.scss +0 -17
- package/src/Device/DeviceSelector/select-device.scss +0 -38
- package/src/Device/DeviceSelector/selected-device.scss +0 -57
- package/src/Device/DeviceSetup/DeviceSetupView.tsx +0 -102
- package/src/Device/deviceAutoSelectSlice.ts +0 -144
- package/src/Device/deviceInfo/deviceInfo.ts +0 -254
- package/src/Device/deviceInfo/nRF51-Series-logo.svg +0 -1
- package/src/Device/deviceInfo/nRF52-Series-logo.svg +0 -1
- package/src/Device/deviceInfo/nRF53-Series-logo.svg +0 -1
- package/src/Device/deviceInfo/nRF70-Series_no-background_RGB.svg +0 -36
- package/src/Device/deviceInfo/nRF91-Series-logo.svg +0 -1
- package/src/Device/deviceInfo/ppk-logo.svg +0 -1
- package/src/Device/deviceInfo/unknown-logo.svg +0 -30
- package/src/Device/deviceInfo/unknown-nordic-logo.svg +0 -25
- package/src/Device/deviceLibWrapper.test.ts +0 -97
- package/src/Device/deviceLibWrapper.ts +0 -133
- package/src/Device/deviceLister.test.ts +0 -89
- package/src/Device/deviceLister.ts +0 -396
- package/src/Device/deviceSetup.ts +0 -264
- package/src/Device/deviceSetupSlice.ts +0 -94
- package/src/Device/deviceSlice.ts +0 -248
- package/src/Device/dfu-cc.ts +0 -162
- package/src/Device/initPacket.ts +0 -402
- package/src/Device/jprogOperations.ts +0 -206
- package/src/Device/sdfuOperations.ts +0 -601
- package/src/Dialog/Dialog.test.tsx +0 -134
- package/src/Dialog/Dialog.tsx +0 -236
- package/src/Dialog/dialog.scss +0 -60
- package/src/Dropdown/Dropdown.module.scss +0 -83
- package/src/Dropdown/Dropdown.test.tsx +0 -62
- package/src/Dropdown/Dropdown.tsx +0 -106
- package/src/ErrorBoundary/ErrorBoundary.test.tsx +0 -105
- package/src/ErrorBoundary/ErrorBoundary.tsx +0 -186
- package/src/ErrorBoundary/bug.svg +0 -1
- package/src/ErrorBoundary/error-boundary.scss +0 -102
- package/src/ErrorDialog/ErrorDialog.test.tsx +0 -70
- package/src/ErrorDialog/ErrorDialog.tsx +0 -94
- package/src/ErrorDialog/error.scss +0 -14
- package/src/ErrorDialog/errorDialogSlice.test.ts +0 -64
- package/src/ErrorDialog/errorDialogSlice.ts +0 -80
- package/src/FactoryReset/FactoryResetButton.test.tsx +0 -46
- package/src/FactoryReset/FactoryResetButton.tsx +0 -81
- package/src/InlineInput/InlineInput.tsx +0 -170
- package/src/InlineInput/NumberInlineInput.tsx +0 -107
- package/src/InlineInput/inline-input.scss +0 -38
- package/src/InlineInput/number-inline-input.scss +0 -15
- package/src/Log/LogEntry.tsx +0 -62
- package/src/Log/LogViewer.tsx +0 -54
- package/src/Log/log-entry.scss +0 -30
- package/src/Log/log-viewer.scss +0 -24
- package/src/Log/logSlice.ts +0 -73
- package/src/Log/syncLogToStore.ts +0 -36
- package/src/Logo/Logo.tsx +0 -48
- package/src/Logo/logo.scss +0 -11
- package/src/Main/Main.tsx +0 -13
- package/src/Main/main.scss +0 -13
- package/src/MasonryLayout/MasonryLayout.tsx +0 -234
- package/src/MasonryLayout/masonryLayout.module.scss +0 -46
- package/src/NavBar/NavBar.tsx +0 -22
- package/src/NavBar/NavMenu.test.tsx +0 -41
- package/src/NavBar/NavMenu.tsx +0 -53
- package/src/NavBar/NavMenuItem.tsx +0 -41
- package/src/NavBar/nav-bar.scss +0 -26
- package/src/NavBar/nav-menu-item.scss +0 -34
- package/src/OpenApp/openApp.ts +0 -18
- package/src/Panes/FeedbackPane.tsx +0 -149
- package/src/PseudoButton/PseudoButton.tsx +0 -56
- package/src/PseudoButton/pseudo-button.scss +0 -11
- package/src/SerialPort/ConflictingSettingsDialog.tsx +0 -242
- package/src/SerialPort/SerialPort.test.ts +0 -54
- package/src/SerialPort/SerialPort.ts +0 -202
- package/src/Shortcuts/Shortcut-item.scss +0 -33
- package/src/Shortcuts/Shortcut-modal.scss +0 -20
- package/src/Shortcuts/ShortcutItem.tsx +0 -48
- package/src/Shortcuts/ShortcutModal.tsx +0 -67
- package/src/SidePanel/Group.tsx +0 -106
- package/src/SidePanel/SidePanel.tsx +0 -19
- package/src/SidePanel/group.scss +0 -42
- package/src/SidePanel/sidepanel.scss +0 -20
- package/src/Slider/Bar.tsx +0 -24
- package/src/Slider/Factor.test.ts +0 -48
- package/src/Slider/Handle.tsx +0 -121
- package/src/Slider/Slider.test.tsx +0 -25
- package/src/Slider/Slider.tsx +0 -91
- package/src/Slider/Ticks.tsx +0 -54
- package/src/Slider/__snapshots__/Slider.test.tsx.snap +0 -50
- package/src/Slider/bar.scss +0 -24
- package/src/Slider/factor.ts +0 -24
- package/src/Slider/handle.scss +0 -32
- package/src/Slider/percentage.ts +0 -67
- package/src/Slider/range.ts +0 -92
- package/src/Slider/slider.scss +0 -14
- package/src/Slider/ticks.scss +0 -28
- package/src/Slider/variables.scss +0 -16
- package/src/StartStopButton/StartStopButton.tsx +0 -60
- package/src/StartStopButton/play-circle.svg +0 -1
- package/src/StartStopButton/start-stop-button.scss +0 -47
- package/src/StartStopButton/stop-circle.svg +0 -1
- package/src/StateSelector/StateSelector.tsx +0 -64
- package/src/StateSelector/state-selector.scss +0 -38
- package/src/Stepper/Stepper.tsx +0 -139
- package/src/Stepper/stepper.scss +0 -127
- package/src/Toggle/Toggle.tsx +0 -120
- package/src/Toggle/toggle.scss +0 -109
- package/src/bootstrap.scss +0 -14
- package/src/index.ts +0 -146
- package/src/logging/appTransport.test.ts +0 -78
- package/src/logging/appTransport.ts +0 -41
- package/src/logging/describeError.test.ts +0 -38
- package/src/logging/describeError.ts +0 -56
- package/src/logging/index.ts +0 -103
- package/src/logging/logBuffer.test.ts +0 -41
- package/src/logging/logBuffer.ts +0 -24
- package/src/logging/sendInitialLogMessages.ts +0 -64
- package/src/store.ts +0 -60
- package/src/svg.d.ts +0 -15
- package/src/utils/AppTypes.ts +0 -60
- package/src/utils/appDirs.ts +0 -78
- package/src/utils/bleChannels.ts +0 -16
- package/src/utils/classNames.test.ts +0 -29
- package/src/utils/classNames.ts +0 -25
- package/src/utils/colors.scss +0 -46
- package/src/utils/colors.ts +0 -38
- package/src/utils/describeVersion.ts +0 -21
- package/src/utils/environment.ts +0 -6
- package/src/utils/logLibVersions.ts +0 -103
- package/src/utils/open.ts +0 -46
- package/src/utils/packageJson.ts +0 -60
- package/src/utils/persistentStore.ts +0 -144
- package/src/utils/systemReport.ts +0 -160
- package/src/utils/truncateMiddle.test.ts +0 -21
- package/src/utils/truncateMiddle.ts +0 -20
- package/src/utils/usageData.ts +0 -189
- package/src/utils/useHotKey.ts +0 -62
- package/src/utils/useStopwatch.test.tsx +0 -311
- package/src/utils/useStopwatch.ts +0 -140
- package/src/variables.scss +0 -820
- package/styles.scss +0 -88
- package/test/dispatchTo.ts +0 -23
- package/test/index.ts +0 -7
- package/test/jestResolver.js +0 -28
- package/test/setupTests.ts +0 -27
- package/test/testUtil.ts +0 -20
- package/test/testrenderer.tsx +0 -39
- /package/{src/Logo/nordic-logo-white-icon-only.png → dist/nordic-logo-white-icon-only-XIZBW537.png} +0 -0
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2015 Nordic Semiconductor ASA
|
|
3
|
-
*
|
|
4
|
-
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { app } from '@electron/remote';
|
|
8
|
-
import {
|
|
9
|
-
createContext,
|
|
10
|
-
Error,
|
|
11
|
-
LogEvent,
|
|
12
|
-
ModuleVersion,
|
|
13
|
-
setLogLevel,
|
|
14
|
-
setLogPattern,
|
|
15
|
-
setTimeoutConfig,
|
|
16
|
-
startLogEvents,
|
|
17
|
-
stopLogEvents,
|
|
18
|
-
} from '@nordicsemiconductor/nrf-device-lib-js';
|
|
19
|
-
import path from 'path';
|
|
20
|
-
|
|
21
|
-
import { isLoggingVerbose } from '../Log/logSlice';
|
|
22
|
-
import logger from '../logging';
|
|
23
|
-
import {
|
|
24
|
-
getIsLoggingVerbose,
|
|
25
|
-
persistIsLoggingVerbose,
|
|
26
|
-
} from '../utils/persistentStore';
|
|
27
|
-
|
|
28
|
-
let deviceLibContext = 0n;
|
|
29
|
-
export const getDeviceLibContext = () => {
|
|
30
|
-
if (deviceLibContext === 0n) initDeviceLib();
|
|
31
|
-
|
|
32
|
-
return deviceLibContext;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const initDeviceLib = () => {
|
|
36
|
-
if (process.platform === 'win32') {
|
|
37
|
-
const binariesPath = app.getAppPath().endsWith('app.asar')
|
|
38
|
-
? `${app.getAppPath()}.unpacked`
|
|
39
|
-
: app.getAppPath();
|
|
40
|
-
deviceLibContext = createContext({
|
|
41
|
-
plugins_dir: path.join(
|
|
42
|
-
binariesPath,
|
|
43
|
-
'node_modules',
|
|
44
|
-
'@nordicsemiconductor',
|
|
45
|
-
'nrf-device-lib-js',
|
|
46
|
-
'Release'
|
|
47
|
-
),
|
|
48
|
-
});
|
|
49
|
-
} else {
|
|
50
|
-
deviceLibContext = createContext();
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
setTimeoutConfig(getDeviceLibContext(), {
|
|
54
|
-
enumerateMs: 3 * 60 * 1000,
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export const logNrfdlLogs = (evt: LogEvent) => {
|
|
59
|
-
if (process.env.NODE_ENV === 'production' && !isLoggingVerbose()) return;
|
|
60
|
-
switch (evt.level) {
|
|
61
|
-
case 'NRFDL_LOG_TRACE':
|
|
62
|
-
logger.verbose(evt.message);
|
|
63
|
-
break;
|
|
64
|
-
case 'NRFDL_LOG_DEBUG':
|
|
65
|
-
logger.debug(evt.message);
|
|
66
|
-
break;
|
|
67
|
-
case 'NRFDL_LOG_INFO':
|
|
68
|
-
logger.info(evt.message);
|
|
69
|
-
break;
|
|
70
|
-
case 'NRFDL_LOG_WARNING':
|
|
71
|
-
logger.warn(evt.message);
|
|
72
|
-
break;
|
|
73
|
-
case 'NRFDL_LOG_ERROR':
|
|
74
|
-
logger.error(evt.message);
|
|
75
|
-
break;
|
|
76
|
-
case 'NRFDL_LOG_CRITICAL':
|
|
77
|
-
logger.error(evt.message);
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export const forwardLogEventsFromDeviceLib = () => {
|
|
83
|
-
setLogPattern(getDeviceLibContext(), '[%n][%l](%T.%e) %v');
|
|
84
|
-
setVerboseDeviceLibLogging(getIsLoggingVerbose());
|
|
85
|
-
|
|
86
|
-
// Only the first reset after selecting "reset with verbose logging" is relevant
|
|
87
|
-
persistIsLoggingVerbose(false);
|
|
88
|
-
|
|
89
|
-
const taskId = startLogEvents(
|
|
90
|
-
getDeviceLibContext(),
|
|
91
|
-
(err?: Error) => {
|
|
92
|
-
if (err)
|
|
93
|
-
logger.logError(
|
|
94
|
-
'Error while listening to log messages from nrf-device-lib',
|
|
95
|
-
err
|
|
96
|
-
);
|
|
97
|
-
},
|
|
98
|
-
(evt: LogEvent) => logNrfdlLogs(evt)
|
|
99
|
-
);
|
|
100
|
-
return () => {
|
|
101
|
-
// @ts-expect-error Type will be updated in device-lib-js
|
|
102
|
-
stopLogEvents(taskId);
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
export const setVerboseDeviceLibLogging = (verboseLogging: boolean) =>
|
|
107
|
-
setLogLevel(
|
|
108
|
-
getDeviceLibContext(),
|
|
109
|
-
verboseLogging ? 'NRFDL_LOG_TRACE' : 'NRFDL_LOG_ERROR'
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
type KnownModule = 'nrfdl' | 'nrfdl-js' | 'jprog' | 'JlinkARM';
|
|
113
|
-
|
|
114
|
-
const findTopLevel = (module: KnownModule, versions: ModuleVersion[]) =>
|
|
115
|
-
versions.find(version => version.name === module);
|
|
116
|
-
|
|
117
|
-
const findInDependencies = (module: KnownModule, versions: ModuleVersion[]) => {
|
|
118
|
-
if (versions.length > 0) {
|
|
119
|
-
return getModuleVersion(
|
|
120
|
-
module,
|
|
121
|
-
versions.flatMap(version => [
|
|
122
|
-
...(version.dependencies ?? []),
|
|
123
|
-
...((version.plugins as ModuleVersion[]) ?? []),
|
|
124
|
-
])
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
export const getModuleVersion = (
|
|
130
|
-
module: KnownModule,
|
|
131
|
-
versions: ModuleVersion[] = []
|
|
132
|
-
): ModuleVersion | undefined =>
|
|
133
|
-
findTopLevel(module, versions) ?? findInDependencies(module, versions);
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2015 Nordic Semiconductor ASA
|
|
3
|
-
*
|
|
4
|
-
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { DeviceTraits } from '@nordicsemiconductor/nrf-device-lib-js';
|
|
8
|
-
|
|
9
|
-
import { hasValidDeviceTraits } from './deviceLister';
|
|
10
|
-
|
|
11
|
-
const allFalseDeviceTraits: DeviceTraits = {
|
|
12
|
-
usb: false,
|
|
13
|
-
nordicUsb: false,
|
|
14
|
-
nordicDfu: false,
|
|
15
|
-
seggerUsb: false,
|
|
16
|
-
jlink: false,
|
|
17
|
-
serialPorts: false,
|
|
18
|
-
broken: false,
|
|
19
|
-
mcuBoot: false,
|
|
20
|
-
modem: false,
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const someTrueDeviceTraits1: DeviceTraits = {
|
|
24
|
-
usb: true,
|
|
25
|
-
nordicUsb: true,
|
|
26
|
-
nordicDfu: true,
|
|
27
|
-
seggerUsb: false,
|
|
28
|
-
jlink: false,
|
|
29
|
-
serialPorts: false,
|
|
30
|
-
broken: false,
|
|
31
|
-
mcuBoot: false,
|
|
32
|
-
modem: false,
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const someTrueDeviceTraits2: DeviceTraits = {
|
|
36
|
-
usb: false,
|
|
37
|
-
nordicUsb: false,
|
|
38
|
-
nordicDfu: true,
|
|
39
|
-
seggerUsb: true,
|
|
40
|
-
jlink: true,
|
|
41
|
-
serialPorts: false,
|
|
42
|
-
broken: false,
|
|
43
|
-
mcuBoot: false,
|
|
44
|
-
modem: false,
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const someTrueDeviceTraits3: DeviceTraits = {
|
|
48
|
-
usb: false,
|
|
49
|
-
nordicUsb: false,
|
|
50
|
-
nordicDfu: false,
|
|
51
|
-
seggerUsb: false,
|
|
52
|
-
jlink: false,
|
|
53
|
-
serialPorts: false,
|
|
54
|
-
broken: true,
|
|
55
|
-
mcuBoot: true,
|
|
56
|
-
modem: true,
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
describe('hasValidDeviceTraits Tests', () => {
|
|
60
|
-
test('filter all undefined should be valid', () => {
|
|
61
|
-
expect(hasValidDeviceTraits(allFalseDeviceTraits, {})).toBeTruthy();
|
|
62
|
-
expect(hasValidDeviceTraits(someTrueDeviceTraits1, {})).toBeTruthy();
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
test('filter all false should be valid', () => {
|
|
66
|
-
expect(
|
|
67
|
-
hasValidDeviceTraits(allFalseDeviceTraits, allFalseDeviceTraits)
|
|
68
|
-
).toBeTruthy();
|
|
69
|
-
expect(
|
|
70
|
-
hasValidDeviceTraits(someTrueDeviceTraits1, allFalseDeviceTraits)
|
|
71
|
-
).toBeTruthy();
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
test('deviceTraits complete mismatch invalid', () => {
|
|
75
|
-
expect(
|
|
76
|
-
hasValidDeviceTraits(someTrueDeviceTraits1, someTrueDeviceTraits3)
|
|
77
|
-
).toBeFalsy();
|
|
78
|
-
|
|
79
|
-
expect(hasValidDeviceTraits({}, someTrueDeviceTraits3)).toBeFalsy();
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
test('deviceTraits with at lease one match is valid', () => {
|
|
83
|
-
expect(
|
|
84
|
-
hasValidDeviceTraits(someTrueDeviceTraits1, someTrueDeviceTraits2)
|
|
85
|
-
).toBeTruthy();
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
export default null;
|
|
@@ -1,396 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2015 Nordic Semiconductor ASA
|
|
3
|
-
*
|
|
4
|
-
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import nrfDeviceLib, {
|
|
8
|
-
Device as NrfdlDevice,
|
|
9
|
-
DeviceTraits,
|
|
10
|
-
HotplugEvent,
|
|
11
|
-
} from '@nordicsemiconductor/nrf-device-lib-js';
|
|
12
|
-
|
|
13
|
-
import logger from '../logging';
|
|
14
|
-
import type { AppDispatch, RootState } from '../store';
|
|
15
|
-
import {
|
|
16
|
-
clearWaitForDevice,
|
|
17
|
-
clearWaitForDeviceTimeout,
|
|
18
|
-
setArrivedButWrongWhen,
|
|
19
|
-
setDisconnectedTime,
|
|
20
|
-
setLastArrivedDeviceId,
|
|
21
|
-
setWaitForDeviceTimeout,
|
|
22
|
-
WaitForDevice,
|
|
23
|
-
} from './deviceAutoSelectSlice';
|
|
24
|
-
import { getDeviceLibContext } from './deviceLibWrapper';
|
|
25
|
-
import { closeDeviceSetupDialog } from './deviceSetupSlice';
|
|
26
|
-
import { addDevice, Device, removeDevice, setDevices } from './deviceSlice';
|
|
27
|
-
import { isDeviceInDFUBootloader } from './sdfuOperations';
|
|
28
|
-
|
|
29
|
-
let autoSelectDeviceCLISerialUsed = false;
|
|
30
|
-
|
|
31
|
-
const hasSameDeviceTraits = (
|
|
32
|
-
deviceTraits: DeviceTraits,
|
|
33
|
-
otherDeviceTraits: DeviceTraits
|
|
34
|
-
) =>
|
|
35
|
-
Object.keys(otherDeviceTraits).every(
|
|
36
|
-
rule =>
|
|
37
|
-
deviceTraits[rule as keyof DeviceTraits] ===
|
|
38
|
-
otherDeviceTraits[rule as keyof DeviceTraits]
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
const shouldAutoReselect = (
|
|
42
|
-
addedDevice: Device,
|
|
43
|
-
globalAutoReselect: boolean,
|
|
44
|
-
autoReselectDevice?: Device,
|
|
45
|
-
disconnectionTime?: number,
|
|
46
|
-
currentSelectedDevice?: Device
|
|
47
|
-
): boolean => {
|
|
48
|
-
// No device was selected when disconnection occurred
|
|
49
|
-
if (!autoReselectDevice) return false;
|
|
50
|
-
|
|
51
|
-
// device is still connected
|
|
52
|
-
if (disconnectionTime === undefined) return false;
|
|
53
|
-
|
|
54
|
-
// The device that was selected when disconnection occurred is not yet connected
|
|
55
|
-
if (addedDevice.serialNumber !== autoReselectDevice.serialNumber) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// The device is already selected
|
|
60
|
-
if (
|
|
61
|
-
currentSelectedDevice?.serialNumber === autoReselectDevice.serialNumber
|
|
62
|
-
) {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Device does not have the same traits
|
|
67
|
-
if (!hasSameDeviceTraits(addedDevice.traits, autoReselectDevice.traits)) {
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return globalAutoReselect;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const initAutoReconnectTimeout =
|
|
75
|
-
(onTimeout: () => void, waitForDevice: WaitForDevice) =>
|
|
76
|
-
(dispatch: AppDispatch) => {
|
|
77
|
-
const timeout = waitForDevice.timeout;
|
|
78
|
-
|
|
79
|
-
dispatch(
|
|
80
|
-
setWaitForDeviceTimeout(
|
|
81
|
-
setTimeout(() => {
|
|
82
|
-
dispatch(closeDeviceSetupDialog());
|
|
83
|
-
if (waitForDevice?.onFail)
|
|
84
|
-
waitForDevice?.onFail(
|
|
85
|
-
`Failed to detect device after reboot. Timed out after ${
|
|
86
|
-
timeout / 1000
|
|
87
|
-
} seconds.`
|
|
88
|
-
);
|
|
89
|
-
dispatch(clearWaitForDeviceTimeout());
|
|
90
|
-
onTimeout();
|
|
91
|
-
logger.warn(
|
|
92
|
-
`Failed to detect device after reboot. Timed out after ${
|
|
93
|
-
timeout / 1000
|
|
94
|
-
} seconds.`
|
|
95
|
-
);
|
|
96
|
-
}, timeout)
|
|
97
|
-
)
|
|
98
|
-
);
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
let hotplugTaskId: bigint | null = null;
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Wrap the device form nrf-device-lib to make the Device type consistent
|
|
105
|
-
*
|
|
106
|
-
* @param {Device} device The input device from nrf-device-lib
|
|
107
|
-
* @returns {Device} The updated device
|
|
108
|
-
*/
|
|
109
|
-
export const wrapDeviceFromNrfdl = (device: NrfdlDevice): Device => ({
|
|
110
|
-
...device,
|
|
111
|
-
boardVersion: device.jlink?.boardVersion ?? undefined,
|
|
112
|
-
serialport: device.serialPorts?.[0] ?? undefined,
|
|
113
|
-
serialNumber: device.serialNumber ?? `fallback-serialnumber-${device.id}`,
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Wrap the device form nrf-device-lib to make the Device type consistent
|
|
118
|
-
*
|
|
119
|
-
* @param {Device[]} devices The input devices from nrf-device-lib
|
|
120
|
-
* @returns {Device[]} The updated devices
|
|
121
|
-
*/
|
|
122
|
-
export const wrapDevicesFromNrfdl = (devices: NrfdlDevice[]): Device[] =>
|
|
123
|
-
devices.map(wrapDeviceFromNrfdl);
|
|
124
|
-
|
|
125
|
-
export const hasValidDeviceTraits = (
|
|
126
|
-
deviceTraits: DeviceTraits,
|
|
127
|
-
requiredTraits: DeviceTraits
|
|
128
|
-
) =>
|
|
129
|
-
Object.keys(requiredTraits).some(
|
|
130
|
-
rule =>
|
|
131
|
-
deviceTraits[rule as keyof DeviceTraits] &&
|
|
132
|
-
requiredTraits[rule as keyof DeviceTraits]
|
|
133
|
-
) ||
|
|
134
|
-
Object.keys(requiredTraits).every(
|
|
135
|
-
rule => requiredTraits[rule as keyof DeviceTraits] === false
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
/*
|
|
139
|
-
* Starts watching for devices with the given traits. See the nrf-device-lib
|
|
140
|
-
* library for available traits. Whenever devices are attached/detached, this
|
|
141
|
-
* will dispatch AddDevice or removeDevice and trigger events.
|
|
142
|
-
*/
|
|
143
|
-
export const startWatchingDevices =
|
|
144
|
-
(
|
|
145
|
-
deviceListing: DeviceTraits,
|
|
146
|
-
onDeviceConnected: (device: Device) => void,
|
|
147
|
-
onDeviceDisconnected: (device: Device) => void,
|
|
148
|
-
onDeviceDeselected: () => void,
|
|
149
|
-
doSelectDevice: (device: Device, autoReselected: boolean) => void
|
|
150
|
-
) =>
|
|
151
|
-
async (dispatch: AppDispatch, getState: () => RootState) => {
|
|
152
|
-
const updateDeviceList = (event: HotplugEvent) => {
|
|
153
|
-
const removeDeviceFromList = (remove: Device) => {
|
|
154
|
-
if (
|
|
155
|
-
remove.serialNumber ===
|
|
156
|
-
getState().device.selectedSerialNumber
|
|
157
|
-
) {
|
|
158
|
-
onDeviceDeselected();
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (
|
|
162
|
-
remove.serialNumber ===
|
|
163
|
-
getState().device.selectedSerialNumber &&
|
|
164
|
-
!getState().deviceAutoSelect.waitForDevice
|
|
165
|
-
) {
|
|
166
|
-
dispatch(closeDeviceSetupDialog());
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (!getState().deviceAutoSelect.arrivedButWrongWhen) {
|
|
170
|
-
dispatch(removeDevice(remove));
|
|
171
|
-
onDeviceDisconnected(remove);
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
switch (event.event_type) {
|
|
176
|
-
case 'NRFDL_DEVICE_EVENT_ARRIVED':
|
|
177
|
-
if (!event.device) {
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
if (
|
|
181
|
-
hasValidDeviceTraits(
|
|
182
|
-
event.device?.traits,
|
|
183
|
-
deviceListing
|
|
184
|
-
)
|
|
185
|
-
) {
|
|
186
|
-
const device = wrapDeviceFromNrfdl(event.device);
|
|
187
|
-
if (
|
|
188
|
-
!getState().device.devices.has(device.serialNumber)
|
|
189
|
-
) {
|
|
190
|
-
onDeviceConnected(device);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
const sn = getState().device.selectedSerialNumber;
|
|
194
|
-
const disconnectionTime =
|
|
195
|
-
getState().deviceAutoSelect.disconnectionTime;
|
|
196
|
-
const autoSelectDevice =
|
|
197
|
-
getState().deviceAutoSelect.device;
|
|
198
|
-
const selectedDevice =
|
|
199
|
-
sn !== null
|
|
200
|
-
? getState().device.devices.get(sn)
|
|
201
|
-
: undefined;
|
|
202
|
-
|
|
203
|
-
const result = shouldAutoReselect(
|
|
204
|
-
device,
|
|
205
|
-
getState().deviceAutoSelect.autoReselect,
|
|
206
|
-
autoSelectDevice,
|
|
207
|
-
disconnectionTime,
|
|
208
|
-
selectedDevice
|
|
209
|
-
);
|
|
210
|
-
|
|
211
|
-
dispatch(addDevice(device));
|
|
212
|
-
const deviceWithPersistedData =
|
|
213
|
-
getState().device.devices.get(device.serialNumber);
|
|
214
|
-
|
|
215
|
-
if (!deviceWithPersistedData) return;
|
|
216
|
-
|
|
217
|
-
if (result) {
|
|
218
|
-
logger.info(
|
|
219
|
-
`Auto Reconnecting Device SN: ${deviceWithPersistedData.serialNumber}`
|
|
220
|
-
);
|
|
221
|
-
doSelectDevice(deviceWithPersistedData, true);
|
|
222
|
-
} else if (
|
|
223
|
-
deviceWithPersistedData.serialNumber ===
|
|
224
|
-
getState().deviceAutoSelect.device?.serialNumber
|
|
225
|
-
) {
|
|
226
|
-
const waitForDevice =
|
|
227
|
-
getState().deviceAutoSelect.waitForDevice;
|
|
228
|
-
|
|
229
|
-
// Device lib might fail to advertise that a device has left before it rejoins (Mainly OSx)
|
|
230
|
-
// but we still need to trigger the onSuccess if a device 'reappeared' with a different 'id'
|
|
231
|
-
// and there is an outstanding waitForDevice Request. In this case the disconnectionTime was
|
|
232
|
-
// never set (as NRFDL_DEVICE_EVENT_LEFT was never sent) This created an additional problem as device
|
|
233
|
-
// lib may advertise the the same device with a single connect event. Hance we are keeping track of
|
|
234
|
-
// the device ID which is guaranteed to be change if a is disconnected and reconnected (for the
|
|
235
|
-
// same hotplug event listener) to ensure we only call the onSuccess once for every reconnect event.
|
|
236
|
-
// This is mostly relevant when 'when' is always
|
|
237
|
-
|
|
238
|
-
// Device is to be reconnected as timeout is provided
|
|
239
|
-
if (
|
|
240
|
-
waitForDevice &&
|
|
241
|
-
((disconnectionTime === undefined &&
|
|
242
|
-
getState().deviceAutoSelect
|
|
243
|
-
.lastArrivedDeviceId !==
|
|
244
|
-
deviceWithPersistedData.id) ||
|
|
245
|
-
(disconnectionTime ?? 0) +
|
|
246
|
-
waitForDevice.timeout >=
|
|
247
|
-
Date.now())
|
|
248
|
-
) {
|
|
249
|
-
if (
|
|
250
|
-
waitForDevice.when === 'always' ||
|
|
251
|
-
(waitForDevice.when ===
|
|
252
|
-
'dfuBootLoaderMode' &&
|
|
253
|
-
isDeviceInDFUBootloader(
|
|
254
|
-
deviceWithPersistedData
|
|
255
|
-
)) ||
|
|
256
|
-
(waitForDevice.when === 'applicationMode' &&
|
|
257
|
-
deviceWithPersistedData.dfuTriggerInfo !==
|
|
258
|
-
null) ||
|
|
259
|
-
(selectedDevice &&
|
|
260
|
-
waitForDevice.when === 'sameTraits' &&
|
|
261
|
-
hasSameDeviceTraits(
|
|
262
|
-
device.traits,
|
|
263
|
-
selectedDevice.traits
|
|
264
|
-
)) ||
|
|
265
|
-
(typeof waitForDevice.when === 'function' &&
|
|
266
|
-
waitForDevice.when(device))
|
|
267
|
-
) {
|
|
268
|
-
dispatch(
|
|
269
|
-
setLastArrivedDeviceId(
|
|
270
|
-
deviceWithPersistedData.id
|
|
271
|
-
)
|
|
272
|
-
);
|
|
273
|
-
dispatch(setDisconnectedTime(undefined));
|
|
274
|
-
|
|
275
|
-
logger.info(
|
|
276
|
-
'Wait For Device was successfully'
|
|
277
|
-
);
|
|
278
|
-
|
|
279
|
-
if (waitForDevice.once) {
|
|
280
|
-
dispatch(clearWaitForDevice());
|
|
281
|
-
} else {
|
|
282
|
-
dispatch(clearWaitForDeviceTimeout());
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
if (waitForDevice.onSuccess)
|
|
286
|
-
waitForDevice.onSuccess(
|
|
287
|
-
deviceWithPersistedData
|
|
288
|
-
);
|
|
289
|
-
} else {
|
|
290
|
-
dispatch(setArrivedButWrongWhen(true));
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
break;
|
|
296
|
-
case 'NRFDL_DEVICE_EVENT_LEFT':
|
|
297
|
-
{
|
|
298
|
-
const devices = getState().device.devices;
|
|
299
|
-
|
|
300
|
-
devices.forEach(device => {
|
|
301
|
-
if (device.id === event.device_id) {
|
|
302
|
-
const waitForDevice =
|
|
303
|
-
getState().deviceAutoSelect.waitForDevice;
|
|
304
|
-
if (
|
|
305
|
-
device.serialNumber ===
|
|
306
|
-
getState().deviceAutoSelect.device
|
|
307
|
-
?.serialNumber
|
|
308
|
-
) {
|
|
309
|
-
if (waitForDevice) {
|
|
310
|
-
dispatch(
|
|
311
|
-
setArrivedButWrongWhen(undefined)
|
|
312
|
-
);
|
|
313
|
-
|
|
314
|
-
dispatch(
|
|
315
|
-
initAutoReconnectTimeout(
|
|
316
|
-
() =>
|
|
317
|
-
removeDeviceFromList(
|
|
318
|
-
device
|
|
319
|
-
),
|
|
320
|
-
waitForDevice
|
|
321
|
-
)
|
|
322
|
-
);
|
|
323
|
-
} else {
|
|
324
|
-
removeDeviceFromList(device);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
dispatch(setDisconnectedTime(Date.now()));
|
|
328
|
-
} else {
|
|
329
|
-
removeDeviceFromList(device);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
break;
|
|
335
|
-
}
|
|
336
|
-
};
|
|
337
|
-
|
|
338
|
-
try {
|
|
339
|
-
stopWatchingDevices();
|
|
340
|
-
const nrfdlDevices = await nrfDeviceLib.enumerate(
|
|
341
|
-
getDeviceLibContext(),
|
|
342
|
-
deviceListing
|
|
343
|
-
);
|
|
344
|
-
|
|
345
|
-
const currentDevices = wrapDevicesFromNrfdl(nrfdlDevices);
|
|
346
|
-
dispatch(setDevices(currentDevices));
|
|
347
|
-
|
|
348
|
-
if (!autoSelectDeviceCLISerialUsed) {
|
|
349
|
-
const autoSelectSN = getAutoSelectDeviceCLISerial();
|
|
350
|
-
|
|
351
|
-
if (autoSelectSN !== undefined) {
|
|
352
|
-
const autoSelectDevice =
|
|
353
|
-
getState().device.devices.get(autoSelectSN);
|
|
354
|
-
|
|
355
|
-
if (autoSelectDevice)
|
|
356
|
-
doSelectDevice(autoSelectDevice, true);
|
|
357
|
-
}
|
|
358
|
-
autoSelectDeviceCLISerialUsed = true;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
hotplugTaskId = nrfDeviceLib.startHotplugEvents(
|
|
362
|
-
getDeviceLibContext(),
|
|
363
|
-
() => {},
|
|
364
|
-
updateDeviceList
|
|
365
|
-
);
|
|
366
|
-
} catch (error) {
|
|
367
|
-
logger.logError(
|
|
368
|
-
'Error while probing devices, more details in the debug log',
|
|
369
|
-
error
|
|
370
|
-
);
|
|
371
|
-
}
|
|
372
|
-
};
|
|
373
|
-
|
|
374
|
-
const getAutoSelectDeviceCLISerial = () => {
|
|
375
|
-
const { argv } = process;
|
|
376
|
-
const serialIndex = argv.findIndex(arg => arg === '--deviceSerial');
|
|
377
|
-
return serialIndex > -1 ? argv[serialIndex + 1] : undefined;
|
|
378
|
-
};
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* Stops watching for devices.
|
|
382
|
-
*
|
|
383
|
-
* @returns {undefined}
|
|
384
|
-
*/
|
|
385
|
-
export const stopWatchingDevices = () => {
|
|
386
|
-
// Not sure, if this guard clause is really needed
|
|
387
|
-
if (getDeviceLibContext() && hotplugTaskId !== null) {
|
|
388
|
-
try {
|
|
389
|
-
// @ts-expect-error Type will be updated in device-lib-js
|
|
390
|
-
nrfDeviceLib.stopHotplugEvents(hotplugTaskId);
|
|
391
|
-
hotplugTaskId = null;
|
|
392
|
-
} catch (error) {
|
|
393
|
-
logger.logError('Error while stopping to watch devices', error);
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
};
|