forked from Roos-AID/ModbusRTU-ESP8266-webui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandleDebug.ino
108 lines (102 loc) · 3.65 KB
/
handleDebug.ino
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
/*
***************************************************************************
** Program : handleDebug
** Version 1.8.0
**
**
** Copyright (c) 2021 Rob Roos
** based on Framework ESP8266 from Willem Aandewiel and modifications
** from Robert van Breemen
**
** TERMS OF USE: MIT License. See bottom of file.
***************************************************************************
*/
void handleDebug(){
if (TelnetStream.available()>0){
//read the next
char c;
c = TelnetStream.read();
switch (c){
case 'h':
Debugln("Available commands are:");
Debugln("p : Print (list) Modbusmap ");
Debugln("l : List Daytimemap");
Debugln("d : Re-read Daytimemap from Daytimemap.cfg");
Debugln("t : Toggle Timebased Relay");
Debugln("m : Configure MQTT Discovery");
Debugln("r : Reconnecting to wifi");
Debugf("1 : Toggle debug Modbus msg, status: %s\r\n", CBOOLEAN(bDebugMBmsg));
Debugf("2 : Toggle debug RestAPI status %s\r\n", CBOOLEAN(bDebugRestAPI));
Debugf("3 : Toggle debug MQTT, status: %s\r\n", CBOOLEAN(bDebugMQTT));
Debugf("8 : Toggle Modbus Byteswap: %s\r\n", CBOOLEAN(settingModbusByteswap));
Debugf("9 : Toggle debug Modbuslogic, status: %s\r\n", CBOOLEAN(bDebugMBlogic));
break;
case 'd':
DebugTln("Read Daytimemap");
doInitDaytimemap() ;
printDaytimemap();
break;
case 'l':
DebugTln("List Daytimemap");
printDaytimemap();
break;
case 'p':
DebugTln("Print Modbusmap");
printModbusmap();
break;
case 't':
DebugTln("Toggle Timebased Relay");
if (settingTimebasedSwitch && settingNTPenable) {
DebugTf("Relay current status %d \r\n", statusRelay);
if (statusRelay==RELAYOFF)
setRelay(RELAYON) ;
else setRelay(RELAYOFF);
} else {
DebugTln("NOT POSSIBLE, TIMEBASED SWITCHING NOT ACTIVATED");
}
case 'm':
DebugTln("Configure MQTT Discovery");
DebugTf("Enable MQTT: %s", CBOOLEAN(settingMQTTenable));
doAutoConfigure();
break;
case 'r':
if (WiFi.status() != WL_CONNECTED)
{
DebugTln("Reconnecting to wifi");
restartWiFi(CSTR(settingHostname), 240);
startTelnet();
}
else
DebugTln("Wifi is connected");
if (!statusMQTTconnection)
{
DebugTln("Reconnecting MQTT");
startMQTT();
}
else
DebugTln("MQTT is connected");
break;
case '1':
bDebugMBmsg = !bDebugMBmsg;
Debugf("\r\nDebug Modbus msg: %s\r\n", CBOOLEAN(bDebugMBmsg));
break;
case '2':
bDebugRestAPI = !bDebugRestAPI;
Debugf("\r\nDebug RestAPI: %s\r\n", CBOOLEAN(bDebugRestAPI));
break;
case '3':
bDebugMQTT = !bDebugMQTT;
Debugf("\r\nDebug MQTT: %s\r\n", CBOOLEAN(bDebugMQTT));
break;
case '8':
settingModbusByteswap = !settingModbusByteswap;
Debugf("\r\nModbus ByteSwap: %s\r\n", CBOOLEAN(settingModbusByteswap));
break;
case '9':
bDebugMBlogic = !bDebugMBlogic;
Debugf("\r\nDebug Modbuslogic: %s\r\n", CBOOLEAN(bDebugMBlogic));
break;
default: break;
}
}
}