diff --git a/js/appinfo.js b/js/appinfo.js index 5562169..191133f 100644 --- a/js/appinfo.js +++ b/js/appinfo.js @@ -5,9 +5,6 @@ if ("undefined"!=typeof module) { heatshrink = require("../../webtools/heatshrink.js"); } -// How many bytes of code to we attempt to upload in one go? -const CHUNKSIZE = 1024; - // Converts a string into most efficient way to send to Espruino (either json, base64, or compressed base64) function asJSExpr(txt, options) { /* options = { @@ -175,8 +172,12 @@ function parseJS(storageFile, options, app) { var AppInfo = { /* Get a list of commands needed to upload the file */ getFileUploadCommands : (filename, data) => { + const CHUNKSIZE = Const.UPLOAD_CHUNKSIZE; if (Const.FILES_IN_FS) { - return `\n\x10require('fs').writeFileSync(${JSON.stringify(filename)},${asJSExpr(data)});`; + let cmd = `\x10require('fs').writeFileSync(${JSON.stringify(filename)},${asJSExpr(data.substr(0,CHUNKSIZE))});`; + for (let i=CHUNKSIZE;i { + const CHUNKSIZE = Const.UPLOAD_CHUNKSIZE; var cmd = ""; // write code in chunks, in case it is too big to fit in RAM (fix #157) function getWriteData(offset) { diff --git a/js/utils.js b/js/utils.js index 6db3e00..b2282b5 100644 --- a/js/utils.js +++ b/js/utils.js @@ -35,6 +35,9 @@ const Const = { /* If true, store files using 'fs' module which is a FAT filesystem on SD card, not on internal Storage */ FILES_IN_FS : false, + /* How many bytes of code to we attempt to upload in one go? */ + UPLOAD_CHUNKSIZE: 1024, + /* Don't try and reset the device when we're connecting/sending apps */ NO_RESET : false,