diff --git a/lib/controller.js b/lib/controller.js index d2750753..c73c11d9 100644 --- a/lib/controller.js +++ b/lib/controller.js @@ -560,13 +560,13 @@ controller.restoreTessel = function(opts) { opts.usb = true; opts.lan = false; opts.altSetting = 1; - return controller.get(opts).then(function(tessel) { - return new Promise(function(resolve, reject) { + return controller.get(opts).then((tessel) => { + return new Promise((resolve, reject) => { tessel.restore(opts) - .then(function(result) { + .then((result) => { resolve(result); }) - .catch(function(err) { + .catch((err) => { reject(err); }); }); diff --git a/lib/flash.js b/lib/flash.js index 978d355c..55fb62e6 100644 --- a/lib/flash.js +++ b/lib/flash.js @@ -38,7 +38,7 @@ function transaction(usbConnection, write, read, status_poll, wren, next) { var data = concatToBuffer(hdr, write); - usbConnection.epOut.transfer(data, function(err) { + usbConnection.epOut.transfer(data, (err) => { if (err) { return next(err); } @@ -71,7 +71,7 @@ function eraseChip(usbConnection, next) { // Poll for the WIP bit in the status register to go low function waitTransactionComplete(usbConnection, next) { setTimeout(function onWait() { - getStatus(usbConnection, function onGetStatus(err, status) { + getStatus(usbConnection, (err, status) => { if (err) { return next(err); } @@ -85,7 +85,7 @@ function waitTransactionComplete(usbConnection, next) { // Read the status register function getStatus(usbConnection, next) { - transaction(usbConnection, [0x05], 1, null, null, function onGetStatus(err, data) { + transaction(usbConnection, [0x05], 1, null, null,(err, data) => { next(err, data ? data[0] : data); }); } @@ -101,7 +101,7 @@ function write(usbConnection, writeAddress, data, sliceStart, next) { var sliceEnd = sliceStart + PAGE; var pageData = data.slice(sliceStart, sliceEnd); - writePage(usbConnection, writeAddress, pageData, function onWrite(err) { + writePage(usbConnection, writeAddress, pageData, (err) => { if (err) { return next(err); } diff --git a/lib/tessel/restore.js b/lib/tessel/restore.js index 48ccd7bf..715c6e64 100644 --- a/lib/tessel/restore.js +++ b/lib/tessel/restore.js @@ -14,19 +14,17 @@ Tessel.prototype.restore = function restore() { var usbConnection = this.connection; return new Promise((resolve, reject) => { - log.info('Proceeding with updating OpenWrt...'); + log.info('Proceeding with updating OpenWrt...'); - // download images - return update.fetchRestore() - .then((result) => { - flash(usbConnection, result.uboot, result.squashfs, (err) => { - if (err) { - return reject(err); - } - resolve(); - }); + // download images + return update.fetchRestore() + .then((result) => { + flash(usbConnection, result.uboot, result.squashfs, (err) => { + if (err) { + return reject(err); + } + resolve(); }); - - + }); }); };