I am trying to call the downloadFirmwareBinary() method to download the binary after calling compileCode(), the compile succeeds, but the download does not. My code which I am executing with node is currently:
/*jslint node: true */
"use strict";
var auth = require('./auth.js');
var Particle = require('particle-api-js');
var fs = require('fs');
var particle = new Particle();
particle.compileCode({
files: {
'tinker.ino': './tinker.ino'
},
platformId: 6,
auth: auth.token
}).then(
function(data) {
console.log('Compile succeeded: ' + data.body.binary_id);
var request = particle.downloadFirmwareBinary({
binaryId: data.body.binary_id,
auth: auth.token
});
console.log('Writing file');
var wstream = fs.createWriteStream('./test3.bin');
request.pipe(wstream);
wstream.end();
console.log("Done");
},
function(err) {
console.log('An error occurred while compiling the code:', err);
});
auth.js contains:
module.exports = {
token: '<my token>'
};
I see nothing in the console after the ‘Compile suceeded’ message, the program exits normally, but no file is generated. The use of request.pipe is based on piping data. Can anyone help?
Chris