diff --git a/src/assets/files/docs-usb-setup-firmware/argon.bin b/src/assets/files/docs-usb-setup-firmware/argon.bin index 824ccd0414..b16bebdc55 100644 Binary files a/src/assets/files/docs-usb-setup-firmware/argon.bin and b/src/assets/files/docs-usb-setup-firmware/argon.bin differ diff --git a/src/assets/files/docs-usb-setup-firmware/b5som.bin b/src/assets/files/docs-usb-setup-firmware/b5som.bin index 3e47026ced..51d63b1c0e 100644 Binary files a/src/assets/files/docs-usb-setup-firmware/b5som.bin and b/src/assets/files/docs-usb-setup-firmware/b5som.bin differ diff --git a/src/assets/files/docs-usb-setup-firmware/boron.bin b/src/assets/files/docs-usb-setup-firmware/boron.bin index edadf0ce9e..e285978a57 100644 Binary files a/src/assets/files/docs-usb-setup-firmware/boron.bin and b/src/assets/files/docs-usb-setup-firmware/boron.bin differ diff --git a/src/assets/files/docs-usb-setup-firmware/bsom.bin b/src/assets/files/docs-usb-setup-firmware/bsom.bin index c9f7ef4080..d9e7443abb 100644 Binary files a/src/assets/files/docs-usb-setup-firmware/bsom.bin and b/src/assets/files/docs-usb-setup-firmware/bsom.bin differ diff --git a/src/assets/files/docs-usb-setup-firmware/electron.bin b/src/assets/files/docs-usb-setup-firmware/electron.bin index 6b7768dfa3..0ee69e9381 100644 Binary files a/src/assets/files/docs-usb-setup-firmware/electron.bin and b/src/assets/files/docs-usb-setup-firmware/electron.bin differ diff --git a/src/assets/files/docs-usb-setup-firmware/p1.bin b/src/assets/files/docs-usb-setup-firmware/p1.bin index 5f3d6acaf1..6b0a12b094 100644 Binary files a/src/assets/files/docs-usb-setup-firmware/p1.bin and b/src/assets/files/docs-usb-setup-firmware/p1.bin differ diff --git a/src/assets/files/docs-usb-setup-firmware/photon.bin b/src/assets/files/docs-usb-setup-firmware/photon.bin index 56274be490..0e42df6bda 100644 Binary files a/src/assets/files/docs-usb-setup-firmware/photon.bin and b/src/assets/files/docs-usb-setup-firmware/photon.bin differ diff --git a/src/assets/files/versionInfo.json b/src/assets/files/versionInfo.json index 48416144ff..56d1bb0b97 100644 --- a/src/assets/files/versionInfo.json +++ b/src/assets/files/versionInfo.json @@ -661,5 +661,5 @@ "semVer": "3.2.0-rc.1" } ], - "updated": 1641413166 + "updated": 1641919517 } \ No newline at end of file diff --git a/src/assets/js/device-restore-dfu.js b/src/assets/js/device-restore-dfu.js index 29eb01fc0d..3d9a399ea4 100644 --- a/src/assets/js/device-restore-dfu.js +++ b/src/assets/js/device-restore-dfu.js @@ -75,7 +75,6 @@ async function dfuDeviceRestore(usbDevice, options) { resolve(); }) .catch(function(err) { - console.log('error', err); setStatus(); reject(); }); @@ -359,6 +358,7 @@ async function dfuDeviceRestore(usbDevice, options) { */ dfuseDevice.logInfo = function(msg) { + console.log(msg); // TEMPORARY }; return dfuseDevice; @@ -370,10 +370,10 @@ async function dfuDeviceRestore(usbDevice, options) { { name: 'system-part1', title: 'Device OS System Part 1' }, { name: 'system-part2', title: 'Device OS System Part 2' }, { name: 'system-part3', title: 'Device OS System Part 3' }, - { name: 'bootloader', title: 'Device OS Bootloader' }, { name: 'softdevice', title: 'nRF52 Soft Device' }, { name: 'tinker', reset:true, title: 'User Firmware' }, - { name: 'tracker-edge', reset:true, title: 'Tracker Edge Firmware' } + { name: 'tracker-edge', reset:true, title: 'Tracker Edge Firmware' }, + { name: 'bootloader', title: 'Device OS Bootloader' }, ]; let dfuParts = []; @@ -479,13 +479,6 @@ async function dfuDeviceRestore(usbDevice, options) { dfuseDevice.startAddress = 0x80C0000; await dfuseDevice.do_download(4096, part, {}); } - if (options.progressUpdate) { - options.progressUpdate('', 100, { - func: 'program', - pct: 100, - partName - }); - } } else if (options.userFirmwareBinary && (partName == 'tinker' || partName == 'tracker-edge')) { @@ -595,7 +588,7 @@ async function dfuDeviceRestore(usbDevice, options) { if (options.progressShowHide) { options.progressShowHide(false); } - + await dfuseAltDevice.close(); } diff --git a/src/assets/js/device-setup-usb.js b/src/assets/js/device-setup-usb.js index 1f6f5b13ca..3e0d9d1e21 100644 --- a/src/assets/js/device-setup-usb.js +++ b/src/assets/js/device-setup-usb.js @@ -346,6 +346,8 @@ $(document).ready(function() { let alreadyOwned = false; let clockTimer; let clockStart; + let functionStart = new Date(); + let hasResetModem = false; const showStep = function(step) { $(thisElem).find('.setupStepActivateSim').children().each(function() { @@ -407,66 +409,76 @@ $(document).ready(function() { $(thisElem).find('.continueWithoutActivating').on('click', nextStep); + while(true) { try { - reqObj = { - op: 'cellularInfo' - } - if (setupOptions.simSelection) { - reqObj.simSelection = setupOptions.simSelection; - } + if (!deviceInfo.iccid) { - const res = await usbDevice.sendControlRequest(10, JSON.stringify(reqObj)); - if (res.result || !res.data) { - await new Promise(function(resolve) { - setTimeout(function() { - resolve(); - }, 5000); - }); - continue; - } - - const respObj = JSON.parse(res.data); - if (!respObj.iccid) { - showStep('setupStepActivateSimGetSlow'); + console.log('getting cellularInfo'); - reqObj = { - op: 'cellularReset' + let reqObj = { + op: 'cellularInfo' } - await usbDevice.sendControlRequest(10, JSON.stringify(reqObj)); - - await new Promise(function(resolve) { - setTimeout(function() { - resolve(); - }, 5000); - }); - continue; - } - - deviceInfo.iccid = respObj.iccid; - console.log('iccid=' + deviceInfo.iccid); - - showInfoTable(); - setInfoTableItem('deviceId', deviceInfo.deviceId); - setInfoTableItemObj(respObj); - - $(thisElem).find('.batteryWarning').hide(); - if (respObj.model) { - if (respObj.model.startsWith('SARA-R') || respObj.model.startsWith('BG9')) { - // LTE model, does not require a battery + if (setupOptions.simSelection) { + reqObj.simSelection = setupOptions.simSelection; } - else { - // Non-LTE model - if (respObj.soc <= 0) { - $(thisElem).find('.batteryWarning').show(); + + const res = await usbDevice.sendControlRequest(10, JSON.stringify(reqObj)); + if (res.result || !res.data) { + await new Promise(function(resolve) { + setTimeout(function() { + resolve(); + }, 5000); + }); + continue; + } + + const respObj = JSON.parse(res.data); + if (!respObj.iccid) { + console.log('no iccid in cellularInfo'); + if (!hasResetModem) { + hasResetModem = true; + if (((new Date().getTime() - functionStart.getTime()) / 1000) > 50) { + showStep('setupStepActivateSimGetSlow'); + + reqObj = { + op: 'cellularReset' + } + await usbDevice.sendControlRequest(10, JSON.stringify(reqObj)); + } + } + + await new Promise(function(resolve) { + setTimeout(function() { + resolve(); + }, 5000); + }); + continue; + } + + deviceInfo.iccid = respObj.iccid; + + showInfoTable(); + setInfoTableItem('deviceId', deviceInfo.deviceId); + setInfoTableItemObj(respObj); + + $(thisElem).find('.batteryWarning').hide(); + if (respObj.model) { + if (respObj.model.startsWith('SARA-R') || respObj.model.startsWith('BG9')) { + // LTE model, does not require a battery } + else { + // Non-LTE model + if (respObj.soc <= 0) { + $(thisElem).find('.batteryWarning').show(); + } + } + } + showStep('setupStepActivateSimChecking'); } - - showStep('setupStepActivateSimChecking'); - let checkSimUrl; if (setupOptions.addToProduct) { @@ -536,6 +548,7 @@ $(document).ready(function() { needToActivate = true; } else { + setSetupStep('setupStepSimActivationFailed'); console.log('exception', e); break; } @@ -546,8 +559,10 @@ $(document).ready(function() { try { setStatus('Activating SIM...'); - clockStart = new Date(); - startClock(); + if (!clockStart) { + clockStart = new Date(); + startClock(); + } const stor = { deviceId: deviceInfo.deviceId, @@ -569,22 +584,25 @@ $(document).ready(function() { } catch(e) { - setSetupStep('setupStepSimActivationFailed'); - // if (e.message.includes('408')) { // activation in progress - // 403 if SIM is a product SIM I think - console.log('exception', e); - break; + if (e.message.includes('408')) { + // Activation in progress, check again in 30 seconds + } + else { + setSetupStep('setupStepSimActivationFailed'); + // 403 if SIM is a product SIM I think + console.log('exception', e); + break; + } + } } - else { - // Wait a bit to try again - await new Promise(function(resolve) { - setTimeout(function() { - resolve(); - }, 30000); - }); - } - + + // Wait a bit to try again + await new Promise(function(resolve) { + setTimeout(function() { + resolve(); + }, 30000); + }); } if (clockTimer) { @@ -593,6 +611,82 @@ $(document).ready(function() { }; + + const reconnectToDevice = async function() { + + setSetupStep('setupStepReconnecting'); + + let nativeUsbDevice; + + const showStep = function(step) { + $(thisElem).find('.setupStepReconnecting').children().each(function() { + $(this).hide(); + }); + $(thisElem).find('.' + step).show(); + } + showStep('setupStepReconnectingWaiting'); + + for(let tries = 0; tries < 4 && !nativeUsbDevice; tries++) { + + await new Promise(function(resolve) { + setTimeout(function() { + resolve(); + }, 3000); + }); + + try { + const nativeUsbDevices = await navigator.usb.getDevices(); + + if (nativeUsbDevices.length > 0) { + for(let dev of nativeUsbDevices) { + if (dev.serialNumber == deviceInfo.deviceId) { + nativeUsbDevice = dev; + break; + } + } + } + } + catch(e) { + console.log('exception getting USB devices', e); + } + + } + + + if (!nativeUsbDevice) { + showStep('setupStepReconnectingNeedReauthorize'); + + await new Promise(function(resolve, reject) { + const filters = [ + {vendorId: 0x2b04} + ]; + + $(thisElem).find('.reconnectUsb').on('click', async function() { + + $(thisElem).find('.reconnectUsb').prop('disabled', true); + + nativeUsbDevice = await navigator.usb.requestDevice({ filters: filters }) + + $(thisElem).find('.reconnectUsb').prop('disabled', false); + + $(thisElem).find('.reconnectUsb').off('click'); + resolve(); + }); + + }); + } + + usbDevice = await ParticleUsb.openDeviceById(nativeUsbDevice, {}); + + + reqObj = { + op: 'noAutoConnect', + }; + await usbDevice.sendControlRequest(10, JSON.stringify(reqObj)); + + }; + + const flashDevice = async function() { try { setSetupStep('setupStepFlashDevice'); @@ -722,95 +816,36 @@ $(document).ready(function() { const restoreResult = await dfuDeviceRestore(usbDevice, options); if (restoreResult.ok) { - await reconnectToDevice(); - - - if (deviceInfo.wifi) { - - configureWiFi(); - } - else { - activateSim(); - } } else { - console.log('do something for dfu error', restoreResult); + console.log('dfu error', restoreResult); } } catch(e) { console.log('exception', e); } - }; - - const continueDfuElem = $(thisElem).find('.continueDfu'); - $(continueDfuElem).on('click', flashDevice); - - const reconnectToDevice = async function() { - setSetupStep('setupStepReconnecting'); - - let nativeUsbDevice; - - const showStep = function(step) { - $(thisElem).find('.setupStepReconnecting').children().each(function() { - $(this).hide(); - }); - $(thisElem).find('.' + step).show(); - } - showStep('setupStepReconnectingWaiting'); - for(let tries = 0; tries < 4 && !nativeUsbDevice; tries++) { - await new Promise(function(resolve) { - setTimeout(function() { - resolve(); - }, 3000); - }); - - try { - const nativeUsbDevices = await navigator.usb.getDevices() + // Wait a little extra before trying to reconnect + await new Promise(function(resolve) { + setTimeout(function() { + resolve(); + }, 3000); + }); - if (nativeUsbDevices.length > 0) { - for(let dev of nativeUsbDevices) { - if (dev.serialNumber == deviceInfo.deviceId) { - nativeUsbDevice = dev; - break; - } - } - } - } - catch(e) { - console.log('exception getting USB devices', e); - } + await reconnectToDevice(); + if (deviceInfo.wifi) { + configureWiFi(); } - - - if (!nativeUsbDevice) { - showStep('setupStepReconnectingNeedReauthorize'); - - await new Promise(function(resolve, reject) { - const filters = [ - {vendorId: 0x2b04} - ]; - - $(thisElem).find('.reconnectUsb').on('click', async function() { - - $(thisElem).find('.reconnectUsb').prop('disabled', true); - - nativeUsbDevice = await navigator.usb.requestDevice({ filters: filters }) - - $(thisElem).find('.reconnectUsb').prop('disabled', false); - - $(thisElem).find('.reconnectUsb').off('click'); - resolve(); - }); - - }); + else { + activateSim(); } - - usbDevice = await ParticleUsb.openDeviceById(nativeUsbDevice, {}); }; + const continueDfuElem = $(thisElem).find('.continueDfu'); + $(continueDfuElem).on('click', flashDevice); + const addToProduct = async function() { setSetupStep('setupStepAddToProduct'); @@ -834,7 +869,7 @@ $(document).ready(function() { }); } - flashDevice(); + await flashDevice(); }; @@ -904,7 +939,7 @@ $(document).ready(function() { }); - $(thisElem).find('.setupSetupDeviceButton').on('click', function() { + $(thisElem).find('.setupSetupDeviceButton').on('click', async function() { deviceInfo.targetVersion = $(setupDeviceOsVersionElem).val(); setupOptions.noClaim = $(setupNoClaimElem).prop('checked'); @@ -916,10 +951,10 @@ $(document).ready(function() { } if (setupOptions.addToProduct) { - addToProduct(); + await addToProduct(); } else { - flashDevice(); + await flashDevice(); } }); @@ -1204,7 +1239,21 @@ $(document).ready(function() { $(deviceLogsElem).show(); - const timer = setInterval(async function() { + let timer1; + let timer2; + + const clearTimers = function() { + if (timer1) { + clearInterval(timer1); + timer1 = null; + } + if (timer2) { + clearInterval(timer2); + timer2 = null; + } + } + + timer1 = setInterval(async function() { let reqObj = { op: 'status' }; @@ -1215,7 +1264,7 @@ $(document).ready(function() { } catch(e) { if (e.message.includes('The device was disconnected.')) { - clearInterval(timer); + clearTimers(); } else { console.log('control request exception', e); } @@ -1229,13 +1278,6 @@ $(document).ready(function() { checkStatus(respObj); } - if (respObj.logs) { - deviceLogs += respObj.logs; - if ($(showDebuggingLogsElem).prop('checked')) { - $(deviceLogsTextElem).val(deviceLogs); - deviceLogsTextElem.scrollTop(deviceLogsTextElem[0].scrollHeight - deviceLogsTextElem.height()); - } - } if (respObj.mcc) { setInfoTableItemObj(respObj); @@ -1248,8 +1290,37 @@ $(document).ready(function() { } } } - }, 1000); + }, 2000); + timer2 = setInterval(async function() { + let reqObj = { + op: 'logs' + }; + + let res; + try { + res = await usbDevice.sendControlRequest(10, JSON.stringify(reqObj)); + } + catch(e) { + if (e.message.includes('The device was disconnected.')) { + clearTimers(); + } else { + console.log('control request exception', e); + } + return; + } + + if (res.result == 0 && res.data) { + if (res.data.length > 0) { + deviceLogs += res.data; + if ($(showDebuggingLogsElem).prop('checked')) { + $(deviceLogsTextElem).val(deviceLogs); + deviceLogsTextElem.scrollTop(deviceLogsTextElem[0].scrollHeight - deviceLogsTextElem.height()); + } + } + } + }, 1000); + const waitOnlineStepsElem = $(thisElem).find('.waitOnlineSteps'); // waitOnlineSteps @@ -1452,6 +1523,13 @@ $(document).ready(function() { const setupDone = async function() { setSetupStep('setupStepDone'); + + if (setupOptions.addToProduct) { + $(thisElem).find('.setupStepDoneNonProduct').hide(); + } + else { + $(thisElem).find('.setupStepDoneNonProduct').show(); + } }; diff --git a/templates/partials/device-setup-usb.hbs b/templates/partials/device-setup-usb.hbs index cd51413227..7e1fba0057 100644 --- a/templates/partials/device-setup-usb.hbs +++ b/templates/partials/device-setup-usb.hbs @@ -237,16 +237,18 @@