1
0
Fork 0

Simplify the APRS generation functions.

ycs232-kbc
Jonathan Naylor 9 years ago
parent da2fdabf09
commit 94303d3df4

@ -95,35 +95,10 @@ void CAPRSWriter::write(const unsigned char* source, const char* type, unsigned
longitude = (tempLong - longitude) * 60.0 + longitude * 100.0;
char lat[20U];
if (latitude >= 1000.0F)
::sprintf(lat, "%.2lf", latitude);
else if (latitude >= 100.0F)
::sprintf(lat, "0%.2lf", latitude);
else if (latitude >= 10.0F)
::sprintf(lat, "00%.2lf", latitude);
else
::sprintf(lat, "000%.2lf", latitude);
::sprintf(lat, "%04.2lf", latitude);
char lon[20U];
if (longitude >= 10000.0F)
::sprintf(lon, "%.2lf", longitude);
else if (longitude >= 1000.0F)
::sprintf(lon, "0%.2lf", longitude);
else if (longitude >= 100.0F)
::sprintf(lon, "00%.2lf", longitude);
else if (longitude >= 10.0F)
::sprintf(lon, "000%.2lf", longitude);
else
::sprintf(lon, "0000%.2lf", longitude);
// Convert commas to periods in the latitude, longitude and frequencies
p = ::strchr(lat, ',');
if (p != NULL)
*p = '.';
p = ::strchr(lon, ',');
if (p != NULL)
*p = '.';
::sprintf(lon, "%05.2lf", longitude);
char symbol;
switch (radio) {
@ -214,39 +189,10 @@ void CAPRSWriter::sendIdFrames()
longitude = (tempLong - longitude) * 60.0 + longitude * 100.0;
char lat[20U];
if (latitude >= 1000.0F)
::sprintf(lat, "%.2lf", latitude);
else if (latitude >= 100.0F)
::sprintf(lat, "0%.2lf", latitude);
else if (latitude >= 10.0F)
::sprintf(lat, "00%.2lf", latitude);
else
::sprintf(lat, "000%.2lf", latitude);
::sprintf(lat, "%04.2lf", latitude);
char lon[20U];
if (longitude >= 10000.0F)
::sprintf(lon, "%.2lf", longitude);
else if (longitude >= 1000.0F)
::sprintf(lon, "0%.2lf", longitude);
else if (longitude >= 100.0F)
::sprintf(lon, "00%.2lf", longitude);
else if (longitude >= 10.0F)
::sprintf(lon, "000%.2lf", longitude);
else
::sprintf(lon, "0000%.2lf", longitude);
// Convert commas to periods in the latitude, longitude and frequencies
char* p = ::strchr(lat, ',');
if (p != NULL)
*p = '.';
p = ::strchr(lon, ',');
if (p != NULL)
*p = '.';
p = ::strchr(desc, ',');
if (p != NULL)
*p = '.';
::sprintf(lon, "%05.2lf", longitude);
std::string server = m_callsign;
int pos = server.find_first_of('-');

@ -97,6 +97,8 @@ int CYSFGateway::run()
return 1;
}
setlocale(LC_ALL, "C");
ret = ::LogInitialise(m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), m_conf.getLogDisplayLevel());
if (!ret) {
::fprintf(stderr, "YSFGateway: unable to open the log file\n");

Loading…
Cancel
Save