Skip to content

Commit d357aad

Browse files
authored
Merge pull request #997 from pybricks/dlech
dfu firmware flashing
2 parents c105dee + 61a3f58 commit d357aad

File tree

88 files changed

+3206
-943
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+3206
-943
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/lib/CalledWithFn.js b/lib/CalledWithFn.js
2+
index 56674799caceb24951e71ab00f20eb53a52c5b6c..1aec49f8c67eb840dba54e937fe49f66a9c13872 100644
3+
--- a/lib/CalledWithFn.js
4+
+++ b/lib/CalledWithFn.js
5+
@@ -30,7 +30,7 @@ const calledWithFn = () => {
6+
fn.mockImplementation((...args) => checkCalledWith(calledWithStack, args));
7+
calledWithStack = [];
8+
}
9+
- calledWithStack.push({ args, calledWithFn });
10+
+ calledWithStack.unshift({ args, calledWithFn });
11+
return calledWithFn;
12+
};
13+
return fn;

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
### Added
88
- Added better error message when no files to backup ([support#681]).
9+
- Added multi-step firmware flashing dialog.
10+
- Added support for flashing firmware via USB DFU.
911

1012
### Fixed
1113
- Fixed deleting files that are not open in the editor.

package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
},
1010
"dependencies": {
1111
"@babel/core": "^7.18.9",
12-
"@blueprintjs/core": "^4.5.0",
12+
"@blueprintjs/core": "^4.6.1",
1313
"@blueprintjs/popover2": "^1.4.3",
14+
"@blueprintjs/select": "^4.5.0",
1415
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.7",
15-
"@pybricks/firmware": "4.17.0",
16+
"@pybricks/firmware": "5.0.0",
1617
"@pybricks/ide-docs": "2.2.0",
1718
"@pybricks/mpy-cross-v5": "^2.0.0",
1819
"@pybricks/mpy-cross-v6": "^2.0.0",
@@ -31,6 +32,7 @@
3132
"@types/react-splitter-layout": "^3.0.2",
3233
"@types/redux-logger": "^3.0.9",
3334
"@types/semver": "^7.3.10",
35+
"@types/w3c-web-usb": "^1.0.6",
3436
"@types/web-bluetooth": "^0.0.15",
3537
"@types/web-locks-api": "^0.0.2",
3638
"@types/wicg-file-system-access": "^2020.9.5",
@@ -53,6 +55,7 @@
5355
"dexie": "^3.2.2",
5456
"dexie-observable": "^4.0.0-beta.13",
5557
"dexie-react-hooks": "^1.1.1",
58+
"dfu": "^0.1.5",
5659
"dotenv": "^16.0.1",
5760
"dotenv-expand": "^8.0.3",
5861
"fake-indexeddb": "^4.0.0",
@@ -110,6 +113,7 @@
110113
"typed-redux-saga": "^1.5.0",
111114
"typescript": "~4.7.4",
112115
"usehooks-ts": "^2.6.0",
116+
"user-agent-data-types": "^0.3.0",
113117
"web-vitals": "^2.1.4",
114118
"webpack": "^5.73.0",
115119
"webpack-dev-server": "^4.9.3",
@@ -162,7 +166,8 @@
162166
"resolutions": {
163167
"[email protected]": "patch:mq-polyfill@npm:1.1.8#.yarn/patches/mq-polyfill-npm-1.1.8-62fe162439.patch",
164168
"react-error-overlay": "6.0.9",
165-
"react-dev-utils@^12.0.1": "patch:react-dev-utils@npm:12.0.1#.yarn/patches/react-dev-utils-npm-12.0.1-83ba06e3ee.patch"
169+
"react-dev-utils@^12.0.1": "patch:react-dev-utils@npm:12.0.1#.yarn/patches/react-dev-utils-npm-12.0.1-83ba06e3ee.patch",
170+
"jest-mock-extended@^2.0.7": "patch:jest-mock-extended@npm:2.0.7#.yarn/patches/jest-mock-extended-npm-2.0.7-4cdf066556.patch"
166171
},
167172
"jest": {
168173
"roots": [
@@ -189,7 +194,7 @@
189194
"^(?!.*\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.mjs"
190195
},
191196
"transformIgnorePatterns": [
192-
"[/\\\\]node_modules[/\\\\](?!(monaco-editor|react-monaco-editor)[/\\\\]).+\\.(js|jsx|mjs|cjs|ts|tsx)$",
197+
"[/\\\\]node_modules[/\\\\](?!(monaco-editor|react-monaco-editor|nanoevents)[/\\\\]).+\\.(js|jsx|mjs|cjs|ts|tsx)$",
193198
"^.+\\.module\\.(css|sass|scss)$"
194199
],
195200
"modulePaths": [],

src/alerts.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33

44
import { IToastProps } from '@blueprintjs/core';
55
import alerts from './alerts/alerts';
6+
import ble from './ble/alerts';
67
import explorer from './explorer/alerts';
8+
import firmware from './firmware/alerts';
79
import { CreateToast } from './i18nToaster';
810

911
/** This collects alerts from all of the subsystems of the app */
1012
const alertDomains = {
1113
alerts,
14+
ble,
1215
explorer,
16+
firmware,
1317
};
1418

1519
/** Gets the type of available alert domains. */

src/alerts/sagas.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ function* handleShowAlert(action: ReturnType<typeof alertsShowAlert>): Generator
3434

3535
try {
3636
const alertAction = yield* take(chan);
37+
// the dismiss actions will have called this already, but other actions don't
38+
toaster.dismiss(key);
3739

3840
yield* put(alertsDidShowAlert(action.domain, action.specific, alertAction));
3941
} finally {

src/app/constants.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
// Copyright (c) 2021 The Pybricks Authors
2+
// Copyright (c) 2021-2022 The Pybricks Authors
33

44
// Definitions for compile-time UI settings.
55

@@ -32,6 +32,12 @@ export const pybricksBugReportsUrl = 'https://github.com/pybricks/support/issues
3232
/** URL for Pybricks community chat on Gitter */
3333
export const pybricksGitterUrl = 'https://gitter.im/pybricks/community';
3434

35+
export const pybricksBluetoothTroubleshootingUrl =
36+
'https://github.com/pybricks/support/discussions/270';
37+
38+
export const pybricksUsbDfuTroubleshootingUrl =
39+
'https://github.com/pybricks/support/discussions/688';
40+
3541
/** Pybricks copyright statement. */
3642
export const pybricksCopyright = 'Copyright (c) 2020-2022 The Pybricks Authors';
3743

src/ble-device-info-service/protocol.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
// Copyright (c) 2021 The Pybricks Authors
2+
// Copyright (c) 2021-2022 The Pybricks Authors
33

44
import {
55
HubType,
@@ -8,7 +8,7 @@ import {
88
} from '../ble-lwp3-service/protocol';
99
import { decodePnpId, getHubTypeName } from './protocol';
1010

11-
function encodeInfo(id: HubType, variant?: number) {
11+
export function encodeInfo(id: HubType, variant?: number) {
1212
return new DataView(
1313
new Uint8Array([
1414
1, // Bluetooth SIG

src/ble-device-info-service/protocol.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
// Copyright (c) 2021 The Pybricks Authors
2+
// Copyright (c) 2021-2022 The Pybricks Authors
33
//
44
// Pybricks uses the standard Device Info service.
55
// Refer to Device Information Service (DIS) at https://www.bluetooth.com/specifications/specs/
@@ -13,7 +13,7 @@ import {
1313
} from '../ble-lwp3-service/protocol';
1414

1515
/** Device Information service UUID. */
16-
export const serviceUUID = 0x180a;
16+
export const deviceInformationServiceUUID = 0x180a;
1717

1818
/** Firmware Revision String characteristic UUID. */
1919
export const firmwareRevisionStringUUID = 0x2a26;
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
// Copyright (c) 2020 The Pybricks Authors
2+
// Copyright (c) 2020-2022 The Pybricks Authors
33
//
44
// Definitions related to the nRF UART Bluetooth low energy GATT service.
55
//
@@ -8,16 +8,16 @@
88
// https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/ble_sdk_app_nus_eval.html
99

1010
/** nRF UART Service UUID. */
11-
export const ServiceUUID = '6e400001-b5a3-f393-e0a9-e50e24dcca9e';
11+
export const nordicUartServiceUUID = '6e400001-b5a3-f393-e0a9-e50e24dcca9e';
1212

1313
/** nRF UART RX Characteristic UUID. Supports Write or Write without response. */
14-
export const RxCharUUID = '6e400002-b5a3-f393-e0a9-e50e24dcca9e';
14+
export const nordicUartRxCharUUID = '6e400002-b5a3-f393-e0a9-e50e24dcca9e';
1515

1616
/** nRF UART TX Characteristic UUID. Supports Notifications. */
17-
export const TxCharUUID = '6e400003-b5a3-f393-e0a9-e50e24dcca9e';
17+
export const nordicUartTxCharUUID = '6e400003-b5a3-f393-e0a9-e50e24dcca9e';
1818

1919
/**
2020
* This is the largest data size for the TX characteristic that is safe to use
2121
* when the negotiated MTU is unknown.
2222
*/
23-
export const SafeTxCharLength = 20;
23+
export const nordicUartSafeTxCharLength = 20;

src/ble-pybricks-service/protocol.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// SPDX-License-Identifier: MIT
2-
// Copyright (c) 2020-2021 The Pybricks Authors
2+
// Copyright (c) 2020-2022 The Pybricks Authors
33
//
44
// Definitions related to the Pybricks Bluetooth low energy GATT service.
55

66
import { assert } from '../utils';
77

88
/** Pybricks service UUID. */
9-
export const ServiceUUID = 'c5f50001-8280-46da-89f4-6d8051e4aeef';
9+
export const pybricksServiceUUID = 'c5f50001-8280-46da-89f4-6d8051e4aeef';
1010
/** Pybricks control characteristic UUID. */
11-
export const ControlCharacteristicUUID = 'c5f50002-8280-46da-89f4-6d8051e4aeef';
11+
export const pybricksControlCharacteristicUUID = 'c5f50002-8280-46da-89f4-6d8051e4aeef';
1212

1313
/** Commands are instructions sent to the hub. */
1414
export enum CommandType {

0 commit comments

Comments
 (0)