kopia lustrzana https://github.com/dl9rdz/rdz_ttgo_sonde
cleaning
rodzic
9d883313a9
commit
e5b080d668
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <WiFiUdp.h>
|
#include <WiFiUdp.h>
|
||||||
#include <WiFiClientSecure.h>
|
//#include <WiFiClientSecure.h>
|
||||||
#include <ESPAsyncWebServer.h>
|
#include <ESPAsyncWebServer.h>
|
||||||
#include <SPIFFS.h>
|
#include <SPIFFS.h>
|
||||||
//#include <U8x8lib.h>
|
//#include <U8x8lib.h>
|
||||||
|
@ -50,7 +50,8 @@ boolean connected = false;
|
||||||
WiFiUDP udp;
|
WiFiUDP udp;
|
||||||
WiFiClient client;
|
WiFiClient client;
|
||||||
//WiFiClient rsclient; // Radiosondy client
|
//WiFiClient rsclient; // Radiosondy client
|
||||||
WiFiClientSecure shclient; // Sondehub v2
|
//WiFiClientSecure shclient; // Sondehub v2
|
||||||
|
WiFiClient shclient; // Sondehub v2
|
||||||
|
|
||||||
// KISS over TCP for communicating with APRSdroid
|
// KISS over TCP for communicating with APRSdroid
|
||||||
WiFiServer tncserver(14580);
|
WiFiServer tncserver(14580);
|
||||||
|
@ -2130,141 +2131,8 @@ void loopDecoder() {
|
||||||
tncclient.write(raw, rawlen);
|
tncclient.write(raw, rawlen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sondehub_send_data(&shclient, s, &sonde.config.sondehub);
|
||||||
Serial.println("Sending data to the sondehub v2 DB <--------------------------------->");
|
}
|
||||||
sondehub_send_data(&shclient, s, &sonde.config.sondehub);
|
|
||||||
|
|
||||||
Serial.println("Sending data to the radiosondy.info <--------------------------------->");
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
{"software_name":"BSG TTGO Sonde", "software_version":"v0.2.0", "uploader_callsign":"OH3BSG",
|
|
||||||
"time_received":"YYYY-MM-DDTHH:MM:SS.SSSSSSZ",
|
|
||||||
"manufacturer":"Vaisala",
|
|
||||||
"type":"RS41",
|
|
||||||
"serial":"Radiosonde Serial Number",
|
|
||||||
"frame":1,
|
|
||||||
"datetime":"YYYY-MM-DDTHH:MM:SS.SSSSSSZ",
|
|
||||||
"lat": float,
|
|
||||||
"lon": float,
|
|
||||||
"alt": float
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
char rs_msg[400];
|
|
||||||
char *w;
|
|
||||||
int i;
|
|
||||||
memset(rs_msg, 0, 400);
|
|
||||||
w=rs_msg;
|
|
||||||
sprintf(w, "{\"software_name\":\"BSG TTGO Sonde\", \"software_version\":\"v0.2.0\", \"uploader_callsign\":\"OH3BSG\",");
|
|
||||||
i = strlen(w);
|
|
||||||
sprintf(w+i, " \"serial\":\"%s\",", s->id);
|
|
||||||
i = strlen(w);
|
|
||||||
sprintf(w+i, " \"frame\":%d,", s->frame);
|
|
||||||
i = strlen(w);
|
|
||||||
int sec = s->time % 86400;
|
|
||||||
sprintf(w+i, " \"datetime\": \"%02d%02d%02dz\"", sec/(60*60), (sec%(60*60))/60, sec%60);
|
|
||||||
i = strlen(w);
|
|
||||||
sprintf(w+i, " \"lat\":%02d.%06d,", (int)s->lat, (int)((s->lat - (int)s->lat)*1000000));
|
|
||||||
i = strlen(w);
|
|
||||||
sprintf(w+i, " \"lon\":%03d.%06d,", (int)s->lon, (int)((s->lon - (int)s->lon)*1000000));
|
|
||||||
i = strlen(w);
|
|
||||||
sprintf(w+i, " \"alt\":%d.%02d}", (int)s->alt, (int)((s->alt - (int)s->alt)*100));
|
|
||||||
|
|
||||||
if (!rsclient.connected()) {
|
|
||||||
rsclient.connect("192.168.1.5", 8881);
|
|
||||||
}
|
|
||||||
if (rsclient.write(rs_msg, strlen(rs_msg)) == strlen(rs_msg)) {
|
|
||||||
Serial.println(" Data sent OK");
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
// oh3bsg>APRARX,SONDEGATE,TCPIP,qAR,oh3bsg:;S0650576 *183213h6004.64N/02340.07EO114/024/A=052626 Clb=5.3m/s t=-273.0C h=-1.0% p=-1.0hPa 403.001 MHz Type=RS41 Radiosonde auto_rx v1.5.0 !wPv!\r\n
|
|
||||||
strncat(rs_msg, "oh3bsg>APRARX,SONDEGATE,TCPIP,qAR,oh3bsg:;", 42);
|
|
||||||
strncat(rs_msg, s->id, 10);
|
|
||||||
strncat(rs_msg, " *", 2);
|
|
||||||
// Time convertions
|
|
||||||
time_t t = s->time;
|
|
||||||
int tt = hour(t);
|
|
||||||
char ctemp[3];
|
|
||||||
ctemp[0] = '0' + ((tt/10)%10);
|
|
||||||
ctemp[1] = '0' + (tt%10);
|
|
||||||
ctemp[3] = 0;
|
|
||||||
strncat(rs_msg, ctemp, 2);
|
|
||||||
tt = minute(t);
|
|
||||||
ctemp[0] = '0' + ((tt/10)%10);
|
|
||||||
ctemp[1] = '0' + (tt%10);
|
|
||||||
strncat(rs_msg, ctemp, 2);
|
|
||||||
tt = second(t);
|
|
||||||
ctemp[0] = '0' + ((tt/10)%10);
|
|
||||||
ctemp[1] = '0' + (tt%10);
|
|
||||||
strncat(rs_msg, ctemp, 2);
|
|
||||||
strncat(rs_msg, "h", 1);
|
|
||||||
// Location convertions
|
|
||||||
char location[6];
|
|
||||||
float latlon = s->lat;
|
|
||||||
int deg = abs((int)latlon);
|
|
||||||
sprintf(location, "%02d", deg);
|
|
||||||
strncat(rs_msg, location, 2);
|
|
||||||
float min = abs(latlon - (int)latlon)*60.0;
|
|
||||||
sprintf(location, "%02d", (int)min);
|
|
||||||
strncat(rs_msg, location, 2);
|
|
||||||
int min_des = (min - (int)min)*100;
|
|
||||||
sprintf(location, ".%02dN/", min_des);
|
|
||||||
strncat(rs_msg, location, 5);
|
|
||||||
latlon = s->lon;
|
|
||||||
deg = abs((int)latlon);
|
|
||||||
sprintf(location, "%03d", deg);
|
|
||||||
strncat(rs_msg, location, 3);
|
|
||||||
min = abs(latlon - (int)latlon)*60.0;
|
|
||||||
sprintf(location, "%02d", (int)min);
|
|
||||||
strncat(rs_msg, location, 2);
|
|
||||||
min_des = (min - (int)min)*100;
|
|
||||||
sprintf(location, ".%02dEO", min_des);
|
|
||||||
strncat(rs_msg, location, 5);
|
|
||||||
char temp[50];
|
|
||||||
sprintf(temp, "%03d/%03d", (int)s->dir, (int)s->hs); // datoissa jotain hämärää
|
|
||||||
//sprintf(temp, "%03d/%03d", 0, 0);
|
|
||||||
strncat(rs_msg, temp, 7);
|
|
||||||
sprintf(temp, "/A=%06d ", (int)s->alt);
|
|
||||||
strncat(rs_msg, temp, 10);
|
|
||||||
// Comments
|
|
||||||
//Clb=5.3m/s t=-273.0C h=-1.0% p=-1.0hPa 403.001 MHz Type=RS41 Radiosonde auto_rx v1.5.0
|
|
||||||
sprintf(temp, "Clb=%02dm/s ", (int)s->vs);
|
|
||||||
strncat(rs_msg, temp, 10);
|
|
||||||
int frq_dec = abs(s->freq - (int)s->freq)*1000;
|
|
||||||
sprintf(temp, "%03d.%03d MHz Type=RS41 BSG_TTGO v0.1.0.dev\r\n", (int)s->freq, frq_dec);
|
|
||||||
strncat(rs_msg, temp, 43);
|
|
||||||
// Leave precision part away. http://www.aprs.org/datum.txt
|
|
||||||
|
|
||||||
Serial.println("Radiosondy.info");
|
|
||||||
Serial.println(rs_msg);
|
|
||||||
Serial.println(s->lat);
|
|
||||||
Serial.println(s->lon);
|
|
||||||
Serial.println(s->dir);
|
|
||||||
Serial.println(s->hs);
|
|
||||||
Serial.println(s->alt);
|
|
||||||
Serial.println(s->freq);
|
|
||||||
Serial.println(sizeof(rs_msg));
|
|
||||||
|
|
||||||
|
|
||||||
if (rsclient.write(rs_msg, 148) == 148) {
|
|
||||||
Serial.println(" Data sent OK");
|
|
||||||
// }
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
out_str = ";%s*%sh%s/%sO%s/A=%06d %s %s" % (
|
|
||||||
_object_name, => Sonde_id
|
|
||||||
_aprs_timestamp, => aika
|
|
||||||
lat_str, => lat
|
|
||||||
lon_str, => lon
|
|
||||||
course_speed, => speed
|
|
||||||
alt, => korkeus
|
|
||||||
_aprs_comment,
|
|
||||||
_datum,
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// send to MQTT if enabled
|
// send to MQTT if enabled
|
||||||
if (connected && mqttEnabled) {
|
if (connected && mqttEnabled) {
|
||||||
|
@ -2467,44 +2335,8 @@ void enableNetwork(bool enable) {
|
||||||
mqttclient.init(sonde.config.mqtt.host, sonde.config.mqtt.port, sonde.config.mqtt.id, sonde.config.mqtt.username, sonde.config.mqtt.password, sonde.config.mqtt.prefix);
|
mqttclient.init(sonde.config.mqtt.host, sonde.config.mqtt.port, sonde.config.mqtt.id, sonde.config.mqtt.username, sonde.config.mqtt.password, sonde.config.mqtt.prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
// rsclient.connect("192.168.1.5", 8881);
|
//shclient.setInsecure(); // Skip verification
|
||||||
|
|
||||||
shclient.setInsecure(); // Skip verification
|
|
||||||
sondehub_station_update(&shclient, &sonde.config.sondehub);
|
sondehub_station_update(&shclient, &sonde.config.sondehub);
|
||||||
/*
|
|
||||||
if (!shclient.connect("api.v2.sondehub.org", 443)) {
|
|
||||||
Serial.println("Connection FAILED");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
//sondehub_station_update(&shclient);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
//rsclient.write("user OH3BSG pass 23727 vers BSG-TTGO filter b/OH3BSG", 52);
|
|
||||||
//rsclient.write("{\"software_name\":\"BSG TTGO Sonde\", \"frame\":3}");
|
|
||||||
|
|
||||||
/* Radiosondy
|
|
||||||
if (rsclient.connect("radiosondy.info", 14590)) {
|
|
||||||
Serial.println("Radiosondy connection OK");
|
|
||||||
// Log on
|
|
||||||
if (rsclient.write("user OH3BSG pass 23727 vers BSG-TTGO filter b/OH3BSG \r\n", 55) == 55) {
|
|
||||||
Serial.println(" Log on sent OK");
|
|
||||||
}
|
|
||||||
if (rsclient.write("#filter p/ZZ\r\n", 14) == 14) {
|
|
||||||
Serial.println(" Filter sent OK");
|
|
||||||
}
|
|
||||||
if (rsclient.write("#filter -t/po\r\n", 15) == 15) {
|
|
||||||
Serial.println(" Filter sent OK");
|
|
||||||
}
|
|
||||||
delay(1000);
|
|
||||||
while(rsclient.available()) {
|
|
||||||
char a = rsclient.read();
|
|
||||||
Serial.print(a);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Serial.println("Radiosondy FAIL *************************************************");
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
connected = true;
|
connected = true;
|
||||||
} else {
|
} else {
|
||||||
MDNS.end();
|
MDNS.end();
|
||||||
|
@ -3076,13 +2908,13 @@ void loop() {
|
||||||
/*
|
/*
|
||||||
* Update station data to the sondehub v2 DB
|
* Update station data to the sondehub v2 DB
|
||||||
*/
|
*/
|
||||||
void sondehub_station_update(WiFiClientSecure *client, struct st_sondehub *conf) {
|
void sondehub_station_update(WiFiClient *client, struct st_sondehub *conf) {
|
||||||
char data[200];
|
char data[200];
|
||||||
|
|
||||||
Serial.println("sondehub_station_update()");
|
Serial.println("sondehub_station_update()");
|
||||||
|
|
||||||
if (!client->connected()) {
|
if (!client->connected()) {
|
||||||
if (!client->connect(conf->host, 443)) {
|
if (!client->connect(conf->host, 80)) {
|
||||||
Serial.println("Connection FAILED");
|
Serial.println("Connection FAILED");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3093,65 +2925,40 @@ void sondehub_station_update(WiFiClientSecure *client, struct st_sondehub *conf)
|
||||||
client->println("accept: text/plain");
|
client->println("accept: text/plain");
|
||||||
client->println("Content-Type: application/json");
|
client->println("Content-Type: application/json");
|
||||||
client->print("Content-Length: ");
|
client->print("Content-Length: ");
|
||||||
sprintf(data, "{\
|
sprintf(data, "{"
|
||||||
\"software_name\": \"%s\",\
|
"\"software_name\": \"%s\","
|
||||||
\"software_version\": \"%s\",\
|
"\"software_version\": \"%s\","
|
||||||
\"uploader_callsign\": \"%s\",\
|
"\"uploader_callsign\": \"%s\","
|
||||||
\"uploader_position\": [%s,%s,%s],\
|
"\"uploader_position\": [%s,%s,%s],"
|
||||||
\"uploader_antenna\": \"%s\"\
|
"\"uploader_antenna\": \"%s\""
|
||||||
}", version_name, version_id, conf->callsign, conf->lat, conf->lon, conf->alt, conf->antenna);
|
"}", version_name, version_id, conf->callsign, conf->lat, conf->lon, conf->alt, conf->antenna);
|
||||||
client->println(strlen(data));
|
client->println(strlen(data));
|
||||||
client->println();
|
client->println();
|
||||||
client->println(data);
|
client->println(data);
|
||||||
Serial.println(strlen(data));
|
Serial.println(strlen(data));
|
||||||
Serial.println(data);
|
Serial.println(data);
|
||||||
//delay(1000);
|
|
||||||
String response = client->readString();
|
String response = client->readString();
|
||||||
Serial.println(response);
|
Serial.println(response);
|
||||||
client->stop();
|
client->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
void sondehub_send_data(WiFiClient *client, SondeInfo *s, struct st_sondehub *conf) {
|
||||||
// {"software_name":"BSG TTGO Sonde", "software_version":"v0.2.3", "uploader_callsign":"OH3BSG", "time_received":"2021-04-11T12:07:09.000Z", "manufacturer":"Vaisala", "type":"RS41", "serial":"S0730222", "frame":3776, "datetime":"2021-04-11T12:07:09.000Z", "lat":60.929744, "lon":024.661953, "alt":11030.75}
|
|
||||||
// curl -X PUT "https://api.v2.sondehub.org/sondes/telemetry"
|
|
||||||
// -H "accept: text/plain"
|
|
||||||
// -H "Date: Thu, 22 Apr 2021 14:48:00 GMT"
|
|
||||||
// -H "Content-Type: application/json"
|
|
||||||
// -d "[ { \"software_name\": \"string\",
|
|
||||||
// \"software_version\": \"string\",
|
|
||||||
// \"uploader_callsign\": \"string\",
|
|
||||||
// \"time_received\": \"2021-04-22T14:46:31.652Z\",
|
|
||||||
// \"manufacturer\": \"Vaisala\",
|
|
||||||
// \"type\": \"RS41\",
|
|
||||||
// \"serial\": \"string\",
|
|
||||||
// \"frame\": 0,
|
|
||||||
// \"datetime\": \"2021-04-22T14:46:31.652Z\",
|
|
||||||
// \"lat\": 0,
|
|
||||||
// \"lon\": 0,
|
|
||||||
// \"alt\": 0,
|
|
||||||
// \"subtype\": \"RS41-SG\",
|
|
||||||
// \"frequency\": 0,
|
|
||||||
// \"temp\": 0,
|
|
||||||
// \"humidity\": 0,
|
|
||||||
// \"vel_h\": 0,
|
|
||||||
// \"vel_v\": 0,
|
|
||||||
// \"pressure\": 0,
|
|
||||||
// \"heading\": 0,
|
|
||||||
// \"batt\": 0,
|
|
||||||
// \"sats\": 0,
|
|
||||||
// \"xdata\": \"string\",
|
|
||||||
// \"snr\": 0,
|
|
||||||
// \"rssi\": 0,
|
|
||||||
// \"uploader_position\": [ 62.00, 24.5, 170.3 ],
|
|
||||||
// \"uploader_antenna\": \"string\" }]"
|
|
||||||
//
|
|
||||||
void sondehub_send_data(WiFiClientSecure *client, SondeInfo *s, struct st_sondehub *conf) {
|
|
||||||
Serial.println("sondehub_send_data()");
|
Serial.println("sondehub_send_data()");
|
||||||
|
|
||||||
char rs_msg[400];
|
char rs_msg[400];
|
||||||
char *w;
|
char *w;
|
||||||
char *weekdays[8] = {"?", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; // weekday 1=Sun, 2=mon ... 7=Sat
|
// char *weekdays[8] = {"?", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; // weekday 1=Sun, 2=mon ... 7=Sat
|
||||||
int i;
|
int i;
|
||||||
|
uint16_t _year;
|
||||||
|
uint8_t _month, _day, _hour, _minute, _second;
|
||||||
|
|
||||||
|
time_t t = s->time;
|
||||||
|
_year = year(t);
|
||||||
|
_month = month(t);
|
||||||
|
_day = day(t);
|
||||||
|
_hour = hour(t);
|
||||||
|
_minute = minute(t);
|
||||||
|
_second = second(t);
|
||||||
|
|
||||||
memset(rs_msg, 0, 400);
|
memset(rs_msg, 0, 400);
|
||||||
w=rs_msg;
|
w=rs_msg;
|
||||||
|
@ -3161,14 +2968,14 @@ void sondehub_send_data(WiFiClientSecure *client, SondeInfo *s, struct st_sondeh
|
||||||
"\"software_name\": \"%s\","
|
"\"software_name\": \"%s\","
|
||||||
"\"software_version\": \"%s\","
|
"\"software_version\": \"%s\","
|
||||||
"\"uploader_callsign\": \"%s\","
|
"\"uploader_callsign\": \"%s\","
|
||||||
"\"time_received\": \"2021-04-22T14:46:31.652Z\","
|
"\"time_received\": \"%d-%02d-%02dT%02d:%02d:%02d.000Z\","
|
||||||
"\"manufacturer\": \"Vaisala\","
|
"\"manufacturer\": \"Vaisala\"," // TODO:
|
||||||
"\"type\": \"RS41\","
|
"\"type\": \"RS41\"," // TODO:
|
||||||
"\"serial\": \"%s\","
|
"\"serial\": \"%s\","
|
||||||
"\"frame\": %d,"
|
"\"frame\": %d,"
|
||||||
"\"datetime\": \"2021-04-22T14:46:31.652Z\","
|
"\"datetime\": \"%d-%02d-%02dT%02d:%02d:%02d.000Z\","
|
||||||
"\"lat\": %02d.%06d,"
|
"\"lat\": %02d.%06d,"
|
||||||
"\"lon\": %03d.%06d,"
|
"\"lon\": %d.%06d,"
|
||||||
"\"alt\": %d.%02d,"
|
"\"alt\": %d.%02d,"
|
||||||
// "\"subtype\": \"RS41-SG\","
|
// "\"subtype\": \"RS41-SG\","
|
||||||
// "\"frequency\": 0,"
|
// "\"frequency\": 0,"
|
||||||
|
@ -3182,16 +2989,22 @@ void sondehub_send_data(WiFiClientSecure *client, SondeInfo *s, struct st_sondeh
|
||||||
// "\"sats\": 0,"
|
// "\"sats\": 0,"
|
||||||
// "\"xdata\": \"string\","
|
// "\"xdata\": \"string\","
|
||||||
// "\"snr\": 0,"
|
// "\"snr\": 0,"
|
||||||
"\"rssi\": %d,"
|
// "\"rssi\": %d"
|
||||||
// "\"uploader_position\": [ 62.00, 24.5, 170.3 ],"
|
"\"uploader_position\": [ %s, %s, %s ],"
|
||||||
// "\"uploader_antenna\": \"string\""
|
"\"uploader_antenna\": \"%s\""
|
||||||
"}]",
|
"}]",
|
||||||
version_name, version_id, conf->callsign, s->id, s->frame, (int)s->lat, (int)((s->lat - (int)s->lat)*1000000),
|
version_name, version_id, conf->callsign,
|
||||||
(int)s->lon, (int)((s->lon - (int)s->lon)*1000000), (int)s->alt, (int)((s->alt - (int)s->alt)*100), s->rssi
|
_year, _month, _day, _hour, _minute, _second,
|
||||||
|
s->id, s->frame,
|
||||||
|
_year, _month, _day, _hour, _minute, _second,
|
||||||
|
(int)s->lat, (int)((s->lat - (int)s->lat)*1000000),
|
||||||
|
(int)s->lon, (int)((s->lon - (int)s->lon)*1000000), (int)s->alt, (int)((s->alt - (int)s->alt)*100),
|
||||||
|
conf->lat, conf->lon, conf->alt, conf->antenna
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!client->connected()) {
|
if (!client->connected()) {
|
||||||
if (!client->connect(conf->host, 443)) {
|
Serial.println("NO CONNECTION");
|
||||||
|
if (!client->connect(conf->host, 80)) {
|
||||||
Serial.println("Connection FAILED");
|
Serial.println("Connection FAILED");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3199,115 +3012,26 @@ void sondehub_send_data(WiFiClientSecure *client, SondeInfo *s, struct st_sondeh
|
||||||
client->println("PUT /sondes/telemetry HTTP/1.1");
|
client->println("PUT /sondes/telemetry HTTP/1.1");
|
||||||
client->print("Host: ");
|
client->print("Host: ");
|
||||||
client->println(conf->host);
|
client->println(conf->host);
|
||||||
|
// -H "Date: Thu, 22 Apr 2021 14:48:00 GMT"
|
||||||
client->println("accept: text/plain");
|
client->println("accept: text/plain");
|
||||||
client->println("Content-Type: application/json");
|
client->println("Content-Type: application/json");
|
||||||
client->print("Content-Length: ");
|
client->print("Content-Length: ");
|
||||||
client->println(strlen(w));
|
client->println(strlen(w));
|
||||||
client->println();
|
client->println();
|
||||||
client->println(w);
|
client->println(w);
|
||||||
Serial.println(strlen(w));
|
//Serial.println(strlen(w));
|
||||||
Serial.println(w);
|
Serial.println(w);
|
||||||
//delay(1000);
|
//delay(1000);
|
||||||
String response = client->readString();
|
//String response = client->readString();
|
||||||
Serial.println(response);
|
//Serial.println(response);
|
||||||
client->stop();
|
//client->stop();
|
||||||
|
|
||||||
/*
|
|
||||||
sprintf(w, "[{\"software_name\":\"%s\", \"software_version\":\"%s\", \"uploader_callsign\":\"OH3BSG\",", version_name, version_id);
|
|
||||||
// time_t t = now();
|
|
||||||
time_t t = s->time;
|
|
||||||
i = strlen(w);
|
|
||||||
sprintf(w+i, " \"time_received\":\"%04d-%02d-%02dT%02d:%02d:%02d.000Z\",", year(t), month(t), day(t), hour(t), minute(t), second(t));
|
|
||||||
i = strlen(w);
|
|
||||||
sprintf(w+i, " \"manufacturer\":\"%s\",", "Vaisala"); // ToDo: update this later Now it can be hardcoded
|
|
||||||
i = strlen(w);
|
|
||||||
// Serial.println(s->typestr);
|
|
||||||
// Serial.println(sondeTypeLongStr[s->type]);
|
|
||||||
if (s->typestr==NULL) {
|
|
||||||
sprintf(w+i, " \"type\":\"%s\",", s->typestr);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sprintf(w+i, " \"type\":\"%s\",", sondeTypeLongStr[s->type]); // ToDo: Check subtype => if not then type
|
|
||||||
}
|
|
||||||
i = strlen(w);
|
|
||||||
sprintf(w+i, " \"serial\":\"%s\",", s->id);
|
|
||||||
i = strlen(w);
|
|
||||||
sprintf(w+i, " \"frame\":%d,", s->frame);
|
|
||||||
i = strlen(w);
|
|
||||||
// int sec = s->time % 86400;
|
|
||||||
// sprintf(w+i, " \"datetime\": \"%02d%02d%02dz\"", sec/(60*60), (sec%(60*60))/60, sec%60); // TODO
|
|
||||||
sprintf(w+i, " \"datetime\":\"%04d-%02d-%02dT%02d:%02d:%02d.000Z\",", year(t), month(t), day(t), hour(t), minute(t), second(t));
|
|
||||||
i = strlen(w);
|
|
||||||
sprintf(w+i, " \"lat\":%02d.%06d,", (int)s->lat, (int)((s->lat - (int)s->lat)*1000000));
|
|
||||||
i = strlen(w);
|
|
||||||
sprintf(w+i, " \"lon\":%03d.%06d,", (int)s->lon, (int)((s->lon - (int)s->lon)*1000000));
|
|
||||||
i = strlen(w);
|
|
||||||
sprintf(w+i, " \"alt\":%d.%02d}]", (int)s->alt, (int)((s->alt - (int)s->alt)*100));
|
|
||||||
*/
|
|
||||||
// char headers[300];
|
|
||||||
/*
|
|
||||||
sprintf(headers,
|
|
||||||
"PUT /sondes/telemetry HTTP/1.1\r\n Host:&s\r\nUser-Agent: BSGTTGO-0.2.3\r\nContent-Type: application/json\r\nDate: %s, %02d %s %d %02d:%02d:%02d GMT\r\nContent-Length: %d",
|
|
||||||
/conf->host"api.v2.sondehub.org", weekdays[weekday(t)], day(t), monthShortStr(month(t)), year(t), hour(t), minute(t), second(t), strlen(rs_msg));
|
|
||||||
*/
|
|
||||||
// sprintf(headers,
|
|
||||||
// "PUT /sondes/telemetry HTTP/1.1\r\naccept: text/plain\r\nHost: %s\r\nUser-Agent: BSGTTGO-0.2.3\r\nContent-Type: application/json\r\nDate: %s, %02d %s %d %02d:%02d:%02d GMT\r\nContent-Length: ",
|
|
||||||
// conf->host, weekdays[weekday(t)], day(t), monthShortStr(month(t)), year(t), hour(t), minute(t), second(t));
|
|
||||||
//sondehub_send(client, conf, headers, rs_msg);
|
|
||||||
/*
|
|
||||||
Serial.println(rs_msg);
|
|
||||||
Serial.print("Date: ");
|
|
||||||
Serial.print(weekdays[weekday(t)]);
|
|
||||||
Serial.print(", ");
|
|
||||||
Serial.print(day(t));
|
|
||||||
Serial.print(" ");
|
|
||||||
Serial.print(monthShortStr(month(t)));
|
|
||||||
Serial.print(" ");
|
|
||||||
Serial.println(year(t));
|
|
||||||
//Serial.println(monthShortStr(month(t)));
|
|
||||||
//Serial.println(weekdays[weekday(t)]);
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
if (!client->connected()) {
|
|
||||||
if (!client->connect(conf->host, 443)) {
|
|
||||||
Serial.println("Connection FAILED");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Headers
|
|
||||||
// {'User-Agent': 'autorx-1.5.1', 'Content-Encoding': 'gzip', 'Content-Type': 'application/json', 'Date': 'Sun, 11 Apr 2021 18:04:09 GMT'}
|
|
||||||
client->println("PUT /sondes/telemetry HTTP/1.1");
|
|
||||||
client->print("Host: ");
|
|
||||||
client->println(conf->host);
|
|
||||||
client->println("User-Agent': 'BSGTTGO-0.2.3");
|
|
||||||
//client->println("accept: text/plain");
|
|
||||||
client->println("Content-Type: application/json");
|
|
||||||
client->println("Date: Fri, 16 Apr 2021 05:48:44 GMT");
|
|
||||||
client->print("Content-Length: ");
|
|
||||||
client->println(strlen(rs_msg));
|
|
||||||
client->println();
|
|
||||||
client->println(rs_msg);
|
|
||||||
//delay(1000);
|
|
||||||
String response = client->readString();
|
|
||||||
Serial.println(response);
|
|
||||||
client->stop();
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
if (!rsclient.connected()) {
|
|
||||||
rsclient.connect("192.168.1.5", 8881);
|
|
||||||
}
|
|
||||||
if (rsclient.write(rs_msg, strlen(rs_msg)) == strlen(rs_msg)) {
|
|
||||||
Serial.println(" Data sent OK");
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int sondehub_send(WiFiClientSecure *client, struct st_sondehub *conf, char *headers, char *data) {
|
/*
|
||||||
|
int sondehub_send(WiFiClient *client, struct st_sondehub *conf, char *headers, char *data) {
|
||||||
Serial.println("sondehub_send");
|
Serial.println("sondehub_send");
|
||||||
if (!client->connected()) {
|
if (!client->connected()) {
|
||||||
if (!client->connect(conf->host, 443)) {
|
if (!client->connect(conf->host, 80)) {
|
||||||
Serial.println("Connection FAILED");
|
Serial.println("Connection FAILED");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -3316,14 +3040,14 @@ int sondehub_send(WiFiClientSecure *client, struct st_sondehub *conf, char *head
|
||||||
client->println(strlen(data));
|
client->println(strlen(data));
|
||||||
client->println();
|
client->println();
|
||||||
client->println(data);
|
client->println(data);
|
||||||
Serial.print(headers);
|
//Serial.print(headers);
|
||||||
Serial.println(strlen(data));
|
//Serial.println(strlen(data));
|
||||||
Serial.println();
|
//Serial.println();
|
||||||
Serial.println(data);
|
//Serial.println(data);
|
||||||
//delay(1000);
|
//delay(1000);
|
||||||
String response = client->readString();
|
String response = client->readString();
|
||||||
Serial.println(response);
|
Serial.println(response);
|
||||||
client->stop();
|
//client->stop();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
// End of sondehub v2 related codes
|
// End of sondehub v2 related codes
|
|
@ -91,7 +91,7 @@ ephftp=www.ngs.noaa.gov/cors/rinex/
|
||||||
#-------------------------------#
|
#-------------------------------#
|
||||||
# local use only, do not feed to public services
|
# local use only, do not feed to public services
|
||||||
# data not sanitized / quality checked, outliers not filtered out
|
# data not sanitized / quality checked, outliers not filtered out
|
||||||
axudp.active=1
|
axudp.active=0
|
||||||
axudp.host=192.168.42.20
|
axudp.host=192.168.42.20
|
||||||
axudp.port=9002
|
axudp.port=9002
|
||||||
axudp.symbol=/O
|
axudp.symbol=/O
|
||||||
|
@ -111,7 +111,7 @@ tcp.idformat=0
|
||||||
# mqtt settings
|
# mqtt settings
|
||||||
#-------------------------------#
|
#-------------------------------#
|
||||||
# data not sanitized / quality checked, outliers not filtered out
|
# data not sanitized / quality checked, outliers not filtered out
|
||||||
mqtt.active=1
|
mqtt.active=0
|
||||||
mqtt.id=BSG_MQTT
|
mqtt.id=BSG_MQTT
|
||||||
mqtt.ip=192.168.1.5
|
mqtt.ip=192.168.1.5
|
||||||
mqtt.port=1884
|
mqtt.port=1884
|
||||||
|
|
Ładowanie…
Reference in New Issue