Skip to content

Commit

Permalink
Merge pull request #829 from NordicSemiconductor/fix/programmer-relat…
Browse files Browse the repository at this point in the history
…es-issues

Fix/programmer relates issues
  • Loading branch information
kylebonnici authored Nov 14, 2023
2 parents 4f1b676 + 1b2b5f8 commit fe2109f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
11 changes: 11 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ This project does _not_ adhere to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html) but contrary to it
every new version is a new major version.

## 132 - 2023-11-14

### Added

- Extended `waitForDevice` to allow apps to opt-out from refetching the device
info when device a reapers from a reboot

### Fixed

- `deviceInfo` is update in redux on device select

## 131 - 2023-11-14

### Changed
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nordicsemiconductor/pc-nrfconnect-shared",
"version": "131.0.0",
"version": "132.0.0",
"description": "Shared commodities for developing pc-nrfconnect-* packages",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion src/Device/DeviceSelector/DeviceSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export default ({
abortController.current
);
abortController.current = undefined;
setSelectedDeviceInfo(deviceInfo);
dispatch(setSelectedDeviceInfo(deviceInfo));
onDeviceSelected(device, autoReselected);

usageData.sendUsageData('device selected', {
Expand Down
1 change: 1 addition & 0 deletions src/Device/deviceAutoSelectSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface WaitForDevice {
| 'sameTraits'
| ((device: Device) => boolean);
once: boolean;
skipRefetchDeviceInfo?: boolean;
onSuccess?: (device: Device) => void;
onFail?: (reason?: string) => void;
}
Expand Down
18 changes: 12 additions & 6 deletions src/Device/deviceLister.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,6 @@ export const startWatchingDevices =
const waitForDevice =
getState().deviceAutoSelect.waitForDevice;

const deviceInfo = await NrfutilDeviceLib.deviceInfo(
device
);

// Device lib might fail to advertise that a device has left before it rejoins (Mainly OSx)
// but we still need to trigger the onSuccess if a device 'reappeared' with a different 'id'
// and there is an outstanding waitForDevice Request. In this case the disconnectionTime was
Expand Down Expand Up @@ -266,7 +262,10 @@ export const startWatchingDevices =
deviceWithPersistedData
)) ||
(waitForDevice.when === 'applicationMode' &&
deviceInfo?.dfuTriggerVersion) ||
deviceWithPersistedData.traits.nordicDfu &&
!isDeviceInDFUBootloader(
deviceWithPersistedData
)) ||
(selectedDevice &&
waitForDevice.when === 'sameTraits' &&
hasSameDeviceTraits(
Expand All @@ -292,7 +291,14 @@ export const startWatchingDevices =
);

dispatch(selectDevice(deviceWithPersistedData));
dispatch(setSelectedDeviceInfo(deviceInfo));

if (!waitForDevice.skipRefetchDeviceInfo) {
const deviceInfo =
await NrfutilDeviceLib.deviceInfo(
device
);
dispatch(setSelectedDeviceInfo(deviceInfo));
}

if (waitForDevice.onSuccess)
waitForDevice.onSuccess(
Expand Down

0 comments on commit fe2109f

Please sign in to comment.