mirror of https://github.com/espruino/BangleApps
Fix apploader node.js app issues - invalid length when uploading (base64 encode issues) and path (when run from directory other than the root)
parent
4a5abd1cfd
commit
99dcd7868c
|
@ -78,8 +78,12 @@ function cmdListDevices() {
|
||||||
});
|
});
|
||||||
noble.startScanning([], true);
|
noble.startScanning([], true);
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
|
console.log("Stopping scan");
|
||||||
noble.stopScanning();
|
noble.stopScanning();
|
||||||
}, 2000);
|
setTimeout(function() {
|
||||||
|
process.exit(0);
|
||||||
|
}, 500);
|
||||||
|
}, 4000);
|
||||||
}
|
}
|
||||||
|
|
||||||
function cmdInstallApp(appId, deviceAddress) {
|
function cmdInstallApp(appId, deviceAddress) {
|
||||||
|
@ -88,7 +92,8 @@ function cmdInstallApp(appId, deviceAddress) {
|
||||||
if (app.custom) ERROR(`App ${JSON.stringify(appId)} requires HTML customisation`);
|
if (app.custom) ERROR(`App ${JSON.stringify(appId)} requires HTML customisation`);
|
||||||
return AppInfo.getFiles(app, {
|
return AppInfo.getFiles(app, {
|
||||||
fileGetter:function(url) {
|
fileGetter:function(url) {
|
||||||
return Promise.resolve(require("fs").readFileSync(url).toString());
|
console.log(__dirname+"/"+url);
|
||||||
|
return Promise.resolve(require("fs").readFileSync(__dirname+"/../"+url).toString());
|
||||||
}, settings : SETTINGS}).then(files => {
|
}, settings : SETTINGS}).then(files => {
|
||||||
//console.log(files);
|
//console.log(files);
|
||||||
var command = files.map(f=>f.cmd).join("\n")+"\n";
|
var command = files.map(f=>f.cmd).join("\n")+"\n";
|
||||||
|
@ -101,6 +106,7 @@ function bangleSend(command, deviceAddress) {
|
||||||
var args = [].slice.call(arguments);
|
var args = [].slice.call(arguments);
|
||||||
console.log("UART: "+args.join(" "));
|
console.log("UART: "+args.join(" "));
|
||||||
}
|
}
|
||||||
|
//console.log("Sending",JSON.stringify(command));
|
||||||
|
|
||||||
var RESET = true;
|
var RESET = true;
|
||||||
var DEVICEADDRESS = "";
|
var DEVICEADDRESS = "";
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
if (typeof btoa==="undefined") {
|
if (typeof btoa==="undefined") {
|
||||||
// Don't define btoa as a function here because Apple's
|
// Don't define btoa as a function here because Apple's
|
||||||
// iOS browser defines the function even though it's in
|
// iOS browser defines the function even though it's in
|
||||||
// an IF statement that is never executed!
|
// an IF statement that is never executed
|
||||||
btoa = function(d) { return Buffer.from(d).toString('base64'); }
|
btoa = function(d) { return Buffer.from(d,'binary').toString('base64'); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Converts a string into most efficient way to send to Espruino (either json, base64, or compressed base64)
|
// Converts a string into most efficient way to send to Espruino (either json, base64, or compressed base64)
|
||||||
|
|
Loading…
Reference in New Issue