WebBLE partial flashing experiment. (#1388)
* support for webble * more refactoring * updated check * flags * moving flashing to experiments * always have pairing mode * fix settings * added experiment image * bump pxt * add missing types * bump pxt
This commit is contained in:
parent
57c89eb49b
commit
82bf0e7107
BIN
docs/static/experiments/bluetoothPartialFlashing.png
vendored
Normal file
BIN
docs/static/experiments/bluetoothPartialFlashing.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 177 KiB |
@ -531,31 +531,27 @@ namespace pxt.editor {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function deployCoreAsync(resp: pxtc.CompileResult, d: pxt.commands.DeployOptions = {}): Promise<void> {
|
function uwpDeployCoreAsync(resp: pxtc.CompileResult, d: pxt.commands.DeployOptions = {}): Promise<void> {
|
||||||
const saveHexAsync = () => {
|
// Go straight to flashing
|
||||||
return pxt.commands.saveOnlyAsync(resp);
|
return flashAsync(resp, d);
|
||||||
};
|
}
|
||||||
return Promise.resolve()
|
|
||||||
.then(() => {
|
function deployCoreAsync(resp: pxtc.CompileResult, d: pxt.commands.DeployOptions = {}): Promise<void> {
|
||||||
const isUwp = !!(window as any).Windows;
|
return pxt.usb.isPairedAsync()
|
||||||
if (isUwp) {
|
.then(isPaired => {
|
||||||
// Go straight to flashing
|
if (isPaired) {
|
||||||
|
// Already paired from earlier in the session or from previous session
|
||||||
return flashAsync(resp, d);
|
return flashAsync(resp, d);
|
||||||
}
|
}
|
||||||
if (!pxt.usb.isEnabled) {
|
|
||||||
return saveHexAsync();
|
|
||||||
}
|
|
||||||
return pxt.usb.isPairedAsync()
|
|
||||||
.then((isPaired) => {
|
|
||||||
if (isPaired) {
|
|
||||||
// Already paired from earlier in the session or from previous session
|
|
||||||
return flashAsync(resp, d);
|
|
||||||
}
|
|
||||||
|
|
||||||
// No device paired, prompt user
|
// try bluetooth if device is paired
|
||||||
return saveHexAsync();
|
if (pxt.webBluetooth.isPaired())
|
||||||
});
|
return pxt.webBluetooth.flashAsync(resp, d)
|
||||||
})
|
.catch(e => pxt.commands.saveOnlyAsync(resp));
|
||||||
|
|
||||||
|
// No device paired, prompt user
|
||||||
|
return pxt.commands.saveOnlyAsync(resp);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -820,7 +816,10 @@ namespace pxt.editor {
|
|||||||
subclassCode: 0x03
|
subclassCode: 0x03
|
||||||
}])
|
}])
|
||||||
|
|
||||||
if (canHID())
|
const isUwp = !!(window as any).Windows;
|
||||||
|
if (isUwp)
|
||||||
|
pxt.commands.deployCoreAsync = uwpDeployCoreAsync;
|
||||||
|
else if (canHID() || pxt.webBluetooth.hasPartialFlash())
|
||||||
pxt.commands.deployCoreAsync = deployCoreAsync;
|
pxt.commands.deployCoreAsync = deployCoreAsync;
|
||||||
|
|
||||||
res.blocklyPatch = patchBlocks;
|
res.blocklyPatch = patchBlocks;
|
||||||
|
@ -72,7 +72,7 @@
|
|||||||
"microbit-dal": {
|
"microbit-dal": {
|
||||||
"bluetooth": {
|
"bluetooth": {
|
||||||
"open": 1,
|
"open": 1,
|
||||||
"pairing_mode": 0,
|
"pairing_mode": null,
|
||||||
"whitelist": 0,
|
"whitelist": 0,
|
||||||
"security_level": null
|
"security_level": null
|
||||||
}
|
}
|
||||||
@ -98,7 +98,7 @@
|
|||||||
"microbit-dal": {
|
"microbit-dal": {
|
||||||
"bluetooth": {
|
"bluetooth": {
|
||||||
"open": 0,
|
"open": 0,
|
||||||
"pairing_mode": 1,
|
"pairing_mode": null,
|
||||||
"whitelist": 1,
|
"whitelist": 1,
|
||||||
"security_level": "SECURITY_MODE_ENCRYPTION_WITH_MITM"
|
"security_level": "SECURITY_MODE_ENCRYPTION_WITH_MITM"
|
||||||
}
|
}
|
||||||
|
@ -38,10 +38,11 @@
|
|||||||
"@types/bluebird": "2.0.33",
|
"@types/bluebird": "2.0.33",
|
||||||
"@types/jquery": "3.2.16",
|
"@types/jquery": "3.2.16",
|
||||||
"@types/marked": "0.3.0",
|
"@types/marked": "0.3.0",
|
||||||
"@types/node": "8.0.53"
|
"@types/node": "8.0.53",
|
||||||
|
"@types/web-bluetooth": "0.0.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"pxt-common-packages": "0.24.2",
|
"pxt-common-packages": "0.24.2",
|
||||||
"pxt-core": "4.1.28"
|
"pxt-core": "4.1.30"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -275,7 +275,8 @@
|
|||||||
"allowPackageExtensions",
|
"allowPackageExtensions",
|
||||||
"instructions",
|
"instructions",
|
||||||
"debugger",
|
"debugger",
|
||||||
"bluetoothUartConsole"
|
"bluetoothUartConsole",
|
||||||
|
"bluetoothPartialFlashing"
|
||||||
],
|
],
|
||||||
"bluetoothUartFilters": [{
|
"bluetoothUartFilters": [{
|
||||||
"namePrefix": "BBC micro:bit"
|
"namePrefix": "BBC micro:bit"
|
||||||
|
Loading…
Reference in New Issue
Block a user