Some API changes

A project log for LoShark

The Ultra-Compact Powerhouse for LoRa Debugging and Connectivity

reimu-notmoeReimu NotMoe 08/10/2023 at 23:350 Comments

After some careful thinking, I changed the JS API of Resonance a bit:

So now the LoShark example code looks likes this:

// X1501 EVB
const {SX126x} = loadModule("loshark/sx126x");
const {GPIOControllerLinux} = loadModule("gpio/linux");
const {SPIControllerLinux} = loadModule("spi/linux");

const gpioa = new GPIOControllerLinux(0);
const pa12 =, "SX126x NRST");
const pa13 =, "SX126x DIO2");
const pa14 =, "SX126x DIO1");
const pa15 =, "SX126x BUSY");

const spi0 = new SPIControllerLinux(0);
const spidev0_3 =;

const cfg = {
  chip: "SX1268",
  tcxo: { voltage: 0x2, timeout: 32 },
  gpio: { reset: pa12, busy: pa15, dio1: pa14, dio2: pa13 },
  spi: spidev0_3,

mdm = new SX126x(cfg);

mdm.on("receive", msg => console.log("packet received:", msg));
mdm.on("signal", sig => console.log("signal:", sig));
mdm.on("event", ev => console.log("event:", ev));"modem opened"));
mdm.propertySet("", 62).then(console.log);
mdm.transmit('Bonjour mes reufs').then(console.log);

You can use the await keyword in async functions in .js files.

Suggestions are welcomed.