Skip to content

Commit 779236b

Browse files
authored
Merge pull request #2 from ch2i/master
Version V1.67
2 parents 8a536bc + e086d74 commit 779236b

33 files changed

+523
-323
lines changed

README.md

Lines changed: 15 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -1,163 +1,15 @@
1-
RadioHead Packet Radio library for embedded microprocessors
2-
===========================================================
3-
4-
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.
5-
6-
**Please read the full documentation and licensing from the original author [site][3]**
7-
8-
### features added with this fork
9-
=================================
10-
11-
**Compatible with boards**
12-
13-
[LoRasPI][10], [Raspberry PI Lora Gateway][12], [Dragino Lora GPS HAT][13]
14-
15-
<img src="https://raw.githubusercontent.com/hallard/LoRasPI/master/images/LoRasPI-on-Pi.jpg" height="25%" width="25%" alt="LoRasPI">&nbsp;
16-
<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;
17-
<img src="http://wiki.dragino.com/images/d/d6/Lora_GPS_HAT.png" height="25%" width="25%" alt="Raspberry PI Lora Gateway/Node">
18-
19-
- Added moteino modem setting on RF69 to be compatible with lowpowerlab RF69 configuration library
20-
- Added possibility to work with no IRQ connected for RF69 and RF95
21-
- for example to get one more GPIO free
22-
- on Raspberry Pi, we do not have `attachInterrupt()` like with bcm2835 library
23-
- Added samples for multiples Raspberry Pi boards with RF69 and RF95 modules such as
24-
- [LoRasPI][10], simple RFM9x or RFM69HCW shield
25-
- [iC880A or Linklabs Raspberry PI shield][11] with RFM9x or RFM69HCW onboard
26-
- [Raspberry PI Lora Gateway][12] with multiple RFM9x or RFM69HCW shield
27-
- [Dragino Lora shield][13]
28-
- 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.
29-
- Added 2 samples test tools (for Raspberry PI) do detect RF69 and RF95 modules and check IRQ rising edge
30-
- [spi_scan][9] sample code, scan and try to detect connected modules
31-
- [irq_test][8] sample code, check a rising edge on a GPIO
32-
33-
Sample code for Raspberry PI is located under [RadioHead/examples/raspi][7] folder.
34-
35-
### Installation on Raspberry PI
36-
================================
37-
38-
Clone repository
39-
```shell
40-
git clone https://github.com/hallard/RadioHead
41-
```
42-
43-
**Connection and pins definition**
44-
45-
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
46-
```cpp
47-
// LoRasPi board
48-
#define BOARD_LORASPI
49-
50-
// Now we include RasPi_Boards.h so this will expose defined
51-
// constants with CS/IRQ/RESET/on board LED pins definition
52-
#include "../RasPiBoards.h"
53-
54-
// Your code start here
55-
#ifdef RF_RST_PIN
56-
// Blah blah do reset line
57-
#endif
58-
59-
```
60-
61-
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.
62-
63-
So you have 3 options to define the pins you want
64-
65-
- The board you have is already defined so just need to define it your source code (as explained above)
66-
- You can add your board into [RasPiBoards.h][24] and then define it your source code as above
67-
- You can manually define pins in your code and remove the board definition and `#include "../RasPiBoards.h"`
68-
69-
To go further with examples :
70-
71-
go to example folder here spi_scan
72-
```shell
73-
cd RadioHead/examples/raspi/spi_scan
74-
```
75-
Build executable
76-
```shell
77-
root@pi03(rw):~/RadioHead/examples/raspi/spi_scan# make
78-
g++ -DRASPBERRY_PI -DBCM2835_NO_DELAY_COMPATIBILITY -c -I../../.. spi_scan.c
79-
g++ spi_scan.o -lbcm2835 -o spi_scan
80-
root@pi03(rw):~/RadioHead/examples/raspi/spi_scan
81-
```
82-
And run
83-
```shell
84-
root@pi03(rw):~/RadioHead/examples/raspi/spi_scan# ./spi_scan
85-
Checking register(0x42) with CS=GPIO06 => Nothing!
86-
Checking register(0x10) with CS=GPIO06 => Nothing!
87-
Checking register(0x42) with CS=GPIO08 => SX1276 RF95/96 (V=0x12)
88-
Checking register(0x10) with CS=GPIO08 => Nothing!
89-
Checking register(0x42) with CS=GPIO07 => Nothing!
90-
Checking register(0x10) with CS=GPIO07 => Nothing!
91-
Checking register(0x42) with CS=GPIO26 => Nothing!
92-
Checking register(0x10) with CS=GPIO26 => Nothing!
93-
```
94-
And voila! with [LoRasPi][10] board RFM95 dedected on SPI with GPIO8 (CE0)
95-
96-
97-
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
98-
99-
<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">
100-
101-
Here are the results when trying to detect the onboard modules:
102-
103-
```shell
104-
root@pi01(rw):~/RadioHead/examples/raspi/spi_scan# ./spi_scan
105-
Checking register(0x42) with CS=GPIO06 => Nothing!
106-
Checking register(0x10) with CS=GPIO06 => Nothing!
107-
Checking register(0x42) with CS=GPIO08 => SX1276 RF95/96 (V=0x12)
108-
Checking register(0x10) with CS=GPIO08 => Nothing!
109-
Checking register(0x42) with CS=GPIO07 => SX1276 RF95/96 (V=0x12)
110-
Checking register(0x10) with CS=GPIO07 => Nothing!
111-
Checking register(0x42) with CS=GPIO26 => Unknown (V=0x01)
112-
Checking register(0x10) with CS=GPIO26 => SX1231 RFM69 (V=0x24)
113-
```
114-
115-
Voila! 3 modules are seen, now let's try listenning packets with PI Lora [Gateway][12].
116-
117-
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.
118-
119-
Here the results starting from scratch
120-
121-
**Client side**
122-
123-
<img src="https://raw.githubusercontent.com/hallard/RadioHead/master/examples/raspi/pictures/rf95_client.png" alt="RF95 client">
124-
125-
**multi server side**
126-
127-
<img src="https://raw.githubusercontent.com/hallard/RadioHead/master/examples/raspi/pictures/multi_server.png" alt="RF95 client">
128-
129-
It works!
130-
131-
### Difference with original Author repo
132-
========================================
133-
134-
Due to easier maintenance to keep in sync with original author lib, I've got 2 repo:
135-
136-
- 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.
137-
- The one above has been forked to https://github.com/ch2i/RadioHead where I put the original version released by the author.
138-
139-
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.
140-
141-
[1]: https://github.com/hallard/RadioHead
142-
[2]: https://hallard.me
143-
[3]: http://www.airspayce.com/mikem/arduino/RadioHead/
144-
[4]: http://www.airspayce.com/mikem/arduino/RadioHead/RadioHead-1.61.zip
145-
[5]: https://github.com/ch2i/RadioHead
146-
[6]: http://hallard.me/category/ulpnode/
147-
[7]: https://github.com/hallard/RadioHead/tree/master/examples/raspi
148-
[8]: https://github.com/hallard/RadioHead/tree/master/examples/raspi/irq_test
149-
[9]: https://github.com/hallard/RadioHead/tree/master/examples/raspi/spi_scan
150-
151-
[10]: https://github.com/hallard/LoRasPI
152-
[11]: https://github.com/ch2i/iC880A-Raspberry-PI
153-
[12]: https://github.com/hallard/RPI-Lora-Gateway
154-
[13]: https://github.com/dragino/Lora
155-
156-
[20]: https://github.com/hallard/RadioHead/tree/master/examples/raspi/rf69
157-
[21]: https://github.com/hallard/RadioHead/tree/master/examples/raspi/rf95
158-
[22]: https://github.com/hallard/RadioHead/tree/master/examples/raspi/nrf24
159-
[23]: https://github.com/hallard/RadioHead/tree/master/examples/raspi/multi_server
160-
[24]: https://github.com/hallard/RadioHead/tree/master/examples/raspi/RasPiBoards.h
161-
[25]: https://github.com/hallard/RadioHead/tree/master/examples/raspi/rf95/rf95_client.cpp
162-
163-
1+
RadioHead Packet Radio library for embedded microprocessors
2+
===========================================================
3+
4+
###Version 1.67
5+
6+
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.
7+
8+
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].
9+
10+
**If you want to know what features have been added for my custom needs, please see my [repo version README][1]**
11+
12+
[1]: https://github.com/hallard/RadioHead
13+
[2]: https://hallard.me
14+
[3]: http://www.airspayce.com/mikem/arduino/RadioHead/
15+
[4]: http://www.airspayce.com/mikem/arduino/RadioHead/RadioHead-1.67.zip

RHGenericDriver.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RHGenericDriver.cpp
22
//
33
// Copyright (C) 2014 Mike McCauley
4-
// $Id: RHGenericDriver.cpp,v 1.19 2015/12/11 01:10:24 mikem Exp $
4+
// $Id: RHGenericDriver.cpp,v 1.20 2017/01/12 23:58:00 mikem Exp $
55

66
#include <RHGenericDriver.h>
77

@@ -72,7 +72,7 @@ bool RHGenericDriver::waitPacketSent(uint16_t timeout)
7272
bool RHGenericDriver::waitCAD()
7373
{
7474
if (!_cad_timeout)
75-
return true;
75+
return true;
7676

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

RHGenericDriver.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RHGenericDriver.h
22
// Author: Mike McCauley ([email protected])
33
// Copyright (C) 2014 Mike McCauley
4-
// $Id: RHGenericDriver.h,v 1.17 2016/04/04 01:40:12 mikem Exp $
4+
// $Id: RHGenericDriver.h,v 1.18 2017/01/12 23:58:00 mikem Exp $
55

66
#ifndef RHGenericDriver_h
77
#define RHGenericDriver_h
@@ -52,7 +52,7 @@ class RHGenericDriver
5252
RHModeIdle, ///< Transport is idle.
5353
RHModeTx, ///< Transport is in the process of transmitting a message.
5454
RHModeRx, ///< Transport is in the process of receiving a message.
55-
RHModeCad ///< Transport is in the process of detecting channel activity (if supported)
55+
RHModeCad ///< Transport is in the process of detecting channel activity (if supported)
5656
} RHMode;
5757

5858
/// Constructor
@@ -298,6 +298,10 @@ class RHGenericDriver
298298
volatile bool _cad;
299299
unsigned int _cad_timeout;
300300

301+
/// Channel activity detected
302+
volatile bool _cad;
303+
unsigned int _cad_timeout;
304+
301305
private:
302306

303307
};

RHHardwareSPI.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Author: Mike McCauley ([email protected])
33
// Copyright (C) 2011 Mike McCauley
44
// Contributed by Joanna Rutkowska
5-
// $Id: RHHardwareSPI.h,v 1.9 2014/08/12 00:54:52 mikem Exp $
5+
// $Id: RHHardwareSPI.h,v 1.10 2017/01/12 23:58:00 mikem Exp $
66

77
#ifndef RHHardwareSPI_h
88
#define RHHardwareSPI_h
@@ -54,7 +54,7 @@ class RHHardwareSPI : public RHGenericSPI
5454
void end();
5555
#else
5656
// not supported on ATTiny etc
57-
uint8_t transfer(uint8_t data) {return 0;}
57+
uint8_t transfer(uint8_t /*data*/) {return 0;}
5858
void begin(){}
5959
void end(){}
6060

RHReliableDatagram.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//
1010
// Author: Mike McCauley ([email protected])
1111
// Copyright (C) 2011 Mike McCauley
12-
// $Id: RHReliableDatagram.cpp,v 1.15 2015/12/11 01:10:24 mikem Exp $
12+
// $Id: RHReliableDatagram.cpp,v 1.16 2017/01/12 23:58:00 mikem Exp $
1313

1414
#include <RHReliableDatagram.h>
1515

@@ -22,6 +22,7 @@ RHReliableDatagram::RHReliableDatagram(RHGenericDriver& driver, uint8_t thisAddr
2222
_lastSequenceNumber = 0;
2323
_timeout = RH_DEFAULT_TIMEOUT;
2424
_retries = RH_DEFAULT_RETRIES;
25+
memset(_seenIds, 0, sizeof(_seenIds));
2526
}
2627

2728
////////////////////////////////////////////////////////////////////

RH_ASK.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RH_ASK.cpp
22
//
33
// Copyright (C) 2014 Mike McCauley
4-
// $Id: RH_ASK.cpp,v 1.19 2016/08/17 01:53:21 mikem Exp mikem $
4+
// $Id: RH_ASK.cpp,v 1.20 2017/01/12 23:58:00 mikem Exp $
55

66
#include <RH_ASK.h>
77
#include <RHCRC.h>
@@ -483,7 +483,7 @@ bool RH_ASK::send(const uint8_t* data, uint8_t len)
483483
waitPacketSent();
484484

485485
if (!waitCAD())
486-
return false; // Check channel activity
486+
return false; // Check channel activity
487487

488488
// Encode the message length
489489
crc = RHcrc_ccitt_update(crc, count);

RH_CC110.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Driver for Texas Instruments CC110L transceiver.
44
//
55
// Copyright (C) 2016 Mike McCauley
6-
// $Id: RH_CC110.cpp,v 1.4 2016/01/02 01:46:34 mikem Exp $
6+
// $Id: RH_CC110.cpp,v 1.5 2017/01/12 23:58:00 mikem Exp $
77

88
#include <RH_CC110.h>
99

@@ -302,7 +302,7 @@ bool RH_CC110::send(const uint8_t* data, uint8_t len)
302302
setModeIdle();
303303

304304
if (!waitCAD())
305-
return false; // Check channel activity
305+
return false; // Check channel activity
306306

307307
spiWriteRegister(RH_CC110_REG_3F_FIFO, len + RH_CC110_HEADER_LEN);
308308
spiWriteRegister(RH_CC110_REG_3F_FIFO,_txHeaderTo);

RH_MRF89.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RH_MRF89.cpp
22
//
33
// Copyright (C) 2015 Mike McCauley
4-
// $Id: RH_MRF89.cpp,v 1.7 2015/12/31 04:23:12 mikem Exp $
4+
// $Id: RH_MRF89.cpp,v 1.8 2017/01/12 23:58:00 mikem Exp $
55

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

391391
waitPacketSent(); // Make sure we dont interrupt an outgoing message
392392
setModeIdle();
393-
393+
394394
if (!waitCAD())
395-
return false; // Check channel activity
396-
395+
return false; // Check channel activity
396+
397397
// First octet is the length of the chip payload
398398
// 0 length messages are transmitted but never trigger a receive!
399399
spiWriteData(len + RH_MRF89_HEADER_LEN);

RH_NRF24.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// NRF24.cpp
22
//
33
// Copyright (C) 2012 Mike McCauley
4-
// $Id: RH_NRF24.cpp,v 1.22 2016/04/04 01:40:12 mikem Exp $
4+
// $Id: RH_NRF24.cpp,v 1.23 2017/01/12 23:58:00 mikem Exp $
55

66
#include <RH_NRF24.h>
77

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

191191
if (!waitCAD())
192-
return false; // Check channel activity
192+
return false; // Check channel activity
193193

194194
// Set up the headers
195195
_buf[0] = _txHeaderTo;

0 commit comments

Comments
 (0)