use codebender to compile sketches
I had codebender username/password included originally but compiling works without. Codebender usage guidelines allow "usage via API".
This commit is contained in:
@@ -1,18 +1,18 @@
|
|||||||
const gwType = 'Ethernet';
|
//const gwType = 'Ethernet';
|
||||||
const gwAddress = '10.0.1.99';
|
//const gwAddress = '10.0.1.99';
|
||||||
const gwPort = 9999;
|
//const gwPort = 9999;
|
||||||
|
|
||||||
//const gwType = 'Serial';
|
const gwType = 'Serial';
|
||||||
//const gwPort = 'COM4';
|
//const gwPort = 'COM4';
|
||||||
//const gwPort = '/dev/ttyUSB0';
|
const gwPort = '/dev/ttyAMA0';
|
||||||
//const gwBaud = 115200;
|
const gwBaud = 115200;
|
||||||
|
|
||||||
const dbAddress = '127.0.0.1';
|
const dbAddress = '127.0.0.1';
|
||||||
const dbPort = 27017;
|
const dbPort = 27017;
|
||||||
const dbName = 'MySensorsDb';
|
const dbName = 'MySensorsDb';
|
||||||
|
|
||||||
const fwHexFiles = [ ];
|
const fwSketches = [ '../libraries/MySensors/examples/DallasTemperatureSensor/DallasTemperatureSensor.ino' ];
|
||||||
const fwDefaultType = 0xFFFF; // index of hex file from array above (0xFFFF == none defined)
|
const fwDefaultType = 0; // index of hex file from array above
|
||||||
|
|
||||||
const FIRMWARE_BLOCK_SIZE = 16;
|
const FIRMWARE_BLOCK_SIZE = 16;
|
||||||
const BROADCAST_ADDRESS = 255;
|
const BROADCAST_ADDRESS = 255;
|
||||||
@@ -117,6 +117,8 @@ const P_ULONG32 = 5;
|
|||||||
const P_CUSTOM = 6;
|
const P_CUSTOM = 6;
|
||||||
|
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
|
var path = require('path');
|
||||||
|
var requestify = require('requestify');
|
||||||
var appendedString="";
|
var appendedString="";
|
||||||
|
|
||||||
function crcUpdate(old, value) {
|
function crcUpdate(old, value) {
|
||||||
@@ -146,13 +148,32 @@ function pushDWord(arr, val) {
|
|||||||
arr.push((val >> 24) & 0x000000FF);
|
arr.push((val >> 24) & 0x000000FF);
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadFirmware(fwtype, fwversion, filename, db) {
|
function loadFirmware(fwtype, fwversion, sketch, db) {
|
||||||
|
var filename = path.basename(sketch);
|
||||||
|
console.log("compiling firmware: " + filename);
|
||||||
|
var req = {
|
||||||
|
files: [{
|
||||||
|
filename: filename,
|
||||||
|
content: fs.readFileSync(sketch).toString()
|
||||||
|
}],
|
||||||
|
format: "hex",
|
||||||
|
version: "105",
|
||||||
|
build: {
|
||||||
|
mcu: "atmega328p",
|
||||||
|
f_cpu: "16000000L",
|
||||||
|
core: "arduino",
|
||||||
|
variant: "standard"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
requestify.post('https://codebender.cc/utilities/compile/', req).then(function(res) {
|
||||||
|
var body = JSON.parse(res.getBody());
|
||||||
|
if (body.success) {
|
||||||
console.log("loading firmware: " + filename);
|
console.log("loading firmware: " + filename);
|
||||||
fwdata = [];
|
fwdata = [];
|
||||||
var start = 0;
|
var start = 0;
|
||||||
var end = 0;
|
var end = 0;
|
||||||
var pos = 0;
|
var pos = 0;
|
||||||
var hex = fs.readFileSync(filename).toString().split("\n");
|
var hex = body.output.split("\n");
|
||||||
for(l in hex) {
|
for(l in hex) {
|
||||||
line = hex[l].trim();
|
line = hex[l].trim();
|
||||||
if (line.length > 0) {
|
if (line.length > 0) {
|
||||||
@@ -216,6 +237,10 @@ function loadFirmware(fwtype, fwversion, filename, db) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
console.log("loading firmware done. blocks: " + blocks + " / crc: " + crc);
|
console.log("loading firmware done. blocks: " + blocks + " / crc: " + crc);
|
||||||
|
} else {
|
||||||
|
console.log("error: %j", res.body);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -645,8 +670,8 @@ dbc.connect('mongodb://' + dbAddress + ':' + dbPort + '/' + dbName, function(err
|
|||||||
db.createCollection('firmware', function(err, collection) { });
|
db.createCollection('firmware', function(err, collection) { });
|
||||||
|
|
||||||
// ToDo : check for new hex files / only load if new / get type and version from filename
|
// ToDo : check for new hex files / only load if new / get type and version from filename
|
||||||
for (var i = 0; i < fwHexFiles.length; i++)
|
for (var i = 0; i < fwSketches.length; i++)
|
||||||
loadFirmware(i, 1, fwHexFiles[i], db);
|
loadFirmware(i, 1, fwSketches[i], db);
|
||||||
|
|
||||||
var gw;
|
var gw;
|
||||||
if (gwType == 'Ethernet') {
|
if (gwType == 'Ethernet') {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"mongodb": "~1.4.7",
|
"mongodb": "~1.4.7",
|
||||||
"net": "~1.0.2",
|
"net": "~1.0.2",
|
||||||
|
"requestify": "^0.1.16",
|
||||||
"serialport": "^1.4.5"
|
"serialport": "^1.4.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user