Questions & Observations on the RFM69 library code.

Started by DeKay, February 23, 2014, 01:25:49 PM

DeKay

I've been working away on getting my Moteino to talk to my weather station.  In doing so, I've decided to come up with a separate library based on the RFM69 code rather than trying to subclass from it.  My application doesn't deal with ACKs, retries, adresses, variable payload lengths, encryption and the like so I can also simplify things somewhat.  The RFM69 library also makes some assumptions on the state machine that are less than optimal for my frequency hopping situation.

In doing all this, I came up with some questions and observations regarding the RFM69 code.

Questions

First, the code is released under Creative Commons, but to my understanding, the CC guys themselves recommend against using this for licensing software.  Why CC, and should a different license be used?

Given that I'm developing this separate library based on RFM69, I would myself prefer to use a license that is more clearly compatible with that of other Arduino libraries, and the fact that CC isn't recommended for software in the first place makes this a bit tricky.  Given that I have reworked some significant parts of the RFM69 code while copying other parts, could I consider this an original work that I should assign my own license to?

I'm just trying to stay on everybody's good side with the whole license thing   ;)

Observations

Some of these may be applicable to the general purpose RFM69 code and some may not.  I haven't thought all of these all the way through, but they might be worth consideration.  Here we go...

The RFM69 interrupt handler reads the RSSI after the packet is read from the FIFO.  I'd recommend putting the RSSI read at the start of the packet while the carrier is most likely still up.  My code is:

void DavisRFM69::interruptHandler() {
  RSSI = readRSSI();  // Read up front when it is most likely the carrier is still up


The receiveDone() function turns interrupts on and off every time it is called and this is in the main loop.  What I've done is simply set a flag in my interrupt handler

    _packetReceived = true;

that I can check with a simple getter method.  This seems much cleaner to me.

The RFM69 code sets the mode back to RX in the Interrupt Routine.  This caused a problem for me while I was receiving from my weather station because I'd sometimes get a false partial packet if its transmitter was still on by the time I finished receiving its packet.  Because I am frequency hopping, it works better for me to stay in STANDBY within the ISR and only go into RX in my variant of receiveBegin after the hop.

The RFM69 code supports changing the radio frequency, but doing this while transmit is on will cause some nasty splatter that the datasheet warns against.  This should be looked at at some point.  I have not addressed this in my code yet.

I was getting large amounts of interference and because I don't have the benefit of retries (the weather station just sends stuff), I only get one crack at it.  I dropped my sensitivity way down from the default in the RFM69 code and I got a huge improvement.

    /* 0x29 */ { REG_RSSITHRESH, 170 }, //must be set to dBm = (-Sensitivity / 2) - default is 0xE4=228 so -114dBm

Looking forward to some feedback, and thanks to Felix for all the hard work on the Moteino and the RFM69 code!

Felix

Hey DeKay,
The CC license might not be the most suitable indeed. I think I've used it because it's the easiest to understand. I think conceptually people can understand what it means.
It's free open source software so you can do whatever with it. CC-BY means attribution if the work is not original. Original means you write all your code by yourself.

Reading RSSI before moving to standby might be a good idea. I will consider that.
The RX/TX packet state machine is pretty sensitive. The interrupt disable/enable code is there to avoid issues.
The check for packet received is this:
_mode == RF69_MODE_RX && PAYLOADLEN>0


Dropping sensitivity is not a bad idea, not as long as you are still aware that you might loose some packets from nodes that are far away. At your -86dBm that is quite low. The default is -114, big difference.