Skip to content

Commit 05ea581

Browse files
committed
R86
1 parent 4767a54 commit 05ea581

28 files changed

+219
-96
lines changed

Command.ino

+86-23
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#define INPUT_COMMAND_SIZE 80
2-
void ExecuteCommand(const char *Line)
2+
void ExecuteCommand(byte source, const char *Line)
33
{
4+
String status = "";
5+
boolean success = false;
46
char TmpStr1[80];
57
TmpStr1[0] = 0;
68
char Command[80];
@@ -20,22 +22,24 @@ void ExecuteCommand(const char *Line)
2022

2123
if (strcasecmp_P(Command, PSTR("pinstates")) == 0)
2224
{
25+
success = true;
2326
for (byte x = 0; x < PINSTATE_TABLE_MAX; x++)
2427
if (pinStates[x].plugin != 0)
2528
{
26-
Serial.print(F("Plugin: "));
27-
Serial.print(pinStates[x].plugin);
28-
Serial.print(F(" index: "));
29-
Serial.print(pinStates[x].index);
30-
Serial.print(F(" mode: "));
31-
Serial.print(pinStates[x].mode);
32-
Serial.print(F(" value: "));
33-
Serial.println(pinStates[x].value);
29+
status += F("\nPlugin: ");
30+
status += pinStates[x].plugin;
31+
status += F(" index: ");
32+
status += pinStates[x].index;
33+
status += F(" mode: ");
34+
status += pinStates[x].mode;
35+
status += F(" value: ");
36+
status += pinStates[x].value;
3437
}
3538
}
3639

3740
if (strcasecmp_P(Command, PSTR("timer")) == 0)
3841
{
42+
success = true;
3943
if (GetArgv(Line, TmpStr1, 3))
4044
{
4145
setSystemTimer(Par1 * 1000, Par2, Par3, 0, 0);
@@ -44,6 +48,7 @@ void ExecuteCommand(const char *Line)
4448

4549
if (strcasecmp_P(Command, PSTR("cmdtimer")) == 0)
4650
{
51+
success = true;
4752
if (GetArgv(Line, TmpStr1, 3))
4853
{
4954
String demo = TmpStr1;
@@ -53,11 +58,23 @@ void ExecuteCommand(const char *Line)
5358

5459
if (strcasecmp_P(Command, PSTR("TaskClear")) == 0)
5560
{
61+
success = true;
5662
taskClear(Par1 - 1, true);
5763
}
5864

65+
if (strcasecmp_P(Command, PSTR("TaskGlobalSync")) == 0)
66+
{
67+
success = true;
68+
if (Par2 == 1)
69+
Settings.TaskDeviceGlobalSync[Par1 -1] = true;
70+
else
71+
Settings.TaskDeviceGlobalSync[Par1 -1] = false;
72+
}
73+
74+
5975
if (strcasecmp_P(Command, PSTR("wdconfig")) == 0)
6076
{
77+
success = true;
6178
Wire.beginTransmission(Par1); // address
6279
Wire.write(Par2); // command
6380
Wire.write(Par3); // data
@@ -66,6 +83,7 @@ void ExecuteCommand(const char *Line)
6683

6784
if (strcasecmp_P(Command, PSTR("wdread")) == 0)
6885
{
86+
success = true;
6987
Wire.beginTransmission(Par1); // address
7088
Wire.write(0x83); // command to set pointer
7189
Wire.write(Par2); // pointer value
@@ -74,30 +92,28 @@ void ExecuteCommand(const char *Line)
7492
if (Wire.available())
7593
{
7694
byte value = Wire.read();
77-
if (printToWeb)
78-
{
79-
printWebString += F("Reg value: ");
80-
printWebString += value;
81-
}
82-
Serial.print(F("Reg value: "));
83-
Serial.println(value);
95+
status = F("Reg value: ");
96+
status += value;
8497
}
8598
}
8699

87100
if (strcasecmp_P(Command, PSTR("VariableSet")) == 0)
88101
{
102+
success = true;
89103
if (GetArgv(Line, TmpStr1, 3))
90104
UserVar[Par1 - 1] = atof(TmpStr1);
91105
}
92106

93107
if (strcasecmp_P(Command, PSTR("build")) == 0)
94108
{
109+
success = true;
95110
Settings.Build = Par1;
96111
SaveSettings();
97112
}
98113

99114
if (strcasecmp_P(Command, PSTR("NoSleep")) == 0)
100115
{
116+
success = true;
101117
Settings.deepSleep = 0;
102118
}
103119

@@ -108,16 +124,19 @@ void ExecuteCommand(const char *Line)
108124

109125
if (strcasecmp_P(Command, PSTR("TimerSet")) == 0)
110126
{
127+
success = true;
111128
RulesTimer[Par1 - 1] = millis() + (1000 * Par2);
112129
}
113130

114131
if (strcasecmp_P(Command, PSTR("Delay")) == 0)
115132
{
133+
success = true;
116134
delayMillis(Par1);
117135
}
118136

119137
if (strcasecmp_P(Command, PSTR("Rules")) == 0)
120138
{
139+
success = true;
121140
if (Par1 == 1)
122141
Settings.UseRules = true;
123142
else
@@ -126,6 +145,7 @@ void ExecuteCommand(const char *Line)
126145

127146
if (strcasecmp_P(Command, PSTR("Event")) == 0)
128147
{
148+
success = true;
129149
String event = Line;
130150
event = event.substring(6);
131151
event.replace("$", "#");
@@ -139,6 +159,7 @@ void ExecuteCommand(const char *Line)
139159

140160
if (strcasecmp_P(Command, PSTR("DomoticzSend")) == 0)
141161
{
162+
success = true;
142163
if (GetArgv(Line, TmpStr1, 4))
143164
{
144165
struct EventStruct TempEvent;
@@ -153,47 +174,67 @@ void ExecuteCommand(const char *Line)
153174

154175
if (strcasecmp(Command, "DomoticzGet") == 0)
155176
{
177+
success = true;
156178
float value = 0;
157179
if (Domoticz_getData(Par2, &value))
158180
{
159-
Serial.print(F("DomoticzGet "));
160-
Serial.println(value);
181+
status = F("DomoticzGet ");
182+
status += value;
161183
}
162184
else
163-
Serial.println(F("Error getting data"));
185+
status = F("Error getting data");
164186
}
165187

166188
// ****************************************
167189
// configure settings commands
168190
// ****************************************
169191
if (strcasecmp_P(Command, PSTR("WifiSSID")) == 0)
192+
{
193+
success = true;
170194
strcpy(SecuritySettings.WifiSSID, Line + 9);
195+
}
171196

172197
if (strcasecmp_P(Command, PSTR("WifiKey")) == 0)
198+
{
199+
success = true;
173200
strcpy(SecuritySettings.WifiKey, Line + 8);
201+
}
174202

175203
if (strcasecmp_P(Command, PSTR("WifiScan")) == 0)
204+
{
205+
success = true;
176206
WifiScan();
177-
207+
}
208+
178209
if (strcasecmp_P(Command, PSTR("WifiConnect")) == 0)
210+
{
211+
success = true;
179212
WifiConnect();
180-
213+
}
214+
181215
if (strcasecmp_P(Command, PSTR("WifiDisconnect")) == 0)
216+
{
217+
success = true;
182218
WifiDisconnect();
183-
219+
}
220+
184221
if (strcasecmp_P(Command, PSTR("Reboot")) == 0)
185222
{
223+
success = true;
186224
pinMode(0, INPUT);
187225
pinMode(2, INPUT);
188226
pinMode(15, INPUT);
189227
ESP.reset();
190228
}
191229

192230
if (strcasecmp_P(Command, PSTR("Restart")) == 0)
231+
{
232+
success = true;
193233
ESP.restart();
194-
234+
}
195235
if (strcasecmp_P(Command, PSTR("Erase")) == 0)
196236
{
237+
success = true;
197238
EraseFlash();
198239
ZeroFillFlash();
199240
saveToRTC(0);
@@ -203,16 +244,26 @@ void ExecuteCommand(const char *Line)
203244
}
204245

205246
if (strcasecmp_P(Command, PSTR("Reset")) == 0)
247+
{
248+
success = true;
206249
ResetFactory();
250+
}
207251

208252
if (strcasecmp_P(Command, PSTR("Save")) == 0)
253+
{
254+
success = true;
209255
SaveSettings();
256+
}
210257

211258
if (strcasecmp_P(Command, PSTR("Load")) == 0)
259+
{
260+
success = true;
212261
LoadSettings();
262+
}
213263

214264
if (strcasecmp_P(Command, PSTR("FlashDump")) == 0)
215265
{
266+
success = true;
216267
uint32_t _sectorStart = ((uint32_t)&_SPIFFS_start - 0x40200000) / SPI_FLASH_SEC_SIZE;
217268
uint32_t _sectorEnd = ((uint32_t)&_SPIFFS_end - 0x40200000) / SPI_FLASH_SEC_SIZE;
218269

@@ -240,21 +291,27 @@ void ExecuteCommand(const char *Line)
240291

241292
if (strcasecmp_P(Command, PSTR("flashcheck")) == 0)
242293
{
294+
success = true;
243295
CheckFlash(Par1, Par2);
244296
}
245297

246298
if (strcasecmp_P(Command, PSTR("Debug")) == 0)
299+
{
300+
success = true;
247301
Settings.SerialLogLevel = Par1;
302+
}
248303

249304
if (strcasecmp_P(Command, PSTR("IP")) == 0)
250305
{
306+
success = true;
251307
if (GetArgv(Line, TmpStr1, 2))
252308
if (!str2ip(TmpStr1, Settings.IP))
253309
Serial.println("?");
254310
}
255311

256312
if (strcasecmp_P(Command, PSTR("Settings")) == 0)
257313
{
314+
success = true;
258315
char str[20];
259316
Serial.println();
260317

@@ -268,5 +325,11 @@ void ExecuteCommand(const char *Line)
268325
Serial.print(F(" WifiKey : ")); Serial.println(SecuritySettings.WifiKey);
269326
Serial.print(F(" Free mem : ")); Serial.println(FreeMem());
270327
}
328+
329+
if (success)
330+
status += F("\nOk");
331+
else
332+
status += F("\nUnknown command!");
333+
SendStatus(source,status);
271334
}
272335

Controller.ino

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ boolean sendData(struct EventStruct *event)
2424
}
2525
}
2626

27+
if (Settings.GlobalSync && Settings.TaskDeviceGlobalSync[event->TaskIndex])
28+
SendUDPTaskData(0, event->TaskIndex, event->TaskIndex);
29+
2730
if (!Settings.TaskDeviceSendData[event->TaskIndex])
2831
return false;
2932

@@ -42,9 +45,6 @@ boolean sendData(struct EventStruct *event)
4245
}
4346
}
4447

45-
if (Settings.TaskDeviceGlobalSync[event->TaskIndex])
46-
SendUDPTaskData(0, event->TaskIndex, event->TaskIndex);
47-
4848
if (Settings.Protocol)
4949
{
5050
byte ProtocolIndex = getProtocolIndex(Settings.Protocol);

ESPEasy.ino

+3-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
#define ESP_PROJECT_PID 2015050101L
101101
#define ESP_EASY
102102
#define VERSION 9
103-
#define BUILD 85
103+
#define BUILD 86
104104
#define REBOOT_ON_MAX_CONNECTION_FAILURES 30
105105
#define FEATURE_SPIFFS false
106106

@@ -301,6 +301,7 @@ struct SettingsStruct
301301
unsigned long TaskDeviceTimer[TASKS_MAX];
302302
boolean UseSSDP;
303303
unsigned long WireClockStretchLimit;
304+
boolean GlobalSync;
304305
} Settings;
305306

306307
struct ExtraTaskSettingsStruct
@@ -905,7 +906,7 @@ boolean checkSystemTimers()
905906
struct EventStruct TempEvent;
906907
parseCommandString(&TempEvent, systemCMDTimers[x].action);
907908
if (!PluginCall(PLUGIN_WRITE, &TempEvent, systemCMDTimers[x].action))
908-
ExecuteCommand(systemCMDTimers[x].action.c_str());
909+
ExecuteCommand(VALUE_SOURCE_SYSTEM, systemCMDTimers[x].action.c_str());
909910
systemCMDTimers[x].timer = 0;
910911
systemCMDTimers[x].action = "";
911912
}

Misc.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -1802,7 +1802,7 @@ void rulesProcessing(String& event)
18021802
struct EventStruct TempEvent;
18031803
parseCommandString(&TempEvent, action);
18041804
if (!PluginCall(PLUGIN_WRITE, &TempEvent, action))
1805-
ExecuteCommand(action.c_str());
1805+
ExecuteCommand(VALUE_SOURCE_SYSTEM, action.c_str());
18061806
}
18071807
}
18081808
}

0 commit comments

Comments
 (0)