The code I'm running on the Adafruit Feather is different than yours.
Mine is below:
// rf95_reliable_datagram_server.pde
// -*- mode: C++ -*-
// Example sketch showing how to create a simple addressed, reliable messaging server
// with the RHReliableDatagram class, using the RH_RF95 driver to control a RF95 radio.
// It is designed to work with the other example rf95_reliable_datagram_client
// Tested with Anarduino MiniWirelessLoRa, Rocket Scream Mini Ultra Pro with the RFM95W
#include <RHReliableDatagram.h>
#include <RH_RF95.h>
#include <SPI.h>
/* for feather32u4 */
#define RFM95_CS 8
#define RFM95_RST 4
#define RFM95_INT 7
#define CLIENT_ADDRESS 1
#define SERVER_ADDRESS 2
// Singleton instance of the radio driver
RH_RF95 rf95(RFM95_CS, RFM95_INT);
//RH_RF95 driver(5, 2); // Rocket Scream Mini Ultra Pro with the RFM95W
#define RF95_FREQ 915.0
// Class to manage message delivery and receipt, using the driver declared above
RHReliableDatagram manager(rf95, SERVER_ADDRESS);
// Blinky on receipt
#define LED 13
void setup()
{
pinMode(LED, OUTPUT);
pinMode(RFM95_RST, OUTPUT);
digitalWrite(RFM95_RST, HIGH);
Serial.begin(9600);
delay(100);
//while (!Serial) ; // Wait for serial port to be available
Serial.println("Feather LoRa TX Test!");
// manual reset
digitalWrite(RFM95_RST, LOW);
delay(10);
digitalWrite(RFM95_RST, HIGH);
delay(10);
if (!manager.init())
Serial.println("init failed");
rf95.setTxPower(10, false);
rf95.setFrequency(915.0);
Serial.println("..this is the Adafuit Feather LoRa as server +RFM95 @915mhz");
// Defaults after init are 434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on
// The default transmitter power is 13dBm, using PA_BOOST.
// If you are using RFM95/96/97/98 modules which uses the PA_BOOST transmitter pin, then
// you can set transmitter powers from 5 to 23 dBm:
//driver.setTxPower(23, false);
// You can optionally require this module to wait until Channel Activity
// Detection shows no activity on the channel before transmitting by setting
// the CAD timeout to non-zero:
// driver.setCADTimeout(10000);
}
uint8_t data[] = "And hello back to you";
// Dont put this on the stack:
uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
void loop()
{
if (manager.available())
{
// Wait for a message addressed to us from the client
uint8_t len = sizeof(buf);
uint8_t from;
if (manager.recvfromAck(buf, &len, &from))
{
Serial.print("got request from : 0x");
Serial.print(from, HEX);
Serial.print(": ");
Serial.println((char*)buf);
Serial.print("RSSI: ");
Serial.println(rf95.lastRssi(), DEC);
Serial.println();
digitalWrite(LED, HIGH); //Flash LED 2 times to indicate received message.
delay(250);
digitalWrite(LED, LOW);
delay(250);
digitalWrite(LED, HIGH);
delay(250);
digitalWrite(LED, LOW);
delay(250);
// Send a reply back to the originator client
if (!manager.sendtoWait(data, sizeof(data), from))
Serial.println("sendtoWait failed");
}
}
}
The next important thing that you need to change is the spreading factor code on the Adafruit library in these files on the lines mentioned below:
Have a look at RH_RF95.cpp line 120-136 and RH_RF95.h line 579-597.
In the RH_RF95.cpp file line 120-136 in the Adafruit library make sure it matches what I have in the Photon library your using:
// No Sync Words in LORA mode.
// setModemConfig(Bw500Cr45Sf128); // 1: Bw = 500kHz, Cr = 4/5, Sf7 = 128 chips/symbol,CRC on --> I gott a delay of: RSSI= 33, 105 ms sending this --> Hello World!!
// setModemConfig(Bw125Cr45Sf128); // 2: Bw = 125kHz, Cr = 4/5, Sf7 = 128 chips/symbol,CRC on --> I gott a delay of: RSSI= 36, 230 ms sending this --> Hello World!!
/// setModemConfig(Bw125Cr48Sf4096); // 3; Bw = 125kHz, Cr = 4/8, Sf12 = 4096 chips/symbol,CRC on Slow+long range --->>> delay I got of 2176ms (DO NOT WORK NOW) sending this --> Hello World!(1923m con el GPS tracker 5dbm) last used on 02/04/2017
// setModemConfig(Bw31_25Cr48Sf512); // 4: Bw = 31.25kHz, Cr = 4/8, Sf9 = 512 chips/symbol,CRC on --> I gott a delay of: RSSI= 39, 2990 ms sending this --> Hello World!! (872m con el GPS tracker 5dbm)
// setModemConfig(BW41_7Cr45Sf512); // 5: Bw = 41.7kHz, Cr = 4/5, Sf9 = 512 chips/symbol,CRC on --> I gott a delay of: RSSI= 39, 1816 ms sending this --> Hello World!!
// setModemConfig(BW62_5Cr45Sf1024); // 6: Bw = 62.5kHz, Cr = 4/5, Sf10 = 1024 chips/symbol,CRC on Slow+long range--->>> delay I got of 1652ms ( NOW DO NOT WORK!!)sending this --> Hello World!
// setModemConfig(BW62_5Cr45Sf512); // 7: Bw = 62.5kHz, Cr = 4/5, Sf9 = 512 chips/symbol,CRC on --> I gott a delay of: RSSI= 40, 1816 ms sending this --> Hello World!! (665m con el gps tracker 5dbm)
// setModemConfig(BW256_7Cr45sf128); // 8: Bw = 256 kHz, Cr = 4/5, Sf7 = 128 chips/symbol,CRC on --> I gott a delay of: RSSI= 35, 145 ms sending this --> Hello World!!
// setModemConfig(BW125_7Cr45sf128); // 9: Bw = 125 kHz, Cr = 4/5, Sf7 = 128 chips/symbol,CRC on --> I gott a delay of: RSSI= 39, 219 ms sending this --> Hello World!!
// setModemConfig(BW62_57Cr45sf128); // 10: Bw = 62.5kHz, Cr = 4/5, Sf7 = 128 chips/symbol,CRC on --> I gott a delay of: RSSI= 36, 376 ms sending this --> Hello World!!
setModemConfig(BW125CR46SF9); // 11: BW = 125 Khz, Cr = 4/6, SF9 = 512 chips/symbol,CRC on --> I gott a delay of: RSSI= 36, 647 ms sending this --> Hello World!
// setModemConfig(BW62_5CR45SF9); // 12: Bw = 62.5khz, Cr = 4/5, Sf8 = 256 chips/symbol,CRC on --> I gott a delay of: RSSI= 36, 688 ms sending this --> Hello World!
// setModemConfig(BW62_5CR46SF10); // 13: Bw = 62.5khz, Cr = 4/6, Sf10 = 1024 chips/symbol,CRC on --> I gott a delay of: RSSI= 40, 2595 ms sending this --> Hello World!
// setModemConfig(BW62_5CR45SF11); // 14: Bw = 62.5khz, Cr = 4/5, Sf11 = 2048 chips/symbol,CRC on --> DO NOT WORK sending this --> Hello World!
// setModemConfig(BW125CR45SF11); // 15: Bw = 125 khz, Cr = 4/5, Sf11 = 2048 chips/symbol,CRC on--> DO NOT WORK sending this --> Hello World!
// setModemConfig(BW125CR45SF10); // 16: Bw = 125khz, Cr = 4/5, Sf10 = 1024 chips/symbol,CRC on--> DO NOT WORK sending this --> Hello World!
// setModemConfig(BW31_25CR45SF9); // 17: Bw = 31.25khz, Cr = 4/5, Sf8 = 256 chips/symbol,CRC on--> I gott a delay of: RSSI= 39, 1313 ms sending this --> Hello World! (858m con el GPS tracker 5dbm)
//setModemConfig(BW41_7CR45SF9); // 18: Bw = 41.7khz, Cr = 4/5, Sf8 = 256 chips/symbol, CRC on.
And in the RH_RF95.h line 579-597 in the Adafruit library make sure it matches what we are using in the Photon library below:
typedef enum
{
Bw125Cr45Sf128 = 0, ///1: Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on. Default medium range
Bw500Cr45Sf128, ///2: Bw = 500 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on. Fast+short range
Bw31_25Cr48Sf512, ///3: Bw = 31.25 kHz, Cr = 4/8, Sf = 512chips/symbol, CRC on. Slow+long range
Bw125Cr48Sf4096, ///4: Bw = 125 kHz, Cr = 4/8, Sf = 4096chips/symbol, CRC on. Slow+long range
BW41_7Cr45Sf512, ///5: Bw = 41.7 kHz, Cr = 4/5, Sf = 512chips/symbol, CRC on
BW62_5Cr45Sf1024, ///6: Bw = 62.5 kHz, Cr = 4/5, Sf = 1024 chips/symbol, CRC on
BW62_5Cr45Sf512, ///7: Bw = 62.5 kHz, Cr = 4/5, Sf = 512 chips/symbol, CRC on
BW256_7Cr45sf128, ///8: Bw = 256 kHz, Cr = 4/5, Sf7 = 128chips/symbol, CRC on
BW125_7Cr45sf128, ///9: Bw = 125 kHz, Cr = 4/5, Sf7 = chips/symbol, CRC on
BW62_57Cr45sf128, ///10: Bw = 62.5 kHz, Cr = 4/5, Sf7 = chips/symbol, CRC on
BW125CR46SF9, ///11: Bw = 125 kHz, Cr = 4/6, Sf9 = chips/symbol, CRC on
BW62_5CR45SF9, ///12: Bw = 62.5 khz, Cr = 4/5, Sf8 = 256 chips/symbol, CRC on.
BW62_5CR46SF10, ///13: Bw = 62.5 khz, Cr = 4/6, Sf10 = 1024 chips/symbol, CRC on.
BW62_5CR45SF11, ///14: Bw = 62.5 khz, Cr = 4/5, Sf11 = 2048 chips/symbol, CRC on.
BW125CR45SF11, ///15: Bw = 125 khz, Cr = 4/5, Sf11 = 2048 chips/symbol, CRC on.
BW125CR45SF10, ///16: Bw = 125 khz, Cr = 4/5, Sf10 = 1024 chips/symbol, CRC on.
BW31_25CR45SF9, ///17: Bw = 31.25khz, Cr = 4/5, Sf8 = 256 chips/symbol, CRC on.
BW41_7CR45SF9, ///18: Bw = 41.7khz, Cr = 4/5, Sf8 = 256 chips/symbol, CRC on
} ModemConfigChoice;
They need to match what were using in the Photon Radio Head library to get longer range communication working with the Reliable Datagram library code.
It didn't work for me until I change this.
I learned about it here: