diff --git a/lib/APRS-IS/APRS-IS.cpp b/lib/APRS-IS/APRS-IS.cpp deleted file mode 100644 index af34a7c..0000000 --- a/lib/APRS-IS/APRS-IS.cpp +++ /dev/null @@ -1,107 +0,0 @@ -#include -#include "APRS-IS.h" - -APRS_IS::APRS_IS(const String & user, const String & passcode, const String & tool_name, const String & version) - : _user(user), _passcode(passcode), _tool_name(tool_name), _version(version) -{ -} - -bool APRS_IS::connect(const String & server, const int port) -{ - const String login = "user " + _user + " pass " + _passcode + " vers " + _tool_name + " " + _version + "\n\r"; - return connect_(server, port, login); -} - -bool APRS_IS::connect(const String & server, const int port, const String & filter) -{ - const String login = "user " + _user + " pass " + _passcode + " vers " + _tool_name + " " + _version + " filter " + filter + "\n\r"; - return connect_(server, port, login); -} - -bool APRS_IS::connect_(const String & server, const int port, const String & login_line) -{ - if(!_client.connect(server.c_str(), port)) - { - logPrintlnE("Something went wrong on connecting! Is the server reachable?"); - return false; - } - sendMessage(login_line); - while(true) - { - String line = _client.readStringUntil('\n'); - if(line.indexOf("logresp") != -1) - { - if(line.indexOf("unverified") == -1) - { - return true; - } - else - { - logPrintlnE("User can not be verified with passcode!"); - return false; - } - } - } - return true; -} - -bool APRS_IS::connected() -{ - return _client.connected(); -} - -bool APRS_IS::sendMessage(const String & message) -{ - if(!connected()) - { - return false; - } - _client.println(message); - return true; -} - -bool APRS_IS::sendMessage(const std::shared_ptr message) -{ - if(!connected()) - { - return false; - } - _client.println(message->encode() + "\n"); - return true; -} - -int APRS_IS::available() -{ - return _client.available(); -} - -String APRS_IS::getMessage() -{ - String line; - if (_client.available() > 0) - { - line = _client.readStringUntil('\n'); - } - return line; -} - -std::shared_ptr APRS_IS::getAPRSMessage() -{ - String line; - if (_client.available() > 0) - { - line = _client.readStringUntil('\n'); - } - if(line.startsWith("#")) - { - //logPrintlnD(line); - return 0; - } - if(line.length() == 0) - { - return 0; - } - std::shared_ptr msg = std::shared_ptr(new APRSMessage()); - msg->decode(line); - return msg; -} diff --git a/lib/APRS-IS/APRS-IS.h b/lib/APRS-IS/APRS-IS.h deleted file mode 100644 index 256df1e..0000000 --- a/lib/APRS-IS/APRS-IS.h +++ /dev/null @@ -1,35 +0,0 @@ - -#ifndef APRS_IS_Lib_h_ -#define APRS_IS_Lib_h_ - -#include -#include - -class APRS_IS -{ -public: - APRS_IS(const String & user, const String & passcode, const String & tool_name, const String & version); - - bool connect(const String & server, const int port); - bool connect(const String & server, const int port, const String & filter); - bool connect_(const String & server, const int port, const String & login_line); - bool connected(); - - bool sendMessage(const String & message); - bool sendMessage(const std::shared_ptr message); - - int available(); - - String getMessage(); - std::shared_ptr getAPRSMessage(); - -private: - const String _user; - const String _passcode; - const String _tool_name; - const String _version; - WiFiClient _client; -}; - -#endif - diff --git a/platformio.ini b/platformio.ini index c150286..5a17682 100644 --- a/platformio.ini +++ b/platformio.ini @@ -8,6 +8,7 @@ lib_deps = bblanchon/ArduinoJson @ 6.17.0 lewisxhe/AXP202X_Library @ 1.1.2 peterus/APRS-Decoder-Lib @ 0.0.6 + peterus/APRS-IS-Lib @ 0.0.8 peterus/esp-logger @ 0.0.1 peterus/ESP-FTP-Server-Lib @ 0.9.5 check_tool = cppcheck