Merge branch 'master' of gitlab.com:morganrallen/esp32-lora

This commit is contained in:
Morgan 'ARR\!' Allen 2019-06-28 19:58:09 -07:00
commit 53c3b3d6e5
5 changed files with 67 additions and 43 deletions

View file

@ -10,6 +10,7 @@ all_tests:
- echo $PATH - echo $PATH
- make -f test/lora32/Makefile defconfig all - make -f test/lora32/Makefile defconfig all
- npm install --unsafe-perm - npm install --unsafe-perm
- npm rebuild
- npm test - npm test
artifacts: artifacts:
paths: paths:

View file

@ -27,7 +27,7 @@ This is the most basic usage. Setting up the LoRa instance, setting it's receive
lora32_init(&lora); lora32_init(&lora);
lora32_send(&lora, "Hello, LoRa", 10); lora32_send(&lora, "Hello, LoRa", 11);
``` ```

View file

@ -22,7 +22,12 @@
}, },
"dependencies": { "dependencies": {
"async": "^2.6.1", "async": "^2.6.1",
"esptool-wrapper": "^1.0.4",
"serialport": "^6.2.2", "serialport": "^6.2.2",
"tape": "^4.9.1" "tape": "^4.9.1",
"testbed-query-fixtures": "^1.0.0"
},
"devDependencies": {
"homedir": "^0.6.0"
} }
} }

View file

@ -133,9 +133,11 @@ void set_mode(void *args) {
} }
void send(void *args) { void send(void *args) {
ESP_LOGI(TAG, "sending: %s\n", (char*)args); ESP_LOGI(TAG, "sending: %s", (char*)args);
lora32_send(&lora, (uint8_t *)args, 12); lora32_send(&lora, (uint8_t *)args, 12);
ESP_LOGI(TAG, "done");
}; };
void set_spreadfactor(void *args) { void set_spreadfactor(void *args) {

View file

@ -1,52 +1,68 @@
var async = require("async"); var async = require("async");
var esptool = require("esptool-wrapper");
var homedir = require("homedir")();
var spawn = require("child_process").spawn; var spawn = require("child_process").spawn;
var SerialPort = require("serialport"); var SerialPort = require("serialport");
var path = require("path"); var path = require("path");
var test = require("tape"); var test = require("tape");
var testbed = require("testbed-query-fixtures");
const exec = path.join(process.env.IDF_PATH, "components", "esptool_py", "esptool", "esptool.py");
const portString = "/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_SERIAL_ID-if00-port0";
const buildPath = path.join(__dirname, "lora32", "build"); const buildPath = path.join(__dirname, "lora32", "build");
const TB_DEV1 = process.env.TB_DEV1 || "0000"; try {
const TB_DEV2 = process.env.TB_DEV2 || "0001"; var testbedConfig = require(path.join(homedir, ".testbed.json"));
} catch(e) {
console.log(e);
console.error("testbed.json fixture file not found.");
var args = [ process.exit(1);
"--chip", }
"esp32",
"--baud", var devices = testbed({
"460800", f: [ "esp32", "lora" ],
fixtures: testbedConfig.fixtures
});
if(devices.length < 2) {
throw new Error("Not enough test devices available");
}
const TB_DEV1 = devices[0].DEVNAME;
const TB_DEV2 = devices[1].DEVNAME;
var testBins = {
0x1000: path.join(buildPath, "bootloader/bootloader.bin"),
0x8000: path.join(buildPath, "partitions_singleapp.bin"),
0x10000: path.join(buildPath, "lora32.bin")
};
function flash(port, cb) {
var argsReset = [
"--before", "--before",
"default_reset", "default_reset",
"--after", "--after",
"hard_reset", "hard_reset"
"write_flash", ];
var argsWriteFlash = [
"-z", "-z",
"--flash_mode", "--flash_mode",
"dio", "dio",
"--flash_freq", "--flash_freq",
"40m", "40m",
"--flash_size", "--flash_size",
"detect", "detect"
"0x1000", ];
path.join(buildPath, "bootloader/bootloader.bin"),
"0x10000",
path.join(buildPath, "lora32.bin"),
"0x8000",
path.join(buildPath, "partitions_singleapp.bin")
];
function flash(port, cb) {
console.log("Flashing devices at %s", port); console.log("Flashing devices at %s", port);
var cp = spawn(exec, ["--port", port].concat(args)); esptool({
port: port,
cp.on("exit", function(code) { baud: 460800,
console.log("%s\nexited: %d", port, code); files: testBins,
args: argsReset,
cb(code === 0 ? null : new Error("exited non-zero: " + code)); cmdArgs: argsWriteFlash
}); }, cb);
} }
function toggleReset(sp) { function toggleReset(sp) {
@ -108,20 +124,20 @@ async.series([
async.parallel([ async.parallel([
function(done) { function(done) {
flash(portString.replace("SERIAL_ID", TB_DEV1), done); flash(TB_DEV1, done);
}, function(done) { }, function(done) {
flash(portString.replace("SERIAL_ID", TB_DEV2), done); flash(TB_DEV2, done);
}], next); }], next);
}, },
function(next) { function(next) {
async.parallel({ async.parallel({
dev1: function(done) { dev1: function(done) {
serial(portString.replace("SERIAL_ID", TB_DEV1), done); serial(TB_DEV1, done);
}, },
dev2: function(done) { dev2: function(done) {
serial(portString.replace("SERIAL_ID", TB_DEV2), done); serial(TB_DEV2, done);
} }
}, next); }, next);
} }