Skip to content

Commit

Permalink
Merge pull request #2 from ch2i/master
Browse files Browse the repository at this point in the history
Version V1.67
  • Loading branch information
hallard authored Jan 20, 2017
2 parents 8a536bc + e086d74 commit 779236b
Show file tree
Hide file tree
Showing 33 changed files with 523 additions and 323 deletions.
178 changes: 15 additions & 163 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,163 +1,15 @@
RadioHead Packet Radio library for embedded microprocessors
===========================================================

This is a fork of the original RadioHead Packet Radio library for embedded microprocessors. It provides a complete object-oriented library for sending and receiving packetized messages via a variety of common data radios and other transports on a range of embedded microprocessors.

**Please read the full documentation and licensing from the original author [site][3]**

### features added with this fork
=================================

**Compatible with boards**

[LoRasPI][10], [Raspberry PI Lora Gateway][12], [Dragino Lora GPS HAT][13]

<img src="https://raw.githubusercontent.com/hallard/LoRasPI/master/images/LoRasPI-on-Pi.jpg" height="25%" width="25%" alt="LoRasPI">&nbsp;
<img src="https://raw.githubusercontent.com/hallard/RPI-Lora-Gateway/master/images/RPI-Lora-Gateway-mounted.jpg" height="25%" width="25%" alt="Raspberry PI Lora Gateway/Node">&nbsp;
<img src="http://wiki.dragino.com/images/d/d6/Lora_GPS_HAT.png" height="25%" width="25%" alt="Raspberry PI Lora Gateway/Node">

- Added moteino modem setting on RF69 to be compatible with lowpowerlab RF69 configuration library
- Added possibility to work with no IRQ connected for RF69 and RF95
- for example to get one more GPIO free
- on Raspberry Pi, we do not have `attachInterrupt()` like with bcm2835 library
- Added samples for multiples Raspberry Pi boards with RF69 and RF95 modules such as
- [LoRasPI][10], simple RFM9x or RFM69HCW shield
- [iC880A or Linklabs Raspberry PI shield][11] with RFM9x or RFM69HCW onboard
- [Raspberry PI Lora Gateway][12] with multiple RFM9x or RFM69HCW shield
- [Dragino Lora shield][13]
- Sample code are in [rf95][21], [rf69][20], [nrf24][22] and [multi_server][23], note that old sample NRF24 sample has been moved to nrf24 folder for consistency.
- Added 2 samples test tools (for Raspberry PI) do detect RF69 and RF95 modules and check IRQ rising edge
- [spi_scan][9] sample code, scan and try to detect connected modules
- [irq_test][8] sample code, check a rising edge on a GPIO

Sample code for Raspberry PI is located under [RadioHead/examples/raspi][7] folder.

### Installation on Raspberry PI
================================

Clone repository
```shell
git clone https://github.com/hallard/RadioHead
```

**Connection and pins definition**

Boards pins (Chip Select, IRQ line, Reset and LED) definition are set in the new [RadioHead/examples/raspi/RasPiBoards.h][24] file. In your code, you need to define board used and then, include the file definition like this
```cpp
// LoRasPi board
#define BOARD_LORASPI

// Now we include RasPi_Boards.h so this will expose defined
// constants with CS/IRQ/RESET/on board LED pins definition
#include "../RasPiBoards.h"

// Your code start here
#ifdef RF_RST_PIN
// Blah blah do reset line
#endif

```

Then in your code you'll have exposed RF_CS_PIN, RF_IRQ_PIN, RF_RST_PIN and RF_LED_PIN and you'll be able to do some `#ifdef RF_LED_LIN` for example. See [rf95_client][25] sample code.

So you have 3 options to define the pins you want

- The board you have is already defined so just need to define it your source code (as explained above)
- You can add your board into [RasPiBoards.h][24] and then define it your source code as above
- You can manually define pins in your code and remove the board definition and `#include "../RasPiBoards.h"`

To go further with examples :

go to example folder here spi_scan
```shell
cd RadioHead/examples/raspi/spi_scan
```
Build executable
```shell
root@pi03(rw):~/RadioHead/examples/raspi/spi_scan# make
g++ -DRASPBERRY_PI -DBCM2835_NO_DELAY_COMPATIBILITY -c -I../../.. spi_scan.c
g++ spi_scan.o -lbcm2835 -o spi_scan
root@pi03(rw):~/RadioHead/examples/raspi/spi_scan
```
And run
```shell
root@pi03(rw):~/RadioHead/examples/raspi/spi_scan# ./spi_scan
Checking register(0x42) with CS=GPIO06 => Nothing!
Checking register(0x10) with CS=GPIO06 => Nothing!
Checking register(0x42) with CS=GPIO08 => SX1276 RF95/96 (V=0x12)
Checking register(0x10) with CS=GPIO08 => Nothing!
Checking register(0x42) with CS=GPIO07 => Nothing!
Checking register(0x10) with CS=GPIO07 => Nothing!
Checking register(0x42) with CS=GPIO26 => Nothing!
Checking register(0x10) with CS=GPIO26 => Nothing!
```
And voila! with [LoRasPi][10] board RFM95 dedected on SPI with GPIO8 (CE0)


If I'm doing same test with [PI Lora Gateway][12] with 2 RFM95 (one 433MHz and one 868MHz) and one RFMHW69 433MHz on board like this

<img src="https://raw.githubusercontent.com/hallard/RPI-Lora-Gateway/master/images/RPI-Lora-Gateway-mounted.jpg" height="40%" width="40%" alt="Raspberry PI Lora Gateway/Node">

Here are the results when trying to detect the onboard modules:

```shell
root@pi01(rw):~/RadioHead/examples/raspi/spi_scan# ./spi_scan
Checking register(0x42) with CS=GPIO06 => Nothing!
Checking register(0x10) with CS=GPIO06 => Nothing!
Checking register(0x42) with CS=GPIO08 => SX1276 RF95/96 (V=0x12)
Checking register(0x10) with CS=GPIO08 => Nothing!
Checking register(0x42) with CS=GPIO07 => SX1276 RF95/96 (V=0x12)
Checking register(0x10) with CS=GPIO07 => Nothing!
Checking register(0x42) with CS=GPIO26 => Unknown (V=0x01)
Checking register(0x10) with CS=GPIO26 => SX1231 RFM69 (V=0x24)
```

Voila! 3 modules are seen, now let's try listenning packets with PI Lora [Gateway][12].

My setup has another Raspberry Pi with RFM95 868MHZ [LoRasPI][10] shield running [`rf95_client`][25] sample and some [ULPnode][6] prototypes always running with on board RFM69 configured as Group ID 69 on 433MHz. I don't have a Lora 433MHz sender running so we won't receive anything on this one.

Here the results starting from scratch

**Client side**

<img src="https://raw.githubusercontent.com/hallard/RadioHead/master/examples/raspi/pictures/rf95_client.png" alt="RF95 client">

**multi server side**

<img src="https://raw.githubusercontent.com/hallard/RadioHead/master/examples/raspi/pictures/multi_server.png" alt="RF95 client">

It works!

### Difference with original Author repo
========================================

Due to easier maintenance to keep in sync with original author lib, I've got 2 repo:

- My master one (this one) https://github.com/hallard/RadioHead that is the one you need if you want to use my projects or lib added features.
- The one above has been forked to https://github.com/ch2i/RadioHead where I put the original version released by the author.

Like this, I can do Pull Request from [ch2i][4] to [hallard][1] to add new features added by the author to my version. This mean that this [one][4] is just a github copy version of the latest original done by Mike, I don't do any change on this one. I know it's not the best way, but I didn't found a better solution for now, if you have better idea, just let me know.

[1]: https://github.com/hallard/RadioHead
[2]: https://hallard.me
[3]: http://www.airspayce.com/mikem/arduino/RadioHead/
[4]: http://www.airspayce.com/mikem/arduino/RadioHead/RadioHead-1.61.zip
[5]: https://github.com/ch2i/RadioHead
[6]: http://hallard.me/category/ulpnode/
[7]: https://github.com/hallard/RadioHead/tree/master/examples/raspi
[8]: https://github.com/hallard/RadioHead/tree/master/examples/raspi/irq_test
[9]: https://github.com/hallard/RadioHead/tree/master/examples/raspi/spi_scan

[10]: https://github.com/hallard/LoRasPI
[11]: https://github.com/ch2i/iC880A-Raspberry-PI
[12]: https://github.com/hallard/RPI-Lora-Gateway
[13]: https://github.com/dragino/Lora

[20]: https://github.com/hallard/RadioHead/tree/master/examples/raspi/rf69
[21]: https://github.com/hallard/RadioHead/tree/master/examples/raspi/rf95
[22]: https://github.com/hallard/RadioHead/tree/master/examples/raspi/nrf24
[23]: https://github.com/hallard/RadioHead/tree/master/examples/raspi/multi_server
[24]: https://github.com/hallard/RadioHead/tree/master/examples/raspi/RasPiBoards.h
[25]: https://github.com/hallard/RadioHead/tree/master/examples/raspi/rf95/rf95_client.cpp


RadioHead Packet Radio library for embedded microprocessors
===========================================================
###Version 1.67

This is a copy of the original RadioHead Packet Radio library for embedded microprocessors. It provides a complete object-oriented library for sending and receiving packetized messages via a variety of common data radios and other transports on a range of embedded microprocessors.

Please read the full documentation and licensing from the original author [site][3], here it's just a copy to keep in sync my custom featured [version][1] with this [original version][4].

**If you want to know what features have been added for my custom needs, please see my [repo version README][1]**

[1]: https://github.com/hallard/RadioHead
[2]: https://hallard.me
[3]: http://www.airspayce.com/mikem/arduino/RadioHead/
[4]: http://www.airspayce.com/mikem/arduino/RadioHead/RadioHead-1.67.zip
6 changes: 3 additions & 3 deletions RHGenericDriver.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RHGenericDriver.cpp
//
// Copyright (C) 2014 Mike McCauley
// $Id: RHGenericDriver.cpp,v 1.19 2015/12/11 01:10:24 mikem Exp $
// $Id: RHGenericDriver.cpp,v 1.20 2017/01/12 23:58:00 mikem Exp $

#include <RHGenericDriver.h>

Expand Down Expand Up @@ -72,7 +72,7 @@ bool RHGenericDriver::waitPacketSent(uint16_t timeout)
bool RHGenericDriver::waitCAD()
{
if (!_cad_timeout)
return true;
return true;

// Wait for any channel activity to finish or timeout
// Sophisticated DCF function...
Expand All @@ -83,7 +83,7 @@ bool RHGenericDriver::waitCAD()
while (isChannelActive())
{
if (millis() - t > _cad_timeout)
return false;
return false;
delay(random(1, 10) * 100); // Should these values be configurable? Macros?
}

Expand Down
8 changes: 6 additions & 2 deletions RHGenericDriver.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RHGenericDriver.h
// Author: Mike McCauley ([email protected])
// Copyright (C) 2014 Mike McCauley
// $Id: RHGenericDriver.h,v 1.17 2016/04/04 01:40:12 mikem Exp $
// $Id: RHGenericDriver.h,v 1.18 2017/01/12 23:58:00 mikem Exp $

#ifndef RHGenericDriver_h
#define RHGenericDriver_h
Expand Down Expand Up @@ -52,7 +52,7 @@ class RHGenericDriver
RHModeIdle, ///< Transport is idle.
RHModeTx, ///< Transport is in the process of transmitting a message.
RHModeRx, ///< Transport is in the process of receiving a message.
RHModeCad ///< Transport is in the process of detecting channel activity (if supported)
RHModeCad ///< Transport is in the process of detecting channel activity (if supported)
} RHMode;

/// Constructor
Expand Down Expand Up @@ -298,6 +298,10 @@ class RHGenericDriver
volatile bool _cad;
unsigned int _cad_timeout;

/// Channel activity detected
volatile bool _cad;
unsigned int _cad_timeout;

private:

};
Expand Down
4 changes: 2 additions & 2 deletions RHHardwareSPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Author: Mike McCauley ([email protected])
// Copyright (C) 2011 Mike McCauley
// Contributed by Joanna Rutkowska
// $Id: RHHardwareSPI.h,v 1.9 2014/08/12 00:54:52 mikem Exp $
// $Id: RHHardwareSPI.h,v 1.10 2017/01/12 23:58:00 mikem Exp $

#ifndef RHHardwareSPI_h
#define RHHardwareSPI_h
Expand Down Expand Up @@ -54,7 +54,7 @@ class RHHardwareSPI : public RHGenericSPI
void end();
#else
// not supported on ATTiny etc
uint8_t transfer(uint8_t data) {return 0;}
uint8_t transfer(uint8_t /*data*/) {return 0;}
void begin(){}
void end(){}

Expand Down
3 changes: 2 additions & 1 deletion RHReliableDatagram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//
// Author: Mike McCauley ([email protected])
// Copyright (C) 2011 Mike McCauley
// $Id: RHReliableDatagram.cpp,v 1.15 2015/12/11 01:10:24 mikem Exp $
// $Id: RHReliableDatagram.cpp,v 1.16 2017/01/12 23:58:00 mikem Exp $

#include <RHReliableDatagram.h>

Expand All @@ -22,6 +22,7 @@ RHReliableDatagram::RHReliableDatagram(RHGenericDriver& driver, uint8_t thisAddr
_lastSequenceNumber = 0;
_timeout = RH_DEFAULT_TIMEOUT;
_retries = RH_DEFAULT_RETRIES;
memset(_seenIds, 0, sizeof(_seenIds));
}

////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions RH_ASK.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RH_ASK.cpp
//
// Copyright (C) 2014 Mike McCauley
// $Id: RH_ASK.cpp,v 1.19 2016/08/17 01:53:21 mikem Exp mikem $
// $Id: RH_ASK.cpp,v 1.20 2017/01/12 23:58:00 mikem Exp $

#include <RH_ASK.h>
#include <RHCRC.h>
Expand Down Expand Up @@ -483,7 +483,7 @@ bool RH_ASK::send(const uint8_t* data, uint8_t len)
waitPacketSent();

if (!waitCAD())
return false; // Check channel activity
return false; // Check channel activity

// Encode the message length
crc = RHcrc_ccitt_update(crc, count);
Expand Down
4 changes: 2 additions & 2 deletions RH_CC110.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Driver for Texas Instruments CC110L transceiver.
//
// Copyright (C) 2016 Mike McCauley
// $Id: RH_CC110.cpp,v 1.4 2016/01/02 01:46:34 mikem Exp $
// $Id: RH_CC110.cpp,v 1.5 2017/01/12 23:58:00 mikem Exp $

#include <RH_CC110.h>

Expand Down Expand Up @@ -302,7 +302,7 @@ bool RH_CC110::send(const uint8_t* data, uint8_t len)
setModeIdle();

if (!waitCAD())
return false; // Check channel activity
return false; // Check channel activity

spiWriteRegister(RH_CC110_REG_3F_FIFO, len + RH_CC110_HEADER_LEN);
spiWriteRegister(RH_CC110_REG_3F_FIFO,_txHeaderTo);
Expand Down
8 changes: 4 additions & 4 deletions RH_MRF89.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RH_MRF89.cpp
//
// Copyright (C) 2015 Mike McCauley
// $Id: RH_MRF89.cpp,v 1.7 2015/12/31 04:23:12 mikem Exp $
// $Id: RH_MRF89.cpp,v 1.8 2017/01/12 23:58:00 mikem Exp $

#include <RH_MRF89.h>
#define BAND_915
Expand Down Expand Up @@ -390,10 +390,10 @@ bool RH_MRF89::send(const uint8_t* data, uint8_t len)

waitPacketSent(); // Make sure we dont interrupt an outgoing message
setModeIdle();

if (!waitCAD())
return false; // Check channel activity
return false; // Check channel activity

// First octet is the length of the chip payload
// 0 length messages are transmitted but never trigger a receive!
spiWriteData(len + RH_MRF89_HEADER_LEN);
Expand Down
4 changes: 2 additions & 2 deletions RH_NRF24.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// NRF24.cpp
//
// Copyright (C) 2012 Mike McCauley
// $Id: RH_NRF24.cpp,v 1.22 2016/04/04 01:40:12 mikem Exp $
// $Id: RH_NRF24.cpp,v 1.23 2017/01/12 23:58:00 mikem Exp $

#include <RH_NRF24.h>

Expand Down Expand Up @@ -189,7 +189,7 @@ bool RH_NRF24::send(const uint8_t* data, uint8_t len)
return false;

if (!waitCAD())
return false; // Check channel activity
return false; // Check channel activity

// Set up the headers
_buf[0] = _txHeaderTo;
Expand Down
Loading

0 comments on commit 779236b

Please sign in to comment.