This repository has been archived by the owner on Dec 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.pio | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
language: python | ||
python: | ||
- "2.7" | ||
sudo: false | ||
cache: | ||
directories: | ||
- "~/.platformio" | ||
install: | ||
- pip install -U platformio | ||
- platformio update | ||
script: | ||
- platformio check --fail-on-defect low --fail-on-defect medium --fail-on-defect high |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name=LoRa-APRS-Lib | ||
version=0.0.1 | ||
author=Peter Buchegger <[email protected]> | ||
maintainer=Peter Buchegger <[email protected]> | ||
sentence=LoRa APRS library for ESP32 | ||
paragraph=This library will provide an simple interface to LoRa APRS. | ||
category=Communication | ||
url=https://github.com/peterus/LoRa-APRS-Lib | ||
architectures=* | ||
includes=LoRa-APRS.h | ||
depends=LoRa,APRS-Decoder-Lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[env:native] | ||
platform = native | ||
lib_compat_mode = off | ||
test_build_project_src = yes | ||
lib_deps = | ||
LoRa | ||
APRS-Decoder-Lib | ||
https://github.com/peterus/UnixHostDuino | ||
check_tool = cppcheck | ||
check_flags = | ||
cppcheck: --suppress=*:*.pio\* --suppress=unusedFunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#include <LoRa_APRS.h> | ||
|
||
LoRa_APRS::LoRa_APRS() | ||
: rx_frequency(LORA_RX_FREQUENCY), tx_frequency(LORA_TX_FREQUENCY), spreadingfactor(LORA_SPREADING_FACTOR), | ||
signalbandwidth(LORA_SIGNAL_BANDWIDTH), codingrate4(LORA_CODING_RATE4), _LastReceivedMsg(0) | ||
{ | ||
SPI.begin(LORA_SCK, LORA_MISO, LORA_MOSI, LORA_CS); | ||
LoRa.setPins(LORA_CS, LORA_RST, LORA_IRQ); | ||
} | ||
|
||
bool LoRa_APRS::begin() | ||
{ | ||
if (!LoRa.begin(rx_frequency)) | ||
{ | ||
return false; | ||
} | ||
LoRa.setSpreadingFactor(spreadingfactor); | ||
LoRa.setSignalBandwidth(signalbandwidth); | ||
LoRa.setCodingRate4(codingrate4); | ||
LoRa.enableCrc(); | ||
return true; | ||
} | ||
|
||
bool LoRa_APRS::hasMessage() | ||
{ | ||
if(!LoRa.parsePacket()) | ||
{ | ||
return false; | ||
} | ||
// read header: | ||
char dummy[4]; | ||
LoRa.readBytes(dummy, 3); | ||
if(dummy[0] != '<') | ||
{ | ||
// is no APRS message, ignore message | ||
while(LoRa.available()) | ||
{ | ||
LoRa.read(); | ||
} | ||
return false; | ||
} | ||
// read APRS data: | ||
String str; | ||
while(LoRa.available()) | ||
{ | ||
str += (char)LoRa.read(); | ||
} | ||
_LastReceivedMsg = std::shared_ptr<APRSMessage>(new APRSMessage()); | ||
_LastReceivedMsg->decode(str); | ||
return true; | ||
} | ||
|
||
std::shared_ptr<APRSMessage> LoRa_APRS::getMessage() | ||
{ | ||
return _LastReceivedMsg; | ||
} | ||
|
||
int LoRa_APRS::getMessageRssi() | ||
{ | ||
return LoRa.packetRssi(); | ||
} | ||
|
||
float LoRa_APRS::getMessageSnr() | ||
{ | ||
return LoRa.packetSnr(); | ||
} | ||
|
||
// cppcheck-suppress unusedFunction | ||
void LoRa_APRS::sendMessage(const std::shared_ptr<APRSMessage> msg) | ||
{ | ||
LoRa.setFrequency(tx_frequency); | ||
String data = msg->encode(); | ||
LoRa.beginPacket(); | ||
// Header: | ||
LoRa.write('<'); | ||
LoRa.write(0xFF); | ||
LoRa.write(0x01); | ||
// APRS Data: | ||
LoRa.write((const uint8_t *)data.c_str(), data.length()); | ||
LoRa.endPacket(); | ||
LoRa.setFrequency(rx_frequency); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#ifndef LORA_H_ | ||
#define LORA_H_ | ||
|
||
#include <memory> | ||
#include <Arduino.h> | ||
#include <LoRa.h> | ||
#include <APRS-Decoder.h> | ||
|
||
#define LORA_RX_FREQUENCY (433775000) | ||
#define LORA_TX_FREQUENCY (433900000) | ||
#define LORA_SPREADING_FACTOR (12) | ||
#define LORA_SIGNAL_BANDWIDTH (125E3) | ||
#define LORA_CODING_RATE4 (5) | ||
|
||
class LoRa_APRS | ||
{ | ||
public: | ||
LoRa_APRS(); | ||
bool begin(); | ||
|
||
bool hasMessage(); | ||
std::shared_ptr<APRSMessage> getMessage(); | ||
int getMessageRssi(); | ||
float getMessageSnr(); | ||
|
||
void sendMessage(const std::shared_ptr<APRSMessage> msg); | ||
|
||
// settings: | ||
long rx_frequency; | ||
long tx_frequency; | ||
int spreadingfactor; | ||
long signalbandwidth; | ||
int codingrate4; | ||
|
||
private: | ||
std::shared_ptr<APRSMessage> _LastReceivedMsg; | ||
}; | ||
|
||
#endif |