mirror of
https://github.com/anklimov/lighthub
synced 2025-12-08 04:39: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
|
// Mapping
|
||||||
if (inputMap && inputMap->type == aJson_Array)
|
if (inputMap && inputMap->type == aJson_Array)
|
||||||
{
|
{
|
||||||
int max;
|
int max=1024;
|
||||||
if (aJson.getArraySize(inputMap)>=4)
|
if (aJson.getArraySize(inputMap)>=4)
|
||||||
mappedInputVal = map (mappedInputVal,
|
mappedInputVal = map (mappedInputVal,
|
||||||
aJson.getArrayItem(inputMap, 0)->valueint,
|
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(" ...");
|
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
|
// 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)) {
|
if (mqttClient.connect(deviceName, user, password,willTopic,MQTTQOS1,true,willMessage)) {
|
||||||
mqttErrorRate = 0;
|
mqttErrorRate = 0;
|
||||||
@@ -599,7 +604,7 @@ void ip_ready_config_loaded_connecting_to_broker() {
|
|||||||
nextLanCheckTime = millis() + 5000;
|
nextLanCheckTime = millis() + 5000;
|
||||||
debugSerial<<F("Awaiting for retained topics");
|
debugSerial<<F("Awaiting for retained topics");
|
||||||
} else {
|
} 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;
|
nextLanCheckTime = millis() + 5000;
|
||||||
#ifdef RESTART_LAN_ON_MQTT_ERRORS
|
#ifdef RESTART_LAN_ON_MQTT_ERRORS
|
||||||
mqttErrorRate++;
|
mqttErrorRate++;
|
||||||
@@ -636,7 +641,7 @@ void onInitialStateInitLAN() {
|
|||||||
wifi_connection_wait -= 500;
|
wifi_connection_wait -= 500;
|
||||||
debugSerial<<".";
|
debugSerial<<".";
|
||||||
}
|
}
|
||||||
wifiInitialized = true;
|
wifiInitialized = true; //???
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// Wifi Manager
|
// Wifi Manager
|
||||||
@@ -1215,13 +1220,13 @@ lan_status loadConfigFromHttp(int arg_cnt, char **args)
|
|||||||
return READ_RE_CONFIG;//-11;
|
return READ_RE_CONFIG;//-11;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(__SAM3X8E__) || defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_ESP32)
|
#if defined(__SAM3X8E__) || defined(ARDUINO_ARCH_STM32) //|| defined(ARDUINO_ARCH_ESP32) //|| defined(ARDUINO_ARCH_ESP8266)
|
||||||
#if defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
|
||||||
WiFiClient configEthClient;
|
WiFiClient configEthClient;
|
||||||
#else
|
#else
|
||||||
EthernetClient configEthClient;
|
EthernetClient configEthClient;
|
||||||
#endif
|
#endif
|
||||||
String response;
|
String response;
|
||||||
HttpClient htclient = HttpClient(configEthClient, configServer, 80);
|
HttpClient htclient = HttpClient(configEthClient, configServer, 80);
|
||||||
//htclient.stop(); //_socket =MAX
|
//htclient.stop(); //_socket =MAX
|
||||||
htclient.setHttpResponseTimeout(4000);
|
htclient.setHttpResponseTimeout(4000);
|
||||||
@@ -1263,7 +1268,8 @@ lan_status loadConfigFromHttp(int arg_cnt, char **args)
|
|||||||
return READ_RE_CONFIG;//-11; //Load from NVRAM
|
return READ_RE_CONFIG;//-11; //Load from NVRAM
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(ARDUINO_ARCH_ESP8266)
|
|
||||||
|
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
|
||||||
HTTPClient httpClient;
|
HTTPClient httpClient;
|
||||||
String fullURI = "http://";
|
String fullURI = "http://";
|
||||||
fullURI+=configServer;
|
fullURI+=configServer;
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
#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 <ESP_EEPROM.h>
|
#include <ESP_EEPROM.h>
|
||||||
#include <ESP8266HTTPClient.h>
|
#include <ESP8266HTTPClient.h>
|
||||||
|
//#include <ArduinoHttpClient.h>
|
||||||
|
//#include "HttpClient.h"
|
||||||
#include <WiFiManager.h>
|
#include <WiFiManager.h>
|
||||||
#include <DNSServer.h>
|
#include <DNSServer.h>
|
||||||
#include <ESP8266WebServer.h>
|
#include <ESP8266WebServer.h>
|
||||||
@@ -27,10 +29,12 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined ARDUINO_ARCH_ESP32
|
#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 <EEPROM.h>
|
||||||
#include <NRFFlashStorage.h>
|
#include <NRFFlashStorage.h>
|
||||||
#include <HttpClient.h>
|
//#include "HttpClient.h"
|
||||||
|
//#include <ArduinoHttpClient.h>
|
||||||
|
#include <HTTPClient.h>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <WiFiClient.h>
|
#include <WiFiClient.h>
|
||||||
#include <WiFiClientSecure.h>
|
#include <WiFiClientSecure.h>
|
||||||
|
|||||||
Reference in New Issue
Block a user