mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-27 05:06:44 +00:00
Add checks for HASP_USE_MQTT
This commit is contained in:
parent
3a965b18e5
commit
dc82075a96
@ -12,11 +12,14 @@
|
|||||||
|
|
||||||
#include "hasp_log.h"
|
#include "hasp_log.h"
|
||||||
#include "hasp_mdns.h"
|
#include "hasp_mdns.h"
|
||||||
#include "hasp_mqtt.h"
|
|
||||||
#include "hasp_config.h"
|
#include "hasp_config.h"
|
||||||
|
|
||||||
|
#include "hasp_conf.h"
|
||||||
|
#if HASP_USE_MQTT
|
||||||
|
#include "hasp_mqtt.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
uint8_t mdnsEnabled = true;
|
uint8_t mdnsEnabled = true;
|
||||||
const float haspVersion = 0.38;
|
|
||||||
|
|
||||||
void mdnsSetup(const JsonObject & settings)
|
void mdnsSetup(const JsonObject & settings)
|
||||||
{
|
{
|
||||||
@ -27,7 +30,11 @@ void mdnsSetup(const JsonObject & settings)
|
|||||||
void mdnsStart()
|
void mdnsStart()
|
||||||
{
|
{
|
||||||
if(mdnsEnabled) {
|
if(mdnsEnabled) {
|
||||||
|
#if HASP_USE_MQTT > 0
|
||||||
String hasp2Node = mqttGetNodename();
|
String hasp2Node = mqttGetNodename();
|
||||||
|
#else
|
||||||
|
String hasp2Node = "unknown";
|
||||||
|
#endif
|
||||||
// Setup mDNS service discovery if enabled
|
// Setup mDNS service discovery if enabled
|
||||||
/*if(debugTelnetEnabled) {
|
/*if(debugTelnetEnabled) {
|
||||||
}
|
}
|
||||||
@ -46,8 +53,7 @@ void mdnsStart()
|
|||||||
addServiceTxt("arduino", "tcp", "tcp_check", "no");
|
addServiceTxt("arduino", "tcp", "tcp_check", "no");
|
||||||
addServiceTxt("arduino", "tcp", "ssh_upload", "no");
|
addServiceTxt("arduino", "tcp", "ssh_upload", "no");
|
||||||
addServiceTxt("arduino", "tcp", "board", ARDUINO_BOARD);
|
addServiceTxt("arduino", "tcp", "board", ARDUINO_BOARD);
|
||||||
addServiceTxt("arduino", "tcp", "auth_upload", (auth) ? "yes" : "no");
|
addServiceTxt("arduino", "tcp", "auth_upload", (auth) ? "yes" : "no");*/
|
||||||
*/
|
|
||||||
} else {
|
} else {
|
||||||
errorPrintln(String(F("MDNS: %sResponder failed to start ")) + hasp2Node);
|
errorPrintln(String(F("MDNS: %sResponder failed to start ")) + hasp2Node);
|
||||||
};
|
};
|
||||||
|
@ -6,12 +6,17 @@
|
|||||||
#include "hasp_debug.h"
|
#include "hasp_debug.h"
|
||||||
#include "hasp_dispatch.h"
|
#include "hasp_dispatch.h"
|
||||||
#include "hasp_ota.h"
|
#include "hasp_ota.h"
|
||||||
|
|
||||||
|
#include "hasp_conf.h"
|
||||||
|
#if HASP_USE_MQTT
|
||||||
#include "hasp_mqtt.h"
|
#include "hasp_mqtt.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define F_OTA_URL F("otaurl")
|
#define F_OTA_URL F("otaurl")
|
||||||
|
|
||||||
std::string otaUrl = "http://10.1.0.3";
|
std::string otaUrl = "http://10.1.0.3";
|
||||||
int8_t otaPrecentageComplete = -1;
|
int8_t otaPrecentageComplete = -1;
|
||||||
|
int16_t otaPort = 3232;
|
||||||
|
|
||||||
void otaProgress()
|
void otaProgress()
|
||||||
{
|
{
|
||||||
@ -21,7 +26,6 @@ void otaProgress()
|
|||||||
|
|
||||||
void otaSetup(JsonObject settings)
|
void otaSetup(JsonObject settings)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!settings[F_OTA_URL].isNull()) {
|
if(!settings[F_OTA_URL].isNull()) {
|
||||||
char buffer[128];
|
char buffer[128];
|
||||||
otaUrl = settings[F_OTA_URL].as<String>().c_str();
|
otaUrl = settings[F_OTA_URL].as<String>().c_str();
|
||||||
@ -29,9 +33,7 @@ void otaSetup(JsonObject settings)
|
|||||||
debugPrintln(buffer);
|
debugPrintln(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
ArduinoOTA.setHostname(String(mqttGetNodename()).c_str());
|
if(otaPort > 0) {
|
||||||
// ArduinoOTA.setPassword(configPassword);
|
|
||||||
|
|
||||||
ArduinoOTA.onStart([]() {
|
ArduinoOTA.onStart([]() {
|
||||||
if(ArduinoOTA.getCommand() == U_FLASH) {
|
if(ArduinoOTA.getCommand() == U_FLASH) {
|
||||||
} else { // U_SPIFFS
|
} else { // U_SPIFFS
|
||||||
@ -73,9 +75,31 @@ void otaSetup(JsonObject settings)
|
|||||||
delay(5000);
|
delay(5000);
|
||||||
// haspSendCmd("page " + String(nextionActivePage));
|
// haspSendCmd("page " + String(nextionActivePage));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
#if HASP_USE_MQTT > 0
|
||||||
|
ArduinoOTA.setHostname(String(mqttGetNodename()).c_str());
|
||||||
|
#else
|
||||||
|
ArduinoOTA.setHostname(String(mqttGetNodename()).c_str());
|
||||||
|
#endif
|
||||||
|
// ArduinoOTA.setPassword(configPassword);
|
||||||
|
ArduinoOTA.setPort(otaPort);
|
||||||
|
|
||||||
|
#if ESP32
|
||||||
|
#if HASP_USE_MDNS > 0
|
||||||
|
ArduinoOTA.setMdnsEnabled(true);
|
||||||
|
#else
|
||||||
|
ArduinoOTA.setMdnsEnabled(false);
|
||||||
|
#endif
|
||||||
|
// ArduinoOTA.setTimeout(1000);
|
||||||
|
#endif
|
||||||
|
ArduinoOTA.setRebootOnSuccess(true);
|
||||||
|
|
||||||
ArduinoOTA.begin();
|
ArduinoOTA.begin();
|
||||||
debugPrintln(F("OTA: Over the Air firmware update ready"));
|
debugPrintln(F("OTA: Over the Air firmware update ready"));
|
||||||
debugPrintln(F("OTA: Setup Complete"));
|
debugPrintln(F("OTA: Setup Complete"));
|
||||||
|
} else {
|
||||||
|
debugPrintln(F("OTA: Disabled"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void otaLoop()
|
void otaLoop()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user