kopia lustrzana https://github.com/dl9rdz/rdz_ttgo_sonde
Merge branch 'dl9rdz:devel' into devel
commit
5a0729068b
|
@ -62,6 +62,20 @@ const int daylightOffset_sec = 0; //UTC
|
|||
boolean connected = false;
|
||||
WiFiUDP udp;
|
||||
WiFiClient client;
|
||||
|
||||
/* Sonde.h: enum SondeType { STYPE_DFM,, STYPE_RS41, STYPE_RS92, STYPE_M10M20, STYPE_M10, STYPE_M20, STYPE_MP3H }; */
|
||||
const char *sondeTypeStrSH[NSondeTypes] = { "DFM", "RS41", "RS92", "Mxx"/*never sent*/, "M10", "M20", "MRZ" };
|
||||
const char *dfmSubtypeStrSH[16] = { NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
"DFM06", // 0x06
|
||||
"PS15", // 0x07
|
||||
NULL, NULL,
|
||||
"DFM09", // 0x0A
|
||||
"DFM17", // 0x0B
|
||||
"DFM09P", // 0x0C
|
||||
"DFM17", // 0x0D
|
||||
NULL, NULL
|
||||
};
|
||||
|
||||
#if FEATURE_SONDEHUB
|
||||
#define SONDEHUB_STATION_UPDATE_TIME (60*60*1000) // 60 min
|
||||
#define SONDEHUB_MOBILE_STATION_UPDATE_TIME (30*1000) // 30 sec
|
||||
|
@ -265,8 +279,7 @@ void setupChannelList() {
|
|||
int active = space[3] == '+' ? 1 : 0;
|
||||
if (space[4] == ' ') {
|
||||
memset(launchsite, ' ', 16);
|
||||
int str_len = strlen(space + 5);
|
||||
strncpy(launchsite, space + 5, str_len > 16 ? 16 : str_len);
|
||||
strncpy(launchsite, space + 5, 16);
|
||||
if (sonde.config.debug == 1) {
|
||||
Serial.printf("Add %f - sondetype: %d (on/off: %d) - site #%d - name: %s\n ", freq, type, active, i, launchsite);
|
||||
}
|
||||
|
@ -592,7 +605,9 @@ void setupConfigData() {
|
|||
sonde.setConfig(line.c_str());
|
||||
}
|
||||
sonde.checkConfig(); // eliminate invalid entries
|
||||
#if FEATURE_SONDEHUB
|
||||
shImportInterval = 5; // refresh now in 5 seconds
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -3212,7 +3227,7 @@ void execOTA() {
|
|||
Serial.printf("Updating file %s (%d bytes)\n", fn, len);
|
||||
char fnstr[17];
|
||||
memset(fnstr, ' ', 16);
|
||||
strncpy(fnstr, fn, strlen(fn));
|
||||
strncpy(fnstr, fn, 16);
|
||||
fnstr[16] = 0;
|
||||
disp.rdis->drawString(0, 2 * dispys, fnstr);
|
||||
File f = SPIFFS.open(fn, FILE_WRITE);
|
||||
|
@ -3558,18 +3573,7 @@ enum SHState { SH_DISCONNECTED, SH_CONNECTING, SH_CONN_IDLE, SH_CONN_APPENDING,
|
|||
SHState shState = SH_DISCONNECTED;
|
||||
time_t shStart = 0;
|
||||
|
||||
/* Sonde.h: enum SondeType { STYPE_DFM,, STYPE_RS41, STYPE_RS92, STYPE_M10M20, STYPE_M10, STYPE_M20, STYPE_MP3H }; */
|
||||
const char *sondeTypeStrSH[NSondeTypes] = { "DFM", "RS41", "RS92", "Mxx"/*never sent*/, "M10", "M20", "MRZ" };
|
||||
const char *dfmSubtypeStrSH[16] = { NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
"DFM06", // 0x06
|
||||
"PS15", // 0x07
|
||||
NULL, NULL,
|
||||
"DFM09", // 0x0A
|
||||
"DFM17", // 0x0B
|
||||
"DFM09P", // 0x0C
|
||||
"DFM17", // 0x0D
|
||||
NULL, NULL
|
||||
};
|
||||
|
||||
|
||||
void sondehub_reply_handler(WiFiClient * client) {
|
||||
// sondehub handler for tasks to be done even if no data is to be sent:
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "Sonde.h"
|
||||
//#include <WiFi.h>
|
||||
#include <WiFiUdp.h>
|
||||
|
||||
#include <time.h>
|
||||
class Chasemapper {
|
||||
public:
|
||||
static int send(WiFiUDP &udb, SondeInfo *si);
|
||||
|
|
|
@ -223,6 +223,10 @@ static int32_t getint24(uint8_t *data) {
|
|||
return (int32_t)(data[2]|(data[1]<<8)|(data[0]<<16) );
|
||||
}
|
||||
|
||||
static int32_t getint24_r(uint8_t *data) {
|
||||
return (int32_t)(data[0]|(data[1]<<8)|(data[2]<<16) );
|
||||
}
|
||||
|
||||
static int16_t getint16(uint8_t *data) {
|
||||
return (int16_t)(data[1]|((uint16_t)data[0]<<8));
|
||||
}
|
||||
|
@ -329,12 +333,13 @@ int M10M20::decodeframeM10(uint8_t *data) {
|
|||
si->dir = dir;
|
||||
si->validPos = 0x3f;
|
||||
// m10 temp
|
||||
float T = NAN;
|
||||
{
|
||||
const float p0 = 1.07303516e-03, p1 = 2.41296733e-04, p2 = 2.26744154e-06, p3 = 6.52855181e-08;
|
||||
const float Rs[3] = { 12.1e3 , 36.5e3 , 475.0e3 };
|
||||
const float Rp[3] = { 1e20 , 330.0e3 , 2000.0e3 };
|
||||
uint8_t sct = data[62];
|
||||
float rt = getint16_r(data+63) & (0xFFF);
|
||||
float T = NAN;
|
||||
if(rt!=0 && sct<3) {
|
||||
rt = (4095-rt)/rt - (Rs[sct]/Rp[sct]);
|
||||
if(rt>0) {
|
||||
|
@ -347,6 +352,31 @@ int M10M20::decodeframeM10(uint8_t *data) {
|
|||
}
|
||||
}
|
||||
si->temperature = T;
|
||||
}
|
||||
|
||||
// m10 battery
|
||||
uint16_t batADC = (uint16_t)getint16_r(data+0x45);
|
||||
si->batteryVoltage = 2.709 * batADC * 2.5/1023.0;
|
||||
|
||||
// m10 humidity
|
||||
{
|
||||
float cRHc55 = ((float)(uint32_t)getint24_r(data+0x35)) / (uint32_t)getint24_r(data+0x32);
|
||||
float TH = -273.15;
|
||||
const float huRs = 22.1e3;
|
||||
const float p0 = 4.42606809e-03, p1 = -6.58184309e-04, p2 = 8.95735557e-05, p3 = -2.84347503e-06;
|
||||
float R = huRs / ( (4095.0/getint16_r(data+0x59)) - 1 );
|
||||
if(R>0) TH += 1/( p0 + p1*log(R) + p2*log(R)*log(R) + p3*log(R)*log(R)*log(R) );
|
||||
//float Tc = T;
|
||||
float rh = (cRHc55-0.8955)/0.002;
|
||||
const float T0=0.0, T1=-30.0;
|
||||
//float T = Tc;
|
||||
if(T<T0) rh += T0 - T/5.5;
|
||||
if(T<T1) rh *= 1.0 + (T1-T)/75.0;
|
||||
if(rh<0.0) rh=0.0;
|
||||
if(rh>100.0) rh=100.0;
|
||||
si->relativeHumidity = rh;
|
||||
}
|
||||
Serial.printf("hum: %.2f batt: %.2f\n", si->relativeHumidity, si->batteryVoltage);
|
||||
|
||||
uint32_t gpstime = getint32(data+10);
|
||||
uint16_t gpsweek = getint16(data+32);
|
||||
|
|
|
@ -16,6 +16,7 @@ void mqttCallback(char* topic, byte* payload, unsigned int length) {
|
|||
Serial.println();
|
||||
}
|
||||
|
||||
static char buffer[21];
|
||||
void MQTT::init(const char* host, uint16_t port, const char* id, const char *username, const char *password, const char *prefix)
|
||||
{
|
||||
WiFi.hostByName(host, this->ip);
|
||||
|
@ -26,8 +27,8 @@ void MQTT::init(const char* host, uint16_t port, const char* id, const char *use
|
|||
|
||||
Serial.println("[MQTT] pubsub client");
|
||||
mqttClient.setServer(ip, port);
|
||||
char buffer[20];
|
||||
snprintf(buffer, 20, "%s%6ld", id, random(0, 1000));
|
||||
snprintf(buffer, 20, "%s%04d", id, (int)random(0, 1000));
|
||||
buffer[20] = 0;
|
||||
mqttClient.setClientId(buffer);
|
||||
if (strlen(password) > 0) {
|
||||
mqttClient.setCredentials(username, password);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const char *version_name = "rdzTTGOsonde";
|
||||
const char *version_id = "devel20210930";
|
||||
const char *version_id = "devel20211003";
|
||||
const int SPIFFS_MAJOR=2;
|
||||
const int SPIFFS_MINOR=16;
|
||||
|
|
Ładowanie…
Reference in New Issue