Skip to content

Commit

Permalink
fixes for no path present
Browse files Browse the repository at this point in the history
  • Loading branch information
peterus committed Mar 18, 2020
1 parent 972b0bd commit a8055d2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
3 changes: 2 additions & 1 deletion examples/basic_decode/basic_decode.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ void setup()
"AB1CDE-10>APRS,AB1CDE:=1234.12N/12345.12E-QTH von AB1CDE",
"OE5ABC-10>APMI06,TCPIP*,qAC,T2AUSTRIA:@101733z1234.12N/12345.12E_247/000g002t043r002p002P...h83b10191WX - Linz - Nord",
"BH4ABC-10>APET51,TCPIP*,qAC,T2SWEDEN:!1234.12N/12345.12E-PHG4450 B8/BH4ABC APRS iGate 438.650MHz 12.4V",
"VK2ABC-9>APOTC1,WIDE1-1,WIDE2-1,qAR,VK2BLR:/184701h1234.12S/12345.12E>/A=001074 13.6V 27C DD Com Nicsan"
"VK2ABC-9>APOTC1,WIDE1-1,WIDE2-1,qAR,VK2BLR:/184701h1234.12S/12345.12E>/A=001074 13.6V 27C DD Com Nicsan",
"OE5BPA-10>APRS:!1418.68N/04819.82E_.../...g...t050r...p...P...h00b......DHT22"
};
size_t n = sizeof(message) / sizeof(message[0]);
for(size_t i = 0; i < n; i++)
Expand Down
20 changes: 14 additions & 6 deletions src/APRSMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,25 @@ bool APRSMessage::decode(const String & message)
{
int pos_src = message.indexOf('>');
_source = message.substring(0, pos_src);
int pos_dest = message.indexOf(',');
_destination = message.substring(pos_src+1, pos_dest);
int pos_path = message.indexOf(':');
_path = message.substring(pos_dest+1, pos_path);
_body->decode(message.substring(pos_path+1));
_path = message.substring(pos_src + 1, pos_path);
int path_spliter = _path.indexOf(',');
_destination = _path.substring(0, path_spliter);
if(path_spliter != -1)
{
_path = _path.substring(_path.indexOf(',') + 1);
}
else
{
_path = "";
}
_body->decode(message.substring(pos_path + 1));
return true;
}

String APRSMessage::toString() const
{
return "Source: " + _source + ", Destination: " + _destination + ", Path: " + _path + ", " + _body->toString();
return "Source: \"" + _source + "\", Destination: \"" + _destination + "\", Path: \"" + _path + "\", " + _body->toString();
}

/*
Expand Down Expand Up @@ -111,5 +119,5 @@ bool APRSBody::decode(const String & message)

String APRSBody::toString() const
{
return "Data: " + _data;
return "Data: \"" + _data + "\"";
}
Binary file removed src/APRSMessage.o
Binary file not shown.
Binary file removed src/APRSPosition.o
Binary file not shown.

0 comments on commit a8055d2

Please sign in to comment.