kopia lustrzana https://github.com/dl9rdz/rdz_ttgo_sonde
42 wiersze
1009 B
C++
42 wiersze
1009 B
C++
#include "Chasemapper.h"
|
|
|
|
extern const char *sondeTypeStrSH[];
|
|
|
|
int Chasemapper::send(WiFiUDP &udp, SondeInfo *si) {
|
|
char buf[1024];
|
|
struct tm tim;
|
|
time_t t = si->time;
|
|
gmtime_r(&t, &tim);
|
|
uint8_t realtype = si->type;
|
|
if (TYPE_IS_METEO(realtype)) {
|
|
realtype = si->subtype == 1 ? STYPE_M10 : STYPE_M20;
|
|
}
|
|
sprintf(buf, "{ \"type\": \"PAYLOAD_SUMMARY\","
|
|
"\"callsign\": \"%s\","
|
|
"\"latitude\": %g,"
|
|
"\"longitude\": %g,"
|
|
"\"altitude\": %d,"
|
|
"\"speed\": %d,"
|
|
"\"heading\": %d,"
|
|
"\"time\": \"%02d:%02d:%02d\","
|
|
"\"model\": \"%s\","
|
|
"\"freq\": \"%.3f MHz\","
|
|
"\"temp\": %g }",
|
|
si->ser,
|
|
si->lat,
|
|
si->lon,
|
|
(int)si->alt,
|
|
(int)(si->hs * 1.9438445), // m/s into knots
|
|
(int)si->dir,
|
|
tim.tm_hour, tim.tm_min, tim.tm_sec,
|
|
sondeTypeStrSH[realtype],
|
|
si->freq,
|
|
si->temperature);
|
|
Serial.printf("Sending chasemapper json: %s\n", buf);
|
|
udp.beginPacket(sonde.config.cm.host, sonde.config.cm.port);
|
|
udp.write((const uint8_t *)buf, strlen(buf));
|
|
udp.endPacket();
|
|
return 0;
|
|
}
|
|
|