Minor refactoring

pull/15/head
sh123 2020-06-17 13:32:00 +03:00
rodzic 1c421e5269
commit 04f76c7301
6 zmienionych plików z 24 dodań i 20 usunięć

Wyświetl plik

@ -8,7 +8,7 @@ Can be used in two modes:
- **LoRa APRS iGate RX/TX server over WiFi + Digipeater** - **LoRa APRS iGate RX/TX server over WiFi + Digipeater**
- **RF to APRS-IS gating**, it will connect to your WiFI and will forward received APRS positions from RF LoRa into the APRS-IS network, it also reports client signal level, by appending it into the APRS comment, so you can see your signal reports in different locations (could be enabled or disabled from config). This way, it is also possible to setup portable iGate by connecting to your mobile phone's hotspot and provide power from the phone USB port by using OTA cable - **RF to APRS-IS gating**, it will connect to your WiFI and will forward received APRS positions from RF LoRa into the APRS-IS network, it also reports client signal level, by appending it into the APRS comment, so you can see your signal reports in different locations (could be enabled or disabled from config). This way, it is also possible to setup portable iGate by connecting to your mobile phone's hotspot and provide power from the phone USB port by using OTA cable
- **APRS-IS to RF gating**, it is possible to enable it together with the filter in the config, so APRS-IS data will be forwarded to RF - **APRS-IS to RF gating**, it is possible to enable it together with the filter in the config, so APRS-IS data will be forwarded to RF
- **RF digirepating** for `WIDEn-n`, `TRACEn-n` new style paths, for `TRACE` will insert own callsign before digipeating - **RF digirepating** for `WIDEn-n` new style paths
- **Beaconing**, own station periodic beacon announcement to APRS-IS and RF - **Beaconing**, own station periodic beacon announcement to APRS-IS and RF
# Compatible Boards # Compatible Boards

Wyświetl plik

@ -56,11 +56,8 @@ String Callsign::ToString() const
bool Callsign::Digirepeat() bool Callsign::Digirepeat()
{ {
// only WIDE and TRACE supported if (IsPath()) {
if (call_.startsWith("WIDE*") || call_.startsWith("TRACE*")) return false; if (ssid_ > 0) {
if ((call_.startsWith("WIDE") || call_.startsWith("TRACE")) && call_.length() >= 5) {
char wideLevel = call_.charAt(4);
if ((wideLevel == '1' || wideLevel == '2' || wideLevel == '3') && ssid_ > 0) {
if (--ssid_ == 0) { if (--ssid_ == 0) {
call_ += "*"; call_ += "*";
} }
@ -92,8 +89,10 @@ bool Callsign::encode(byte *txPtr, int bufferLength) const
return true; return true;
} }
bool Callsign::fromString(String callsign) bool Callsign::fromString(const String &inputCallsign)
{ {
String callsign = inputCallsign;
// "ABCDEF-XX" // "ABCDEF-XX"
if (callsign.length() > CallsignSize + 2 || callsign.length() == 0) return false; if (callsign.length() > CallsignSize + 2 || callsign.length() == 0) return false;

Wyświetl plik

@ -17,6 +17,8 @@ public:
inline bool IsValid() const { return isValid_; }; inline bool IsValid() const { return isValid_; };
inline bool IsTrace() const { return call_.startsWith("TRACE"); } inline bool IsTrace() const { return call_.startsWith("TRACE"); }
inline bool IsWide() const { return call_.startsWith("WIDE"); }
inline bool IsPath() const { return IsWide(); }
String ToString() const; String ToString() const;
bool ToBinary(byte *txPayload, int bufferLength) const; bool ToBinary(byte *txPayload, int bufferLength) const;
@ -26,7 +28,7 @@ public:
private: private:
bool encode(byte *txPtr, int bufferLength) const; bool encode(byte *txPtr, int bufferLength) const;
bool fromString(String callsign); bool fromString(const String &callsign);
bool fromBinary(const byte *rxPtr, int payloadLength); bool fromBinary(const byte *rxPtr, int payloadLength);
private: private:

Wyświetl plik

@ -83,7 +83,7 @@ String Payload::ToString(String customComment)
txt += customComment; txt += customComment;
} }
return txt + String("\n"); return txt;
} }
bool Payload::Digirepeat(const Callsign &ownCallsign) bool Payload::Digirepeat(const Callsign &ownCallsign)

Wyświetl plik

@ -15,7 +15,7 @@ public:
inline bool IsValid() const { return isValid_; } inline bool IsValid() const { return isValid_; }
String ToString(String customComment); String ToString(String customComment=String());
int ToBinary(byte *txPayload, int bufferLength) const; int ToBinary(byte *txPayload, int bufferLength) const;
bool Digirepeat(const Callsign &ownCallsign); bool Digirepeat(const Callsign &ownCallsign);

Wyświetl plik

@ -167,9 +167,9 @@ void Service::sendBeacon()
if (payload.IsValid()) { if (payload.IsValid()) {
sendToLora(payload); sendToLora(payload);
if (enableRfToIs_) { if (enableRfToIs_) {
sendToAprsis(payload.ToString(String())); sendToAprsis(payload.ToString());
} }
Serial.println("Sent beacon"); Serial.println("Periodic beacon is sent");
} }
else { else {
Serial.println("Beacon payload is invalid"); Serial.println("Beacon payload is invalid");
@ -177,6 +177,7 @@ void Service::sendBeacon()
previousBeaconMs_ = currentMs; previousBeaconMs_ = currentMs;
} }
} }
void Service::sendToAprsis(String aprsMessage) void Service::sendToAprsis(String aprsMessage)
{ {
if (needsWifi() && WiFi.status() != WL_CONNECTED) { if (needsWifi() && WiFi.status() != WL_CONNECTED) {
@ -185,7 +186,7 @@ void Service::sendToAprsis(String aprsMessage)
if (needsAprsis() && !aprsisConn_.connected()) { if (needsAprsis() && !aprsisConn_.connected()) {
reconnectAprsis(); reconnectAprsis();
} }
aprsisConn_.print(aprsMessage); aprsisConn_.println(aprsMessage);
if (!persistentConn_) { if (!persistentConn_) {
aprsisConn_.stop(); aprsisConn_.stop();
@ -281,13 +282,15 @@ void Service::onLoraDataAvailable(int packetSize)
if (payload.IsValid()) { if (payload.IsValid()) {
String textPayload = payload.ToString(addSignalReport_ ? signalReport : String()); String textPayload = payload.ToString(addSignalReport_ ? signalReport : String());
Serial.print(textPayload); Serial.println(textPayload);
if (enableRfToIs_ && !isClient_) { if (enableRfToIs_ && !isClient_) {
sendToAprsis(textPayload); sendToAprsis(textPayload);
Serial.println("Packet sent to APRS-IS");
} }
if (enableRepeater_ && payload.Digirepeat(ownCallsign_)) { if (enableRepeater_ && payload.Digirepeat(ownCallsign_)) {
sendToLora(payload); sendToLora(payload);
Serial.println("Packet digirepeated");
} }
} }
else { else {