LowPowerLab/RFM12B — pull request #5 by davidhewing (2013-06-11 18:39:49+00:00)
Title: RFM12B Library Ehancements

There are a couple of enhancements that I made to the library for my own purposes that I don't believe impact the library negatively except for one item. Since power isn't an issue with my use, but speed and packet reliability is, here are the additions that I applied:

1) During the packet send routine, it will not return until the packet has been send. I changed that to return immediately if no sleep mode was specified. This allows my code to continue doing other things while the module is provided data by the interrupt routine.

2) When a send is completely by the Interrupt routine, instead of going to TXIDLE, I forced it to go into receive mode. This may be detrimental for battery applications so some additional code checking for a sleep state and conditionally going to a receive mode is probably needed here. I added this because I wanted to make sure that the RFM12B was listening at all times except during transmit.

3) Finally, I added a function for setting a receive call back function and then if it is set, then it is called as part of ReceiveComplete function. I noticed that if the receiver is active when send function is called, allof that data will be lost. With a call back function, that data can be saved. In my code, I call ReceiveComplete as part of the main loop, but actually handle the packet received in the callback function. If a callback function is not defined, functionally is the same as before. The only restriction is that the callback function cannot call the library's send function or the original data trying to be sent will be overwritten.

I have not tested this code with any of the examples, but other than a power drain in item #2, the changes I have made should not impact anything else.

In my project, power isn't an issue with my use, but speed and packet reliability is. I have been trying to make the RFM12B work as well as the XBEE modules, but so far there is very little tolerance for RF packet collisions. My (non library) software has to do quite a lot to track packets and retransmit. Unfortunately, the more RFM12B modules are active, the higher the collision rates get.

Thanks for the library, I hope these additions can help.