Updated doc + misc...
This commit is contained in:
@ -23,7 +23,6 @@
|
||||
// A4095B000C0000D0000E0000F0000G0000H0000I0000J0000K0000L0218M515N09654O.....*52
|
||||
//
|
||||
#include <FS.h>
|
||||
//#include <ESP8266WiFi.h> // Needed?
|
||||
#include <DNSServer.h>
|
||||
#include <ESP8266mDNS.h>
|
||||
#include <WiFiUdp.h>
|
||||
@ -42,12 +41,10 @@
|
||||
#endif /* ESP32 */
|
||||
|
||||
// Domoticz MQTT configuration by WiFiManager
|
||||
//IPAddress MQipAddr; // MQTT IP address from WiFiManager
|
||||
const char *mqtt_server = "portbuild.home.oav.net";
|
||||
#define mqtt_port 1883
|
||||
|
||||
// configuration values
|
||||
//char cfg_mqtt_server[40];
|
||||
char idx_windir[4]="48";
|
||||
char idx_temp[4] ="52";
|
||||
char idx_rain[4] ="51";
|
||||
@ -181,7 +178,6 @@ void setup_ota() {
|
||||
ArduinoOTA.setHostname(Mqtt_clientid);
|
||||
|
||||
// No auth per default
|
||||
// XXX: Change this
|
||||
ArduinoOTA.setPassword((const char *)OTAPASSWORD);
|
||||
|
||||
ArduinoOTA.onStart([]() {
|
||||
@ -222,13 +218,11 @@ void setup() {
|
||||
wm.setSaveConfigCallback(saveConfigCallback);
|
||||
|
||||
// Setup custom parameters
|
||||
//WiFiManagerParameter custom_mqtt_server("server", "Domoticz MQTT server hostname", cfg_mqtt_server, 40);
|
||||
WiFiManagerParameter custom_idx_windir ("idx1", "Domoticz Index for Wind Virtual Module", idx_windir, 4);
|
||||
WiFiManagerParameter custom_idx_temp ("idx2", "Domoticz Index for Temp/Hum/Baro Virtual Module", idx_temp, 4);
|
||||
WiFiManagerParameter custom_idx_rain ("idx3", "Domoticz Index for Rain Virtual Module", idx_rain, 4);
|
||||
|
||||
// Add all parameters
|
||||
//wm.addParameter(&custom_mqtt_server);
|
||||
wm.addParameter(&custom_idx_windir);
|
||||
wm.addParameter(&custom_idx_temp);
|
||||
wm.addParameter(&custom_idx_rain);
|
||||
@ -251,7 +245,6 @@ void setup() {
|
||||
Serial.println("Connected to WiFi !");
|
||||
|
||||
// Read the updated parameters
|
||||
//strcpy(cfg_mqtt_server, custom_mqtt_server.getValue());
|
||||
strcpy(idx_windir, custom_idx_windir.getValue());
|
||||
strcpy(idx_temp, custom_idx_temp.getValue());
|
||||
strcpy(idx_rain, custom_idx_rain.getValue());
|
||||
@ -262,7 +255,6 @@ void setup() {
|
||||
DynamicJsonBuffer jsonBuffer;
|
||||
|
||||
JsonObject& json = jsonBuffer.createObject();
|
||||
//json["mqtt_server"] = cfg_mqtt_server;
|
||||
json["idx_windir"] = idx_windir;
|
||||
json["idx_temp"] = idx_temp;
|
||||
json["idx_rain"] = idx_rain;
|
||||
@ -282,8 +274,6 @@ void setup() {
|
||||
// Launch OTA stuff
|
||||
setup_ota();
|
||||
|
||||
//Serial.println("");
|
||||
//Serial.println(F("WiFi Connected !"));
|
||||
#if LWIP_IPV6
|
||||
Serial.printf("IPV6 is enabled\n");
|
||||
#else
|
||||
@ -304,13 +294,7 @@ void setup() {
|
||||
pkt_str.reserve(WS3_PKT_LEN);
|
||||
debugln(" -> Packet memory allocated!");
|
||||
|
||||
// Now connect to MQTT
|
||||
//if(WiFi.hostByName(cfg_mqtt_server, MQipAddr) != 1)
|
||||
// Serial.println("ERROR: Unable to resolv MQTT Hostname");
|
||||
//else
|
||||
// Serial.printf("INFO: Hostname %s resolved to %s\n",cfg_mqtt_server, MQipAddr.toString().c_str());
|
||||
client.setServer(mqtt_server, mqtt_port);
|
||||
//client.setServer(MQipAddr, mqtt_port);
|
||||
//client.setCallback(callback);
|
||||
debugln("MQTT started");
|
||||
}
|
||||
@ -421,13 +405,11 @@ void parse_packet(String payload, WS3Packet* p) {
|
||||
p->rain_24h = payload.substring(rain24h_idx+1, rain24h_idx+5).toInt();
|
||||
|
||||
// Then move on to L0200 - temp (0.1°C)
|
||||
// XXX: Check with minus zero temperatures
|
||||
int temp_idx = payload.indexOf('L');
|
||||
p->temp_f = payload.substring(temp_idx+1, temp_idx+5).toInt()*.1;
|
||||
|
||||
// Then move on to M611 - Humidity
|
||||
int humidity_idx = payload.indexOf('M');
|
||||
// p->humidity = payload.substring(humidity_idx+1, humidity_idx+3).toInt()*.1;
|
||||
p->humidity = payload.substring(humidity_idx+1, humidity_idx+3).toInt();
|
||||
|
||||
// Then move on to N10020 - air pressure
|
||||
@ -472,7 +454,6 @@ void clear_pkt(WS3Packet* p) {
|
||||
void print_weather(WS3Packet* p){
|
||||
Serial.print("Wind Direction (realtime): ");
|
||||
Serial.println(p->wind_dir, DEC);
|
||||
//Serial.println(" degrees");
|
||||
Serial.print("Wind direction angle : ");
|
||||
Serial.print(p->wind_angle, DEC);
|
||||
Serial.print(" degree ");
|
||||
@ -769,11 +750,9 @@ void setupSpiffs(){
|
||||
if (json.success()) {
|
||||
debugln("\nparsed json");
|
||||
|
||||
//strcpy(cfg_mqtt_server, json["mqtt_server"]);
|
||||
strcpy(idx_windir, json["idx_windir"]);
|
||||
strcpy(idx_temp, json["idx_temp"]);
|
||||
strcpy(idx_rain, json["idex_rain"]);
|
||||
//Serial.printf("Server : %s, idx (wind/temp/rain) : %s/%s/%s\n", cfg_mqtt_server, idx_windir, idx_temp, idx_rain);
|
||||
} else {
|
||||
Serial.println("failed to load json config");
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user