Skip to content

Commit bdbfa11

Browse files
WebUSB: Allocate board ID after connection.
1 parent d2bdb52 commit bdbfa11

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

js/partial-flashing.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ class DAPWrapper {
172172
this.reconnected = false;
173173
this.flashing = true;
174174
this.device = device;
175-
this.allocBoardID();
176175
this.allocDAP();
177176
}
178177

@@ -183,11 +182,6 @@ class DAPWrapper {
183182
}
184183
this.boardId = this.device.serialNumber.substring(0,4);
185184
PartialFlashingUtils.log("Detected board ID " + this.boardId);
186-
document.dispatchEvent(new CustomEvent("webusb", { detail: {
187-
"flash-type": "partial-flash",
188-
"event-type": "info",
189-
"message": "board-id/" + this.boardId,
190-
}}));
191185
}
192186

193187
allocDAP() {
@@ -209,7 +203,8 @@ class DAPWrapper {
209203
}
210204
return p
211205
.then(() => self.daplink.connect())
212-
.then(() => self.cortexM.connect());
206+
.then(() => self.cortexM.connect())
207+
.then(() => self.allocBoardID());
213208
}
214209

215210
disconnectAsync() {

js/python-main.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,11 @@ function web_editor(config) {
12451245
'event-type': 'info',
12461246
'message': 'connected'
12471247
}}));
1248+
document.dispatchEvent(new CustomEvent('webusb', { detail: {
1249+
'flash-type': 'webusb',
1250+
'event-type': 'info',
1251+
'message': 'board-id/' + window.dapwrapper.boardId,
1252+
}}));
12481253

12491254
// Update the Editor autocompletion MicroPython PI based on the board connected
12501255
var boardApi = microPythonApi.getCompatibleMicroPythonApi(window.dapwrapper.boardId);

0 commit comments

Comments
 (0)