mirror of
https://github.com/anklimov/lighthub
synced 2025-12-07 12:19:49 +03:00
Now MQTT compatible with test.mosquitto.org free broker (empty User vs NULL user)
Few analog-in fixes. ESP32 compilation broken due doard definition changed. Trying to workaround it
This commit is contained in:
@@ -470,7 +470,7 @@ void Input::analogPoll() {
|
||||
// Mapping
|
||||
if (inputMap && inputMap->type == aJson_Array)
|
||||
{
|
||||
int max;
|
||||
int max=1024;
|
||||
if (aJson.getArraySize(inputMap)>=4)
|
||||
mappedInputVal = map (mappedInputVal,
|
||||
aJson.getArrayItem(inputMap, 0)->valueint,
|
||||
|
||||
@@ -566,6 +566,11 @@ void ip_ready_config_loaded_connecting_to_broker() {
|
||||
|
||||
|
||||
debugSerial<<F("\nAttempting MQTT connection to ")<<servername<<F(":")<<port<<F(" user:")<<user<<F(" ...");
|
||||
if (!strlen(user))
|
||||
{
|
||||
user = NULL;
|
||||
password= NULL;
|
||||
}
|
||||
// wdt_dis(); //potential unsafe for ethernetIdle(), but needed to avoid cyclic reboot if mosquitto out of order
|
||||
if (mqttClient.connect(deviceName, user, password,willTopic,MQTTQOS1,true,willMessage)) {
|
||||
mqttErrorRate = 0;
|
||||
@@ -599,7 +604,7 @@ void ip_ready_config_loaded_connecting_to_broker() {
|
||||
nextLanCheckTime = millis() + 5000;
|
||||
debugSerial<<F("Awaiting for retained topics");
|
||||
} else {
|
||||
debugSerial<<F("failed, rc=")<<mqttClient.state()<<F(" try again in 5 seconds");
|
||||
debugSerial<<F("failed, rc=")<<mqttClient.state()<<F(" try again in 5 seconds")<<endl;
|
||||
nextLanCheckTime = millis() + 5000;
|
||||
#ifdef RESTART_LAN_ON_MQTT_ERRORS
|
||||
mqttErrorRate++;
|
||||
@@ -636,7 +641,7 @@ void onInitialStateInitLAN() {
|
||||
wifi_connection_wait -= 500;
|
||||
debugSerial<<".";
|
||||
}
|
||||
wifiInitialized = true;
|
||||
wifiInitialized = true; //???
|
||||
}
|
||||
#else
|
||||
// Wifi Manager
|
||||
@@ -1215,13 +1220,13 @@ lan_status loadConfigFromHttp(int arg_cnt, char **args)
|
||||
return READ_RE_CONFIG;//-11;
|
||||
}
|
||||
#endif
|
||||
#if defined(__SAM3X8E__) || defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_ESP32)
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
#if defined(__SAM3X8E__) || defined(ARDUINO_ARCH_STM32) //|| defined(ARDUINO_ARCH_ESP32) //|| defined(ARDUINO_ARCH_ESP8266)
|
||||
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
|
||||
WiFiClient configEthClient;
|
||||
#else
|
||||
EthernetClient configEthClient;
|
||||
#endif
|
||||
String response;
|
||||
String response;
|
||||
HttpClient htclient = HttpClient(configEthClient, configServer, 80);
|
||||
//htclient.stop(); //_socket =MAX
|
||||
htclient.setHttpResponseTimeout(4000);
|
||||
@@ -1263,7 +1268,8 @@ lan_status loadConfigFromHttp(int arg_cnt, char **args)
|
||||
return READ_RE_CONFIG;//-11; //Load from NVRAM
|
||||
}
|
||||
#endif
|
||||
#if defined(ARDUINO_ARCH_ESP8266)
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
|
||||
HTTPClient httpClient;
|
||||
String fullURI = "http://";
|
||||
fullURI+=configServer;
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
#include <FS.h> //this needs to be first, or it all crashes and burns...
|
||||
#include <ESP_EEPROM.h>
|
||||
#include <ESP8266HTTPClient.h>
|
||||
//#include <ArduinoHttpClient.h>
|
||||
//#include "HttpClient.h"
|
||||
#include <WiFiManager.h>
|
||||
#include <DNSServer.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
@@ -27,10 +29,12 @@
|
||||
#endif
|
||||
|
||||
#if defined ARDUINO_ARCH_ESP32
|
||||
//#include <FS.h> //this needs to be first, or it all crashes and burns...
|
||||
#include <FS.h> //this needs to be first, or it all crashes and burns...
|
||||
//#include <EEPROM.h>
|
||||
#include <NRFFlashStorage.h>
|
||||
#include <HttpClient.h>
|
||||
//#include "HttpClient.h"
|
||||
//#include <ArduinoHttpClient.h>
|
||||
#include <HTTPClient.h>
|
||||
#include <WiFi.h>
|
||||
#include <WiFiClient.h>
|
||||
#include <WiFiClientSecure.h>
|
||||
|
||||
Reference in New Issue
Block a user