@nordicsemiconductor/pc-nrfconnect-shared 185.0.0 → 187.0.0
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/Changelog.md +17 -0
- package/package.json +1 -1
- package/src/Device/DeviceSelector/DeviceSelector.tsx +10 -5
- package/src/Device/deviceLister.ts +54 -15
- package/src/Device/deviceSlice.ts +2 -36
- package/typings/generated/src/Device/DeviceSelector/DeviceSelector.d.ts.map +1 -1
- package/typings/generated/src/Device/deviceLister.d.ts.map +1 -1
- package/typings/generated/src/Device/deviceSlice.d.ts.map +1 -1
package/Changelog.md
CHANGED
|
@@ -7,6 +7,23 @@ This project does _not_ adhere to
|
|
|
7
7
|
[Semantic Versioning](https://semver.org/spec/v2.0.0.html) but contrary to it
|
|
8
8
|
every new version is a new major version.
|
|
9
9
|
|
|
10
|
+
## 187.0.0 - 2024-10-04
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Auto connecting from CLI for device that has persisted data.
|
|
15
|
+
|
|
16
|
+
## 186.0.0 - 2024-10-03
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- DeviceSelector Abort controler now aborts on the onDisconnected event
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
|
|
24
|
+
- Auto connecting from CLI when multple devices are connected now works as
|
|
25
|
+
expected.
|
|
26
|
+
|
|
10
27
|
## 185.0.0 - 2024-09-20
|
|
11
28
|
|
|
12
29
|
### Added
|
package/package.json
CHANGED
|
@@ -72,8 +72,11 @@ export default ({
|
|
|
72
72
|
const waitingToAutoReconnect = useSelector(getWaitingToAutoReselect);
|
|
73
73
|
const showSelectedDevice = deviceIsSelected || waitingToAutoReconnect;
|
|
74
74
|
|
|
75
|
+
const abortController = useRef<AbortController>();
|
|
76
|
+
|
|
75
77
|
const doDeselectDevice = useCallback(
|
|
76
78
|
(device?: Device) => {
|
|
79
|
+
abortController.current?.abort();
|
|
77
80
|
if (device) {
|
|
78
81
|
telemetry.sendEvent(
|
|
79
82
|
'device deselected ',
|
|
@@ -83,21 +86,21 @@ export default ({
|
|
|
83
86
|
|
|
84
87
|
dispatch(clearWaitForDevice());
|
|
85
88
|
dispatch(setAutoSelectDevice(undefined));
|
|
86
|
-
logger.info(`
|
|
89
|
+
logger.info(`Deselected device`);
|
|
87
90
|
onDeviceDeselected();
|
|
88
91
|
dispatch(deselectDevice());
|
|
89
92
|
},
|
|
90
93
|
[dispatch, onDeviceDeselected]
|
|
91
94
|
);
|
|
92
95
|
|
|
93
|
-
const abortController = useRef<AbortController>();
|
|
94
|
-
|
|
95
96
|
// Ensure that useCallback is
|
|
96
97
|
// not updated frequently as this
|
|
97
98
|
// will have a side effect to stop and start the hotplug events
|
|
98
99
|
const doSelectDevice = useCallback(
|
|
99
100
|
async (device: Device, autoReselected: boolean) => {
|
|
100
|
-
logger.info(
|
|
101
|
+
logger.info(
|
|
102
|
+
`Selecting device with the serial number ${device.serialNumber}`
|
|
103
|
+
);
|
|
101
104
|
abortController.current?.abort();
|
|
102
105
|
const controller = new AbortController();
|
|
103
106
|
abortController.current = controller;
|
|
@@ -126,7 +129,9 @@ export default ({
|
|
|
126
129
|
|
|
127
130
|
if (!controller.signal.aborted) {
|
|
128
131
|
dispatch(setSelectedDeviceInfo(deviceInfo));
|
|
129
|
-
logger.info(
|
|
132
|
+
logger.info(
|
|
133
|
+
`Selected device with the serial number ${device.serialNumber}`
|
|
134
|
+
);
|
|
130
135
|
onDeviceSelected(device, autoReselected, controller);
|
|
131
136
|
|
|
132
137
|
telemetry.sendEvent('device selected', {
|
|
@@ -11,6 +11,11 @@ import logger from '../logging';
|
|
|
11
11
|
import type { AppThunk, RootState } from '../store';
|
|
12
12
|
import simplifyDevice from '../telemetry/simplifyDevice';
|
|
13
13
|
import telemetry from '../telemetry/telemetry';
|
|
14
|
+
import {
|
|
15
|
+
getPersistedIsFavorite,
|
|
16
|
+
getPersistedNickname,
|
|
17
|
+
getPersistedSerialPortSettings,
|
|
18
|
+
} from '../utils/persistentStore';
|
|
14
19
|
import {
|
|
15
20
|
clearWaitForDevice,
|
|
16
21
|
clearWaitForDeviceTimeout,
|
|
@@ -161,6 +166,36 @@ const removeDeviceFromList =
|
|
|
161
166
|
* library for available traits. Whenever devices are attached/detached, this
|
|
162
167
|
* will dispatch AddDevice or removeDevice and trigger events.
|
|
163
168
|
*/
|
|
169
|
+
|
|
170
|
+
const setPersistedData = (device: Device) => {
|
|
171
|
+
if (device.serialNumber) {
|
|
172
|
+
const newDevice = { ...device };
|
|
173
|
+
newDevice.favorite = getPersistedIsFavorite(device.serialNumber);
|
|
174
|
+
newDevice.nickname = getPersistedNickname(device.serialNumber);
|
|
175
|
+
|
|
176
|
+
const persistedSerialPortSettings = getPersistedSerialPortSettings(
|
|
177
|
+
device.serialNumber
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
if (persistedSerialPortSettings) {
|
|
181
|
+
const path =
|
|
182
|
+
newDevice.serialPorts?.[persistedSerialPortSettings.vComIndex]
|
|
183
|
+
?.comName;
|
|
184
|
+
|
|
185
|
+
if (path) {
|
|
186
|
+
newDevice.persistedSerialPortOptions = {
|
|
187
|
+
...persistedSerialPortSettings.serialPortOptions,
|
|
188
|
+
path,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return newDevice;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return device;
|
|
197
|
+
};
|
|
198
|
+
|
|
164
199
|
export const startWatchingDevices =
|
|
165
200
|
(
|
|
166
201
|
deviceListing: DeviceTraits,
|
|
@@ -404,13 +439,20 @@ export const startWatchingDevices =
|
|
|
404
439
|
const operation = await NrfutilDeviceLib.list(
|
|
405
440
|
deviceListing,
|
|
406
441
|
d => {
|
|
442
|
+
d = d.map(setPersistedData);
|
|
407
443
|
d.forEach(onDeviceArrived);
|
|
408
|
-
|
|
444
|
+
autoSelectDeviceCLI(d, doSelectDevice);
|
|
409
445
|
},
|
|
410
446
|
error => {
|
|
411
447
|
logger.error(error);
|
|
412
448
|
},
|
|
413
|
-
{
|
|
449
|
+
{
|
|
450
|
+
onDeviceArrived: d => {
|
|
451
|
+
d = setPersistedData(d);
|
|
452
|
+
onDeviceArrived(d);
|
|
453
|
+
},
|
|
454
|
+
onDeviceLeft,
|
|
455
|
+
}
|
|
414
456
|
);
|
|
415
457
|
|
|
416
458
|
stopNrfutilDevice = (callback?: () => void) => {
|
|
@@ -459,21 +501,18 @@ const getAutoSelectDevice = (devices: Device[]) => {
|
|
|
459
501
|
}
|
|
460
502
|
};
|
|
461
503
|
|
|
462
|
-
const autoSelectDeviceCLI =
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
(
|
|
467
|
-
|
|
468
|
-
const autoSelectDevice = getAutoSelectDevice(
|
|
469
|
-
getState().device.devices
|
|
470
|
-
);
|
|
504
|
+
const autoSelectDeviceCLI = (
|
|
505
|
+
devices: Device[],
|
|
506
|
+
doSelectDevice: (device: Device, autoReselected: boolean) => void
|
|
507
|
+
) => {
|
|
508
|
+
if (!autoSelectDeviceCLISerialUsed) {
|
|
509
|
+
const autoSelectDevice = getAutoSelectDevice(devices);
|
|
471
510
|
|
|
472
|
-
|
|
511
|
+
if (autoSelectDevice) doSelectDevice(autoSelectDevice, true);
|
|
473
512
|
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
513
|
+
autoSelectDeviceCLISerialUsed = true;
|
|
514
|
+
}
|
|
515
|
+
};
|
|
477
516
|
|
|
478
517
|
export const stopWatchingDevices = (callback?: () => void) => {
|
|
479
518
|
if (stopNrfutilDevice) stopNrfutilDevice(callback);
|
|
@@ -12,9 +12,6 @@ import { DeviceInfo } from '../../nrfutil/device';
|
|
|
12
12
|
import { NrfutilDevice } from '../../nrfutil/device/common';
|
|
13
13
|
import type { RootState } from '../store';
|
|
14
14
|
import {
|
|
15
|
-
getPersistedIsFavorite,
|
|
16
|
-
getPersistedNickname,
|
|
17
|
-
getPersistedSerialPortSettings,
|
|
18
15
|
persistIsFavorite,
|
|
19
16
|
persistNickname,
|
|
20
17
|
persistSerialPortSettings as persistSerialPortSettingsToStore,
|
|
@@ -69,35 +66,6 @@ const initialState: DeviceState = {
|
|
|
69
66
|
devices: [],
|
|
70
67
|
};
|
|
71
68
|
|
|
72
|
-
const setPersistedData = (device: Device) => {
|
|
73
|
-
if (device.serialNumber) {
|
|
74
|
-
const newDevice = { ...device };
|
|
75
|
-
newDevice.favorite = getPersistedIsFavorite(device.serialNumber);
|
|
76
|
-
newDevice.nickname = getPersistedNickname(device.serialNumber);
|
|
77
|
-
|
|
78
|
-
const persistedSerialPortSettings = getPersistedSerialPortSettings(
|
|
79
|
-
device.serialNumber
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
if (persistedSerialPortSettings) {
|
|
83
|
-
const path =
|
|
84
|
-
newDevice.serialPorts?.[persistedSerialPortSettings.vComIndex]
|
|
85
|
-
?.comName;
|
|
86
|
-
|
|
87
|
-
if (path) {
|
|
88
|
-
newDevice.persistedSerialPortOptions = {
|
|
89
|
-
...persistedSerialPortSettings.serialPortOptions,
|
|
90
|
-
path,
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return newDevice;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return device;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
69
|
const slice = createSlice({
|
|
102
70
|
name: 'device',
|
|
103
71
|
initialState,
|
|
@@ -130,12 +98,10 @@ const slice = createSlice({
|
|
|
130
98
|
item.serialNumber === action.payload.serialNumber ||
|
|
131
99
|
item.id === action.payload.id
|
|
132
100
|
);
|
|
133
|
-
|
|
134
|
-
const device = setPersistedData(action.payload);
|
|
135
101
|
if (index !== -1) {
|
|
136
|
-
state.devices[index] =
|
|
102
|
+
state.devices[index] = action.payload;
|
|
137
103
|
} else {
|
|
138
|
-
state.devices.push(
|
|
104
|
+
state.devices.push(action.payload);
|
|
139
105
|
}
|
|
140
106
|
},
|
|
141
107
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceSelector.d.ts","sourceRoot":"","sources":["../../../../../src/Device/DeviceSelector/DeviceSelector.tsx"],"names":[],"mappings":";AAUA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAe9D,OAAO,EAAE,iBAAiB,EAAe,MAAM,gBAAgB,CAAC;AAEhE,OAAO,EAEH,MAAM,EAMT,MAAM,gBAAgB,CAAC;AAKxB,MAAM,WAAW,KAAK;IAClB,aAAa,EAAE,YAAY,CAAC;IAC5B,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,gBAAgB,CAAC,EAAE,CACf,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,OAAO,EACvB,eAAe,EAAE,eAAe,KAC/B,IAAI,CAAC;IACV,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;IAChC,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,oBAAoB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;CAC9C;8KAYE,KAAK;AATR,
|
|
1
|
+
{"version":3,"file":"DeviceSelector.d.ts","sourceRoot":"","sources":["../../../../../src/Device/DeviceSelector/DeviceSelector.tsx"],"names":[],"mappings":";AAUA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAe9D,OAAO,EAAE,iBAAiB,EAAe,MAAM,gBAAgB,CAAC;AAEhE,OAAO,EAEH,MAAM,EAMT,MAAM,gBAAgB,CAAC;AAKxB,MAAM,WAAW,KAAK;IAClB,aAAa,EAAE,YAAY,CAAC;IAC5B,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,gBAAgB,CAAC,EAAE,CACf,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,OAAO,EACvB,eAAe,EAAE,eAAe,KAC/B,IAAI,CAAC;IACV,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;IAChC,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,oBAAoB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;CAC9C;8KAYE,KAAK;AATR,wBAoLE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deviceLister.d.ts","sourceRoot":"","sources":["../../../../src/Device/deviceLister.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAiB,MAAM,6BAA6B,CAAC;AAG1E,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"deviceLister.d.ts","sourceRoot":"","sources":["../../../../src/Device/deviceLister.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAiB,MAAM,6BAA6B,CAAC;AAG1E,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAmBpD,OAAO,EAEH,MAAM,EAIT,MAAM,eAAe,CAAC;AAsDvB,eAAO,MAAM,QAAQ,WAAY,MAAM,eAAe,UAAU,YAI3D,CAAC;AA8BN,eAAO,MAAM,oBAAoB,iBACf,YAAY,kBACV,YAAY,YAS3B,CAAC;AAgEN,eAAO,MAAM,oBAAoB,kBAEV,YAAY,8BACC,MAAM,KAAK,IAAI,iCACZ,MAAM,KAAK,IAAI,sBAC1B,MAAM,IAAI,2BACL,MAAM,kBAAkB,OAAO,KAAK,IAAI,KAClE,SAAS,SAAS,EAAE,IAAI,CAkQ1B,CAAC;AAqDN,eAAO,MAAM,mBAAmB,cAAe,MAAM,IAAI,SAGxD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deviceSlice.d.ts","sourceRoot":"","sources":["../../../../src/Device/deviceSlice.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"deviceSlice.d.ts","sourceRoot":"","sources":["../../../../src/Device/deviceSlice.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAO1C,MAAM,WAAW,MAAO,SAAQ,aAAa;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0BAA0B,CAAC,EAAE,qBAAqB,CAAC,eAAe,CAAC,CAAC;CACvE;AAED,MAAM,WAAW,sBAAuB,SAAQ,MAAM;IAClD,YAAY,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,wBAAwB,WACzB,MAAM,qCAEmC,CAAC;AA0BtD,MAAM,WAAW,WAAW;IACxB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kBAAkB,CAAC,EAAE,UAAU,CAAC;CACnC;AAuKD,eAAO,MACH,OAAO,mEAEH,cAAc,mFACd,mBAAmB,6FACnB,YAAY,sFACZ,qBAAqB,uHACrB,SAAS,mFACT,YAAY,sFACZ,iBAAiB;;;8CACjB,qBAAqB,+FACrB,wBAAwB,gIAEvB,CAAC;AAEV,eAAO,MAAM,SAAS,UAAW,SAAS,gBAAgB,MAAM,uBACG,CAAC;AAEpE,eAAO,MAAM,UAAU,UAAW,SAAS,aAAyB,CAAC;AAErE,eAAO,MAAM,gBAAgB,UAAW,SAAS,YAChB,CAAC;AAElC,eAAO,MAAM,cAAc,UAAW,SAAS,uBAAgC,CAAC;AAEhF,eAAO,MAAM,kBAAkB,UAAW,SAAS,2BAC0B,CAAC;AAE9E,eAAO,MAAM,oBAAoB,UAAW,SAAS,8BACR,CAAC;AAE9C,eAAO,MAAM,qBAAqB,UAAW,SAAS,gEACM,CAAC"}
|