Added OTA methods, fixed subwwoofer template

This commit is contained in:
Nis Wechselberg 2017-09-17 17:44:18 +02:00
parent 145984c2f8
commit 7fc8cda783
3 changed files with 19 additions and 3 deletions

View file

@ -34,6 +34,9 @@
**********************************************************************/
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include <PubSubClient.h>
#include "ESP8266-MQTT-BenQ.h"
@ -91,6 +94,8 @@ void setup_wifi() {
Serial.print("My IP address: ");
Serial.println(WiFi.localIP());
}
ArduinoOTA.setHostname("esp8266-BenQ");
ArduinoOTA.begin();
}
/*
@ -177,6 +182,9 @@ void updateLamptime() {
}
void loop() {
// Check OTA update
ArduinoOTA.handle();
// Ensure MQTT connection
if (!client.connected()) {
reconnect();

View file

@ -6,8 +6,8 @@ const char* password = "";
const char* mqtt_server = "broker.mqtt-dashboard.com";
// Device identification
const char* mqtt_device_name = "esp8266benq"
const char* mqtt_device_name = "livingroom/teufelSub";
// MQTT topics
const char* mqtt_topic_power = "benq/power";
const char* mqtt_topic_lamptime = "benq/lamptime";
const char* mqtt_topic_power = "livingroom/teufelSub/power";
const char* mqtt_topic_powerState = "livingroom/teufelSub/powerState";

View file

@ -34,6 +34,9 @@
**********************************************************************/
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include <PubSubClient.h>
#include "ESP8266-MQTT-Teufel-Subwoofer.h"
@ -105,6 +108,8 @@ void setup_wifi() {
Serial.print("My IP address: ");
Serial.println(WiFi.localIP());
}
ArduinoOTA.setHostname("esp8266-TeufelSub");
ArduinoOTA.begin();
}
/*
@ -189,6 +194,9 @@ void updatePowerState() {
}
void loop() {
// Check OTA update
ArduinoOTA.handle();
// Ensure MQTT connection
if (!client.connected()) {
reconnect();