fixing APRS-IS lib

This commit is contained in:
Peter Buchegger 2022-03-19 23:51:18 +01:00
parent 00603fe2c3
commit 4a39c5e2f2
3 changed files with 25 additions and 15 deletions

View file

@ -8,34 +8,32 @@ void APRS_IS::setup(const String &user, const String &passcode, const String &to
_version = version;
}
bool APRS_IS::connect(const String &server, const int port) {
APRS_IS::ConnectionStatus 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) {
APRS_IS::ConnectionStatus 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) {
APRS_IS::ConnectionStatus 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;
return ERROR_CONNECTION;
}
sendMessage(login_line);
while (true) {
String line = _client.readStringUntil('\n');
if (line.indexOf("logresp") != -1) {
if (line.indexOf("unverified") == -1) {
return true;
return SUCCESS;
} else {
logPrintlnE("User can not be verified with passcode!");
return false;
return ERROR_PASSCODE;
}
}
}
return true;
return SUCCESS;
}
bool APRS_IS::connected() {
@ -76,7 +74,6 @@ std::shared_ptr<APRSMessage> APRS_IS::getAPRSMessage() {
line = _client.readStringUntil('\n');
}
if (line.startsWith("#")) {
logPrintlnD(line);
return 0;
}
if (line.length() == 0) {