1
0
Fork 0

Intelligently add the velocity/speed/bearing data to the APRS message.

ycs232-kbc
Jonathan Naylor 6 years ago
parent 0446deefad
commit 4ddbd34f9b

@ -276,20 +276,20 @@ void CAPRSWriter::sendIdFrameMobile()
buffer[ret] = '\0';
// Parse the GPS data
char* p1 = ::strtok((char*)buffer, ","); // Latitude
char* p2 = ::strtok(NULL, ","); // Longitude
char* p3 = ::strtok(NULL, ","); // Altitude (m)
char* p4 = ::strtok(NULL, ","); // Speed (kms/h)
char* p5 = ::strtok(NULL, "\n"); // Bearing
char* pLatitude = ::strtok((char*)buffer, ","); // Latitude
char* pLongitude = ::strtok(NULL, ","); // Longitude
char* pAltitude = ::strtok(NULL, ","); // Altitude (m)
char* pVelocity = ::strtok(NULL, ","); // Velocity (kms/h)
char* pBearing = ::strtok(NULL, "\n"); // Bearing
if (p1 == NULL || p2 == NULL || p3 == NULL || p4 == NULL || p5 == NULL)
if (pLatitude == NULL || pLongitude == NULL || pAltitude == NULL || pVelocity == NULL || pBearing == NULL)
return;
float rawLatitude = ::atof(p1);
float rawLongitude = ::atof(p2);
float rawAltitude = ::atof(p3);
float rawSpeed = ::atof(p4);
float rawBearing = ::atof(p5);
float rawLatitude = ::atof(pLatitude);
float rawLongitude = ::atof(pLongitude);
float rawAltitude = ::atof(pAltitude);
float rawVelocity = ::atof(pVelocity);
float rawBearing = ::atof(pBearing);
char desc[200U];
if (m_txFrequency != 0U) {
@ -337,12 +337,18 @@ void CAPRSWriter::sendIdFrameMobile()
server.append("S");
char output[500U];
::sprintf(output, "%s>APDG03,TCPIP*,qAC,%s:!%s%cD%s%c&%03.0f/%03.0f/A=%06.0f%s %s",
::sprintf(output, "%s>APDG03,TCPIP*,qAC,%s:!%s%cD%s%c&",
m_callsign.c_str(), server.c_str(),
lat, (rawLatitude < 0.0F) ? 'S' : 'N',
lon, (rawLongitude < 0.0F) ? 'W' : 'E',
rawBearing, rawSpeed * 0.539957F,
float(rawAltitude) * 3.28F, band, desc);
lon, (rawLongitude < 0.0F) ? 'W' : 'E');
if (::strlen(pBearing) > 0U && ::strlen(pVelocity) > 0U)
::sprintf(output + ::strlen(output), "%03.0f/%03.0f", rawBearing, rawVelocity * 0.539957F);
if (::strlen(pAltitude) > 0U)
::sprintf(output + ::strlen(output), "/A=%06.0f", float(rawAltitude) * 3.28F);
::sprintf(output + ::strlen(output), "%s %s", band, desc);
m_thread->write(output);

Loading…
Cancel
Save