Giter VIP home page Giter VIP logo

sx127x's People

Contributors

tperale avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

pasansamara96

sx127x's Issues

Study the different way to know there is an ongoing communication

So far two methods are documented to know if there is an ongoing communication.

  • Using MODEMSTAT
uint8_t status;
spi_read_register(__sx1272_dev.spi, REG_LR_MODEMSTAT, &status, 1);
if (status & (0x04 | 0x01)) {
  sx1272_rx_internal_set(&__sx1272_dev, sx1272_rx_receiving);
}
  • Using interrupt on DIO3
if (sx1272_read_register(SX1272_DEV.spi, REG_LR_IRQFLAGS) & RFLR_IRQFLAGS_VALIDHEADER) {
  SX1272_DEV.receiv_timestamp = RTIMER_NOW(); // - US_TO_RTIMERTICKS(439)
  sx1272_write_register(SX1272_DEV.spi, REG_LR_IRQFLAGS, RFLR_IRQFLAGS_VALIDHEADER);
  sx1272_rx_internal_set(&SX1272_DEV, sx1272_rx_receiving);
  LOG_DBG("Receiving packet\n");
}

I only managed to make the second one work. I should try to implement the first one and study which one detect an incoming packet faster to reduce the time the radio must spend listening for incoming messages.

Enable Interrupts instead of busywaiting

Busywaiting for an interrupt on the pin DI0,DI1,DI2,DI3 introduce some delay in the software. As we can see in the next picture, the time between the interrupt and the acknowledgement from the software can almost reach 1ms.

DS1Z_QuickPrint5

If we assign some pins from the RE-MOTE to handle the interrupts we could process the pending packet more quickly.

So far only two pins are used by the driver.

  • DI0 acknowledge a completed transmition on TX side and acknowledge a pending packet on RX side
  • DI3 acknowledge an ongoing packet reception

The following code could be used to process the interrupt on those two pins.

static void sx1272_interrupt_dio0() { 
  if (__sx1272_dev.mode == sx1272_mode_receiver 
      || __sx1272_dev.mode == sx1272_mode_receiver_single) {
    SX1272_DEV.rx_timestamp = RTIMER_NOW();
    sx1272_rx_internal_set(&__sx1272_dev, sx1272_rx_received);
    sx1272_write_register(__sx1272_dev.spi, REG_LR_IRQFLAGS, RFLR_IRQFLAGS_RXDONE);
  } else if (__sx1272_dev.mode == sx1272_mode_transmitter) {
    sx1272_write_register(__sx1272_dev.spi, REG_LR_IRQFLAGS, RFLR_IRQFLAGS_TXDONE);
    sx127x_set_opmode(&SX1272_DEV, sx1272_mode_standby);
  }
}
static void sx1272_interrupt_dio1() { 
  sx1272_write_register(__sx1272_dev.spi, REG_LR_IRQFLAGS, RFLR_IRQFLAGS_RXTIMEOUT);
}
static void sx1272_interrupt_dio3() { 
  if (__sx1272_dev.mode == sx1272_mode_receiver 
      || __sx1272_dev.mode == sx1272_mode_receiver_single) {
    SX1272_DEV.receiv_timestamp = RTIMER_NOW();
    sx1272_rx_internal_set(&__sx1272_dev, sx1272_rx_receiving);
    sx1272_write_register(__sx1272_dev.spi, REG_LR_IRQFLAGS, RFLR_IRQFLAGS_VALIDHEADER);
  }
}

TODO

  • Assign pins that will handle the interrupts
  • Setup interrupt in Contiki
  • Do the timestamping inside the interrupts
  • Handle both with or without interrupt usage of the driver.

Better knowledge of the opmode

  • In which mode should the SX127X be running to change the channel ?
  • In which mode should we go after completed transmission (currently standby
    sx127x_set_opmode(&SX1272_DEV, sx1272_mode_standby);
    ) ?
  • Is the module settled to a default mode after TX completion ?
  • Measure time to switch from sleep mode to standby and standby to sleep mode.
  • Can we go in sleep mode instead of standby when turning off the radio.

Support for SX1276, RFM95

SX1276,SX1277,SX1278,SX1279

  • Version is 0x12
  • Different rssi calculation method
  • low datarate optimization is different
  • set_bandwidth is different (different register mask)
  • set_coding_rate is different (different register mask)
  • set_crc is different (different register mask)
  • fixed header len is different (different register mask)
  • set_tx_power is different (different register mask)
  • set_tx_power different max power

RFM 95

  • Version is 0x11

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.