Save on Send (to Flash) and the SX127x module

Posted on
  • Why does the following code work just fine on the Pixl.js when code is uploaded to RAM, but when I use "Save on Send (to Flash)", or save() it wrapped in an onInit() function, does it just print "Sending.." and then stop?

    SPI1.setup({ sck:D3, miso:D4, mosi:D5 });
    var sx = require("SX127x").connect({spi: SPI1, cs: D6, rst : D7 });
    
    var config = {
      forcePaBoost: true,
    };
    clearInterval();
    // Until DIO0 line irqs are implemented we need this:
    setInterval(function() { sx.onIRQ(); }, 100);
    
    sx.setTxConfig(config);
    
    console.log('Sending..');
    sx.send("Hello", function() {
      console.log("TX done");
    });
    
  • I believe it's to do with execution speed. It turns out require("SX127x").connect doesn't execute immediately, and so you should only use it maybe 10ms after calling it.

    When you upload you get that delay automatically because of the upload, but executing from flash it's too quick.

    Just doing:

    var sx = require("SX127x").connect({spi: SPI1, cs: D6, rst : D7 });
    //....
    setTimeout(function() {
     sx.setTxConfig(config);
    console.log('Sending..');
    sx.send("Hello", function() {
      console.log("TX done");
    });
    }, 10);
    

    should do it - ideally there should be a callback function when initialisation is done

  • Hmm, that makes sense but it didn't resolve it either. I tried increasing the timeout from 10 to 100ms, and putting the onIRQ setInterval inside the timeout function, but no luck so far.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Save on Send (to Flash) and the SX127x module

Posted by Avatar for gendor @gendor

Actions