add LORA gateway parameters
following lora api library def https://github.com/sandeepmistry/arduino-LoRa/blob/master/API.md
This commit is contained in:
1 parent
325437a72a
commit
7eb231c41e
2 files changed
+28
-1
No files matched your search
@@ -71,6 +71,8 @@ void LORAtoMQTT(){
|
||||
packet ="";
|
||||
for (int i = 0; i < packetSize; i++) { packet += (char) LoRa.read(); }
|
||||
LORAdata.set("rssi", (int)LoRa.packetRssi());
|
||||
LORAdata.set("snr",(float)LoRa.packetSnr());
|
||||
LORAdata.set("pferror",(float)LoRa.packetFrequencyError());
|
||||
LORAdata.set("packetSize", (int)packetSize);
|
||||
LORAdata.set("message", (char *)packet.c_str());
|
||||
pub(subjectLORAtoMQTT,LORAdata);
|
||||
@@ -82,7 +84,23 @@ void LORAtoMQTT(){
|
||||
if (strcmp(topicOri,subjectMQTTtoLORA) == 0){
|
||||
trc(F("MQTTtoLORA json"));
|
||||
const char * message = LORAdata["message"];
|
||||
int txPower = LORAdata["txpower"]|LORA_TX_POWER;
|
||||
int spreadingFactor = LORAdata["spreadingfactor"]|LORA_SPREADING_FACTOR;
|
||||
long int frequency = LORAdata["frequency "]|LORA_BAND;
|
||||
long int signalBandwidth = LORAdata["signalbandwidth"]|LORA_SIGNAL_BANDWIDTH;
|
||||
int codingRateDenominator = LORAdata["codingrate"]|LORA_CODING_RATE;
|
||||
int preambleLength = LORAdata["preamblelength"]|LORA_PREAMBLE_LENGTH;
|
||||
byte syncWord = LORAdata["syncword"]|LORA_SYNC_WORD;
|
||||
bool Crc = LORAdata["enablecrc"];
|
||||
if (message) {
|
||||
LoRa.setTxPower(txPower);
|
||||
LoRa.setFrequency(frequency);
|
||||
LoRa.setSpreadingFactor(spreadingFactor);
|
||||
LoRa.setSignalBandwidth(signalBandwidth);
|
||||
LoRa.setCodingRate4(codingRateDenominator);
|
||||
LoRa.setPreambleLength(preambleLength);
|
||||
LoRa.setSyncWord(syncWord);
|
||||
if (Crc) LoRa.enableCrc();
|
||||
LoRa.beginPacket();
|
||||
LoRa.print(message);
|
||||
LoRa.endPacket();
|
||||
|
||||
+10
-1
@@ -27,7 +27,16 @@
|
||||
#define subjectLORAtoMQTT Base_Topic Gateway_Name "/LORAtoMQTT"
|
||||
#define subjectMQTTtoLORA Base_Topic Gateway_Name "/commands/MQTTtoLORA"
|
||||
#define subjectGTWLORAtoMQTT Base_Topic Gateway_Name "/LORAtoMQTT"
|
||||
#define LORA_BAND 868E6
|
||||
|
||||
//Default parameters used when the parameters are not set in the json data
|
||||
#define LORA_BAND 868E6
|
||||
#define LORA_SIGNAL_BANDWIDTH 125E3
|
||||
#define LORA_TX_POWER 17
|
||||
#define LORA_SPREADING_FACTOR 7
|
||||
#define LORA_CODING_RATE 5
|
||||
#define LORA_PREAMBLE_LENGTH 8
|
||||
#define LORA_SYNC_WORD 0x12
|
||||
|
||||
|
||||
/*-------------------PIN DEFINITIONS----------------------*/
|
||||
//TTGO LORA BOARD ESP32 PIN DEFINITION
|
||||
|
||||
Reference in new issue
Block a user