Added OTA methods, fixed subwwoofer template
This commit is contained in:
parent
145984c2f8
commit
7fc8cda783
3 changed files with 19 additions and 3 deletions
|
@ -34,6 +34,9 @@
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
|
#include <ESP8266mDNS.h>
|
||||||
|
#include <WiFiUdp.h>
|
||||||
|
#include <ArduinoOTA.h>
|
||||||
#include <PubSubClient.h>
|
#include <PubSubClient.h>
|
||||||
#include "ESP8266-MQTT-BenQ.h"
|
#include "ESP8266-MQTT-BenQ.h"
|
||||||
|
|
||||||
|
@ -91,6 +94,8 @@ void setup_wifi() {
|
||||||
Serial.print("My IP address: ");
|
Serial.print("My IP address: ");
|
||||||
Serial.println(WiFi.localIP());
|
Serial.println(WiFi.localIP());
|
||||||
}
|
}
|
||||||
|
ArduinoOTA.setHostname("esp8266-BenQ");
|
||||||
|
ArduinoOTA.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -177,6 +182,9 @@ void updateLamptime() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
// Check OTA update
|
||||||
|
ArduinoOTA.handle();
|
||||||
|
|
||||||
// Ensure MQTT connection
|
// Ensure MQTT connection
|
||||||
if (!client.connected()) {
|
if (!client.connected()) {
|
||||||
reconnect();
|
reconnect();
|
||||||
|
|
|
@ -6,8 +6,8 @@ const char* password = "";
|
||||||
const char* mqtt_server = "broker.mqtt-dashboard.com";
|
const char* mqtt_server = "broker.mqtt-dashboard.com";
|
||||||
|
|
||||||
// Device identification
|
// Device identification
|
||||||
const char* mqtt_device_name = "esp8266benq"
|
const char* mqtt_device_name = "livingroom/teufelSub";
|
||||||
|
|
||||||
// MQTT topics
|
// MQTT topics
|
||||||
const char* mqtt_topic_power = "benq/power";
|
const char* mqtt_topic_power = "livingroom/teufelSub/power";
|
||||||
const char* mqtt_topic_lamptime = "benq/lamptime";
|
const char* mqtt_topic_powerState = "livingroom/teufelSub/powerState";
|
||||||
|
|
|
@ -34,6 +34,9 @@
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
|
#include <ESP8266mDNS.h>
|
||||||
|
#include <WiFiUdp.h>
|
||||||
|
#include <ArduinoOTA.h>
|
||||||
#include <PubSubClient.h>
|
#include <PubSubClient.h>
|
||||||
#include "ESP8266-MQTT-Teufel-Subwoofer.h"
|
#include "ESP8266-MQTT-Teufel-Subwoofer.h"
|
||||||
|
|
||||||
|
@ -105,6 +108,8 @@ void setup_wifi() {
|
||||||
Serial.print("My IP address: ");
|
Serial.print("My IP address: ");
|
||||||
Serial.println(WiFi.localIP());
|
Serial.println(WiFi.localIP());
|
||||||
}
|
}
|
||||||
|
ArduinoOTA.setHostname("esp8266-TeufelSub");
|
||||||
|
ArduinoOTA.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -189,6 +194,9 @@ void updatePowerState() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
// Check OTA update
|
||||||
|
ArduinoOTA.handle();
|
||||||
|
|
||||||
// Ensure MQTT connection
|
// Ensure MQTT connection
|
||||||
if (!client.connected()) {
|
if (!client.connected()) {
|
||||||
reconnect();
|
reconnect();
|
||||||
|
|
Loading…
Reference in a new issue