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:
		@@ -531,31 +531,27 @@ namespace pxt.editor {
 | 
			
		||||
        })
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    export function deployCoreAsync(resp: pxtc.CompileResult, d: pxt.commands.DeployOptions = {}): Promise<void> {
 | 
			
		||||
        const saveHexAsync = () => {
 | 
			
		||||
            return pxt.commands.saveOnlyAsync(resp);
 | 
			
		||||
        };
 | 
			
		||||
        return Promise.resolve()
 | 
			
		||||
            .then(() => {
 | 
			
		||||
                const isUwp = !!(window as any).Windows;
 | 
			
		||||
                if (isUwp) {
 | 
			
		||||
                    // Go straight to flashing
 | 
			
		||||
    function uwpDeployCoreAsync(resp: pxtc.CompileResult, d: pxt.commands.DeployOptions = {}): Promise<void> {
 | 
			
		||||
        // Go straight to flashing
 | 
			
		||||
        return flashAsync(resp, d);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function deployCoreAsync(resp: pxtc.CompileResult, d: pxt.commands.DeployOptions = {}): Promise<void> {
 | 
			
		||||
        return pxt.usb.isPairedAsync()
 | 
			
		||||
            .then(isPaired => {
 | 
			
		||||
                if (isPaired) {
 | 
			
		||||
                    // Already paired from earlier in the session or from previous session
 | 
			
		||||
                    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
 | 
			
		||||
                        return saveHexAsync();
 | 
			
		||||
                    });
 | 
			
		||||
            })
 | 
			
		||||
                // try bluetooth if device is paired
 | 
			
		||||
                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
 | 
			
		||||
        }])
 | 
			
		||||
 | 
			
		||||
        if (canHID())
 | 
			
		||||
        const isUwp = !!(window as any).Windows;
 | 
			
		||||
        if (isUwp)
 | 
			
		||||
            pxt.commands.deployCoreAsync = uwpDeployCoreAsync;
 | 
			
		||||
        else if (canHID() || pxt.webBluetooth.hasPartialFlash())
 | 
			
		||||
            pxt.commands.deployCoreAsync = deployCoreAsync;
 | 
			
		||||
 | 
			
		||||
        res.blocklyPatch = patchBlocks;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user