-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWeMo_Main.h
139 lines (108 loc) · 2.16 KB
/
WeMo_Main.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#ifndef WEMO_MAIN_H
#define WEMO_MAIN_H
#include "WeMo.h"
#include <functional>
#include "Util.h"
#include "Config.h"
#ifdef MQTT
//#include "mqttserver.h"
#include "Async_MQTT_Server.h"
#endif
#ifdef WEBSERVER
#include "WebServer.h"
#endif
#ifdef WITTY
#include "Witty.h"
#endif
#ifdef Alexa
#include "WeMoSwitch.h"
#endif
#ifdef NODEMCU
#include "WeMo_NodeMcu.h"
#endif
#ifdef ESP32
#include "WeMo_ESP32.h"
#endif
#ifdef NODEMCU
WeMo_NodeMCU nodeMcuB;
#endif
#ifdef ESP32
WeMo_ESP32 esp32B;
#endif
#ifdef WITTY
Witty wittyB;
#endif
#ifdef Alexa
WeMoSwitch *weMo;
#endif
#ifdef WEBSERVER
WebServer *webServer;
#endif
class WeMo_Main
{
private:
public:
void CallInSetUp();
void CallInLoop();
};
#endif
void WeMo_Main::CallInSetUp()
{
#ifdef CONFIG_DATA
WeMo::ProcessProcessConfigData();
#endif
#ifdef NODEMCU
nodeMcuB.Setup();
#endif
#ifdef ESP32
esp32B.Setup();
#endif
#ifdef WITTY
wittyB.InitWitty(false);
Serial.println("Witty Board Init done");
#endif
WeMo::SetUpRelaySwitch(); // If Board based Setup is not called then it should be called
#ifdef RetroSwitch
WeMo::SetUpRetroSwitch();
#endif
#ifdef Alexa
weMo = new WeMoSwitch();
Serial.println("WeMoSwtich with Alex added");
weMo->initWemoSwitch();
Serial.println("Wemos Switch init done");
#endif
#ifdef WEBSERVER
webServer = new WebServer(80);
webServer->StartWebServer();
#endif
if (MDNS.begin("amitiot"))
{
Serial.println("MDNS responder started: amitiot");
MDNS.addService("http", "tcp", 80); // Add service to MDNS-SD
}
Serial.println(ESP.getChipId());
Serial1.println(ESP.getFlashChipId());
Serial.println(ESP8266_CLOCK);
}
void WeMo_Main::CallInLoop()
{
MDNS.update();
#ifdef NODEMCU
nodeMcuB.Loop();
#endif
#ifdef ESP32
esp32B.Loop();
#endif
#ifdef WEBSERVER
webServer->IndexPage(); // WebServer
#endif
#ifdef Alexa
weMo->wemoSwitchLoop();
#endif
#ifdef RetroSwitch
WeMo::WeMoRetroSwitchLoop();
#endif
#ifdef WITTY
wittyB.ButtonLoop();
#endif
}