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

Loading…
Cancel
Save