Close

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 = gpioa.open(12, "SX126x NRST");
const pa13 = gpioa.open(13, "SX126x DIO2");
const pa14 = gpioa.open(14, "SX126x DIO1");
const pa15 = gpioa.open(15, "SX126x BUSY");

const spi0 = new SPIControllerLinux(0);
const spidev0_3 = spi0.open(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));

mdm.open().then(console.log("modem opened"));
mdm.propertySet("modem0.modulation.lora.bw", 62).then(console.log);
mdm.propertyList().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.

Discussions