Skip to content

Commit 5593156

Browse files
WebUSB: Dispatch event on WebUSB connection.
1 parent cd48bae commit 5593156

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

python-main.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,12 +1236,19 @@ function web_editor(config) {
12361236
// Connect to board
12371237
return window.daplink.connect();
12381238
})
1239-
.then(() => {
1240-
console.log("Connection Complete");
1239+
.then(function() {
1240+
console.log('Connection Complete');
12411241
});
12421242
}
12431243

12441244
return p.then(function() {
1245+
// Dispatch event for listeners
1246+
document.dispatchEvent(new CustomEvent('webusb', { 'detail': {
1247+
'flash-type': 'webusb',
1248+
'event-type': 'info',
1249+
'message': 'connected'
1250+
}}));
1251+
12451252
// Change button to disconnect
12461253
$("#command-connect").hide();
12471254
$("#command-disconnect").show();
@@ -1380,8 +1387,8 @@ function web_editor(config) {
13801387
}
13811388
}
13821389

1383-
p.finally(() => {
1384-
console.log("Disconnection Complete");
1390+
p.finally(function() {
1391+
console.log('Disconnection Complete');
13851392
});
13861393

13871394
return p;

0 commit comments

Comments
 (0)