Merge branch 'master' of gitlab.com:morganrallen/esp32-lora
This commit is contained in:
commit
53c3b3d6e5
5 changed files with 67 additions and 43 deletions
|
@ -10,6 +10,7 @@ all_tests:
|
|||
- echo $PATH
|
||||
- make -f test/lora32/Makefile defconfig all
|
||||
- npm install --unsafe-perm
|
||||
- npm rebuild
|
||||
- npm test
|
||||
artifacts:
|
||||
paths:
|
||||
|
|
|
@ -27,7 +27,7 @@ This is the most basic usage. Setting up the LoRa instance, setting it's receive
|
|||
|
||||
lora32_init(&lora);
|
||||
|
||||
lora32_send(&lora, "Hello, LoRa", 10);
|
||||
lora32_send(&lora, "Hello, LoRa", 11);
|
||||
|
||||
```
|
||||
|
||||
|
|
|
@ -22,7 +22,12 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"async": "^2.6.1",
|
||||
"esptool-wrapper": "^1.0.4",
|
||||
"serialport": "^6.2.2",
|
||||
"tape": "^4.9.1"
|
||||
"tape": "^4.9.1",
|
||||
"testbed-query-fixtures": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"homedir": "^0.6.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -133,9 +133,11 @@ void set_mode(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);
|
||||
|
||||
ESP_LOGI(TAG, "done");
|
||||
};
|
||||
|
||||
void set_spreadfactor(void *args) {
|
||||
|
|
80
test/test.js
80
test/test.js
|
@ -1,52 +1,68 @@
|
|||
var async = require("async");
|
||||
var esptool = require("esptool-wrapper");
|
||||
var homedir = require("homedir")();
|
||||
var spawn = require("child_process").spawn;
|
||||
var SerialPort = require("serialport");
|
||||
var path = require("path");
|
||||
var test = require("tape");
|
||||
|
||||
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";
|
||||
var testbed = require("testbed-query-fixtures");
|
||||
|
||||
const buildPath = path.join(__dirname, "lora32", "build");
|
||||
|
||||
const TB_DEV1 = process.env.TB_DEV1 || "0000";
|
||||
const TB_DEV2 = process.env.TB_DEV2 || "0001";
|
||||
try {
|
||||
var testbedConfig = require(path.join(homedir, ".testbed.json"));
|
||||
} catch(e) {
|
||||
console.log(e);
|
||||
console.error("testbed.json fixture file not found.");
|
||||
|
||||
var args = [
|
||||
"--chip",
|
||||
"esp32",
|
||||
"--baud",
|
||||
"460800",
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
var devices = testbed({
|
||||
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",
|
||||
"default_reset",
|
||||
"--after",
|
||||
"hard_reset",
|
||||
"write_flash",
|
||||
"hard_reset"
|
||||
];
|
||||
|
||||
var argsWriteFlash = [
|
||||
"-z",
|
||||
"--flash_mode",
|
||||
"dio",
|
||||
"--flash_freq",
|
||||
"40m",
|
||||
"--flash_size",
|
||||
"detect",
|
||||
"0x1000",
|
||||
path.join(buildPath, "bootloader/bootloader.bin"),
|
||||
"0x10000",
|
||||
path.join(buildPath, "lora32.bin"),
|
||||
"0x8000",
|
||||
path.join(buildPath, "partitions_singleapp.bin")
|
||||
];
|
||||
"detect"
|
||||
];
|
||||
|
||||
function flash(port, cb) {
|
||||
console.log("Flashing devices at %s", port);
|
||||
|
||||
var cp = spawn(exec, ["--port", port].concat(args));
|
||||
|
||||
cp.on("exit", function(code) {
|
||||
console.log("%s\nexited: %d", port, code);
|
||||
|
||||
cb(code === 0 ? null : new Error("exited non-zero: " + code));
|
||||
});
|
||||
esptool({
|
||||
port: port,
|
||||
baud: 460800,
|
||||
files: testBins,
|
||||
args: argsReset,
|
||||
cmdArgs: argsWriteFlash
|
||||
}, cb);
|
||||
}
|
||||
|
||||
function toggleReset(sp) {
|
||||
|
@ -108,20 +124,20 @@ async.series([
|
|||
|
||||
async.parallel([
|
||||
function(done) {
|
||||
flash(portString.replace("SERIAL_ID", TB_DEV1), done);
|
||||
flash(TB_DEV1, done);
|
||||
}, function(done) {
|
||||
flash(portString.replace("SERIAL_ID", TB_DEV2), done);
|
||||
flash(TB_DEV2, done);
|
||||
}], next);
|
||||
},
|
||||
|
||||
function(next) {
|
||||
async.parallel({
|
||||
dev1: function(done) {
|
||||
serial(portString.replace("SERIAL_ID", TB_DEV1), done);
|
||||
serial(TB_DEV1, done);
|
||||
},
|
||||
|
||||
dev2: function(done) {
|
||||
serial(portString.replace("SERIAL_ID", TB_DEV2), done);
|
||||
serial(TB_DEV2, done);
|
||||
}
|
||||
}, next);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue