This commit is contained in:
mvdbro
2016-03-13 14:03:09 +01:00
parent 668c641925
commit 4767a54884
20 changed files with 506 additions and 217 deletions
+16
View File
@@ -18,6 +18,22 @@ void ExecuteCommand(const char *Line)
// commands for debugging
// ****************************************
if (strcasecmp_P(Command, PSTR("pinstates")) == 0)
{
for (byte x = 0; x < PINSTATE_TABLE_MAX; x++)
if (pinStates[x].plugin != 0)
{
Serial.print(F("Plugin: "));
Serial.print(pinStates[x].plugin);
Serial.print(F(" index: "));
Serial.print(pinStates[x].index);
Serial.print(F(" mode: "));
Serial.print(pinStates[x].mode);
Serial.print(F(" value: "));
Serial.println(pinStates[x].value);
}
}
if (strcasecmp_P(Command, PSTR("timer")) == 0)
{
if (GetArgv(Line, TmpStr1, 3))
+32 -5
View File
@@ -101,7 +101,7 @@ void MQTTConnect()
String log = "";
boolean MQTTresult = false;
if ((SecuritySettings.ControllerUser) && (SecuritySettings.ControllerPassword))
if ((SecuritySettings.ControllerUser[0] != 0) && (SecuritySettings.ControllerPassword[0] != 0))
MQTTresult = (MQTTclient.connect(MQTT::Connect(clientid).set_auth(SecuritySettings.ControllerUser, SecuritySettings.ControllerPassword)));
else
MQTTresult = (MQTTclient.connect(clientid));
@@ -150,11 +150,38 @@ void MQTTCheck()
}
struct NodeStruct
/*********************************************************************************************\
* Send status info to request source
\*********************************************************************************************/
void SendStatus(byte source, String status)
{
byte ip[4];
byte age;
} Nodes[UNIT_MAX];
switch(source)
{
case VALUE_SOURCE_HTTP:
if (printToWeb)
printWebString += status;
break;
case VALUE_SOURCE_MQTT:
MQTTStatus(status);
break;
case VALUE_SOURCE_SERIAL:
Serial.println(status);
break;
}
}
/*********************************************************************************************\
* Send status info back to channel where request came from
\*********************************************************************************************/
void MQTTStatus(String& status)
{
String pubname = Settings.MQTTsubscribe;
pubname.replace("/#", "/status");
pubname.replace("%sysname%", Settings.Name);
MQTTclient.publish(pubname, status);
}
+36 -3
View File
@@ -1,4 +1,4 @@
#define ESP_CORE 200
#define ESP_CORE 210
/****************************************************************************************************************************\
* Arduino project "ESP Easy" © Copyright www.esp8266.nu
*
@@ -100,7 +100,7 @@
#define ESP_PROJECT_PID 2015050101L
#define ESP_EASY
#define VERSION 9
#define BUILD 84
#define BUILD 85
#define REBOOT_ON_MAX_CONNECTION_FAILURES 30
#define FEATURE_SPIFFS false
@@ -131,6 +131,16 @@
#define RULES_TIMER_MAX 8
#define SYSTEM_TIMER_MAX 8
#define SYSTEM_CMD_TIMER_MAX 2
#define PINSTATE_TABLE_MAX 32
#define PIN_MODE_UNDEFINED 0
#define PIN_MODE_INPUT 1
#define PIN_MODE_OUTPUT 2
#define PIN_MODE_PWM 3
#define PIN_MODE_SERVO 4
#define SEARCH_PIN_STATE true
#define NO_SEARCH_PIN_STATE false
#define DEVICE_TYPE_SINGLE 1 // connected through 1 datapin
#define DEVICE_TYPE_I2C 2 // connected through I2C
@@ -165,6 +175,12 @@
#define PLUGIN_CLOCK_IN 18
#define PLUGIN_TIMER_IN 19
#define VALUE_SOURCE_SYSTEM 1
#define VALUE_SOURCE_SERIAL 2
#define VALUE_SOURCE_HTTP 3
#define VALUE_SOURCE_MQTT 4
#define VALUE_SOURCE_UDP 5
#define BOOT_CAUSE_MANUAL_REBOOT 0
#define BOOT_CAUSE_COLD_BOOT 1
#define BOOT_CAUSE_EXT_WD 10
@@ -277,13 +293,14 @@ struct SettingsStruct
boolean TaskDeviceGlobalSync[TASKS_MAX];
int8_t TaskDevicePin3[TASKS_MAX];
byte TaskDeviceDataFeed[TASKS_MAX];
int8_t PinStates[17];
int8_t PinBootStates[17];
byte UseDNS;
boolean UseRules;
int8_t Pin_status_led;
boolean UseSerial;
unsigned long TaskDeviceTimer[TASKS_MAX];
boolean UseSSDP;
unsigned long WireClockStretchLimit;
} Settings;
struct ExtraTaskSettingsStruct
@@ -297,6 +314,7 @@ struct ExtraTaskSettingsStruct
struct EventStruct
{
byte Source;
byte TaskIndex;
byte BaseVarIndex;
int idx;
@@ -342,6 +360,12 @@ struct ProtocolStruct
int defaultPort;
} Protocol[CPLUGIN_MAX];
struct NodeStruct
{
byte ip[4];
byte age;
} Nodes[UNIT_MAX];
struct systemTimerStruct
{
unsigned long timer;
@@ -357,11 +381,20 @@ struct systemCMDTimerStruct
String action;
} systemCMDTimers[SYSTEM_CMD_TIMER_MAX];
struct pinStatesStruct
{
byte plugin;
byte index;
byte mode;
uint16_t value;
} pinStates[PINSTATE_TABLE_MAX];
int deviceCount = -1;
int protocolCount = -1;
boolean printToWeb = false;
String printWebString = "";
boolean printToWebJSON = false;
float UserVar[VARS_PER_TASK * TASKS_MAX];
unsigned long RulesTimer[RULES_TIMER_MAX];
+15 -3
View File
@@ -7,16 +7,22 @@ void hardwareInit()
// set GPIO pins state if not set to default
for (byte x=0; x < 17; x++)
if (Settings.PinStates[x] != 0)
switch(Settings.PinStates[x])
if (Settings.PinBootStates[x] != 0)
switch(Settings.PinBootStates[x])
{
case 1:
pinMode(x,OUTPUT);
digitalWrite(x,LOW);
setPinState(1, x, PIN_MODE_OUTPUT, LOW);
break;
case 2:
pinMode(x,OUTPUT);
digitalWrite(x,HIGH);
setPinState(1, x, PIN_MODE_OUTPUT, HIGH);
break;
case 3:
pinMode(x,INPUT_PULLUP);
setPinState(1, x, PIN_MODE_INPUT, 0);
break;
}
@@ -27,7 +33,13 @@ void hardwareInit()
addLog(LOG_LEVEL_INFO, log);
Wire.begin(Settings.Pin_i2c_sda, Settings.Pin_i2c_scl);
#if ESP_CORE >= 210
Wire.setClockStretchLimit(2000);
if(Settings.WireClockStretchLimit)
{
String log = F("INIT : I2C custom clockstretchlimit:");
log += Settings.WireClockStretchLimit;
addLog(LOG_LEVEL_INFO, log);
Wire.setClockStretchLimit(Settings.WireClockStretchLimit);
}
#endif
}
+149 -1
View File
@@ -1,3 +1,151 @@
/*********************************************************************************************\
* Parse a string and get the xth command or parameter
\*********************************************************************************************/
String parseString(String& string, byte indexFind)
{
String tmpString = string;
tmpString += ",";
tmpString.replace(" ", ",");
String locateString = "";
byte count = 0;
int index = tmpString.indexOf(',');
while (index > 0)
{
count++;
locateString = tmpString.substring(0, index);
tmpString = tmpString.substring(index + 1);
index = tmpString.indexOf(',');
if (count == indexFind)
{
locateString.toLowerCase();
return locateString;
}
}
return "";
}
/*********************************************************************************************\
* set pin mode & state (info table)
\*********************************************************************************************/
boolean setPinState(byte plugin, byte index, byte mode, uint16_t value)
{
// plugin number and index form a unique key
// first check if this pin is already known
boolean reUse = false;
for (byte x = 0; x < PINSTATE_TABLE_MAX; x++)
if ((pinStates[x].plugin == plugin) && (pinStates[x].index == index))
{
pinStates[x].mode = mode;
pinStates[x].value = value;
reUse = true;
break;
}
if (!reUse)
{
for (byte x = 0; x < PINSTATE_TABLE_MAX; x++)
if (pinStates[x].plugin == 0)
{
pinStates[x].plugin = plugin;
pinStates[x].index = index;
pinStates[x].mode = mode;
pinStates[x].value = value;
break;
}
}
}
/*********************************************************************************************\
* get pin mode & state (info table)
\*********************************************************************************************/
boolean getPinState(byte plugin, byte index, byte *mode, uint16_t *value)
{
for (byte x = 0; x < PINSTATE_TABLE_MAX; x++)
if ((pinStates[x].plugin == plugin) && (pinStates[x].index == index))
{
*mode = pinStates[x].mode;
*value = pinStates[x].value;
return true;
}
return false;
}
/*********************************************************************************************\
* check if pin mode & state is known (info table)
\*********************************************************************************************/
boolean hasPinState(byte plugin, byte index)
{
for (byte x = 0; x < PINSTATE_TABLE_MAX; x++)
if ((pinStates[x].plugin == plugin) && (pinStates[x].index == index))
{
return true;
}
return false;
}
/*********************************************************************************************\
* report pin mode & state (info table) using json
\*********************************************************************************************/
String getPinStateJSON(boolean search, byte plugin, byte index, String& log, uint16_t noSearchValue)
{
printToWebJSON = true;
byte mode = PIN_MODE_INPUT;
uint16_t value = noSearchValue;
String reply = "";
boolean found = false;
if (search)
{
for (byte x = 0; x < PINSTATE_TABLE_MAX; x++)
if ((pinStates[x].plugin == plugin) && (pinStates[x].index == index))
{
mode = pinStates[x].mode;
value = pinStates[x].value;
found = true;
break;
}
}
if (!search || (search && found))
{
reply += F("{\n\"log\": \"");
reply += log.substring(7,32); // truncate to 25 chars, max MQTT message size = 128 including header...
reply += F("\",\n\"plugin\": ");
reply += plugin;
reply += F(",\n\"pin\": ");
reply += index;
reply += F(",\n\"mode\": \"");
switch (mode)
{
case PIN_MODE_UNDEFINED:
reply += F("undefined");
break;
case PIN_MODE_INPUT:
reply += F("input");
break;
case PIN_MODE_OUTPUT:
reply += F("output");
break;
case PIN_MODE_PWM:
reply += F("PWM");
break;
case PIN_MODE_SERVO:
reply += F("servo");
break;
}
reply += F("\",\n\"state\": ");
reply += value;
reply += F("\n}\n");
return reply;
}
return "?";
}
/********************************************************************************************\
* Unsigned long Timer timeOut check
\*********************************************************************************************/
@@ -1583,7 +1731,7 @@ void rulesProcessing(String& event)
String eventTrigger = "";
String action = "";
if (!codeBlock) // do not check "on" rules if a block of actions is to be processed
{
if (line.startsWith("on "))
+1
View File
@@ -70,6 +70,7 @@ void checkUDP()
}
char packetBuffer[128];
int len = portUDP.read(packetBuffer, 128);
if (packetBuffer[0] != 255)
{
packetBuffer[len] = 0;
+1
View File
@@ -33,6 +33,7 @@ void serial()
String action = InputBuffer_Serial;
struct EventStruct TempEvent;
parseCommandString(&TempEvent, action);
TempEvent.Source = VALUE_SOURCE_SERIAL;
if (!PluginCall(PLUGIN_WRITE, &TempEvent, action))
ExecuteCommand(InputBuffer_Serial);
SerialInByteCounter = 0;
+49 -35
View File
@@ -522,17 +522,17 @@ void handle_hardware() {
Settings.Pin_i2c_sda = pin_i2c_sda.toInt();
Settings.Pin_i2c_scl = pin_i2c_scl.toInt();
Settings.Pin_status_led = pin_status_led.toInt();
Settings.PinStates[0] = WebServer.arg("p0").toInt();
Settings.PinStates[2] = WebServer.arg("p2").toInt();
Settings.PinStates[4] = WebServer.arg("p4").toInt();
Settings.PinStates[5] = WebServer.arg("p5").toInt();
Settings.PinStates[9] = WebServer.arg("p9").toInt();
Settings.PinStates[10] = WebServer.arg("p10").toInt();
Settings.PinStates[12] = WebServer.arg("p12").toInt();
Settings.PinStates[13] = WebServer.arg("p13").toInt();
Settings.PinStates[14] = WebServer.arg("p14").toInt();
Settings.PinStates[15] = WebServer.arg("p15").toInt();
Settings.PinStates[16] = WebServer.arg("p16").toInt();
Settings.PinBootStates[0] = WebServer.arg("p0").toInt();
Settings.PinBootStates[2] = WebServer.arg("p2").toInt();
Settings.PinBootStates[4] = WebServer.arg("p4").toInt();
Settings.PinBootStates[5] = WebServer.arg("p5").toInt();
Settings.PinBootStates[9] = WebServer.arg("p9").toInt();
Settings.PinBootStates[10] = WebServer.arg("p10").toInt();
Settings.PinBootStates[12] = WebServer.arg("p12").toInt();
Settings.PinBootStates[13] = WebServer.arg("p13").toInt();
Settings.PinBootStates[14] = WebServer.arg("p14").toInt();
Settings.PinBootStates[15] = WebServer.arg("p15").toInt();
Settings.PinBootStates[16] = WebServer.arg("p16").toInt();
SaveSettings();
}
@@ -548,28 +548,29 @@ void handle_hardware() {
reply += F("<TR><TD>SCL:<TD>");
addPinSelect(true, reply, "pscl", Settings.Pin_i2c_scl);
reply += F("<TR><TD>GPIO boot states:<TD>");
reply += F("<TR><TD>Pin mode 0:<TD>");
addPinStateSelect(reply, "p0", Settings.PinStates[0]);
addPinStateSelect(reply, "p0", Settings.PinBootStates[0]);
reply += F("<TR><TD>Pin mode 2:<TD>");
addPinStateSelect(reply, "p2", Settings.PinStates[2]);
addPinStateSelect(reply, "p2", Settings.PinBootStates[2]);
reply += F("<TR><TD>Pin mode 4:<TD>");
addPinStateSelect(reply, "p4", Settings.PinStates[4]);
addPinStateSelect(reply, "p4", Settings.PinBootStates[4]);
reply += F("<TR><TD>Pin mode 5:<TD>");
addPinStateSelect(reply, "p5", Settings.PinStates[5]);
addPinStateSelect(reply, "p5", Settings.PinBootStates[5]);
reply += F("<TR><TD>Pin mode 9:<TD>");
addPinStateSelect(reply, "p9", Settings.PinStates[9]);
addPinStateSelect(reply, "p9", Settings.PinBootStates[9]);
reply += F("<TR><TD>Pin mode 10:<TD>");
addPinStateSelect(reply, "p10", Settings.PinStates[10]);
addPinStateSelect(reply, "p10", Settings.PinBootStates[10]);
reply += F("<TR><TD>Pin mode 12:<TD>");
addPinStateSelect(reply, "p12", Settings.PinStates[12]);
addPinStateSelect(reply, "p12", Settings.PinBootStates[12]);
reply += F("<TR><TD>Pin mode 13:<TD>");
addPinStateSelect(reply, "p13", Settings.PinStates[13]);
addPinStateSelect(reply, "p13", Settings.PinBootStates[13]);
reply += F("<TR><TD>Pin mode 14:<TD>");
addPinStateSelect(reply, "p14", Settings.PinStates[14]);
addPinStateSelect(reply, "p14", Settings.PinBootStates[14]);
reply += F("<TR><TD>Pin mode 15:<TD>");
addPinStateSelect(reply, "p15", Settings.PinStates[15]);
addPinStateSelect(reply, "p15", Settings.PinBootStates[15]);
reply += F("<TR><TD>Pin mode 16:<TD>");
addPinStateSelect(reply, "p16", Settings.PinStates[16]);
addPinStateSelect(reply, "p16", Settings.PinBootStates[16]);
reply += F("<TR><TD><TD><input class=\"button-link\" type='submit' value='Submit'><TR><TD>");
@@ -584,19 +585,21 @@ void handle_hardware() {
//********************************************************************************
void addPinStateSelect(String& str, String name, int choice)
{
String options[3];
String options[4];
options[0] = F("Default");
options[1] = F("Output Low");
options[2] = F("Output High");
int optionValues[3];
options[3] = F("Input");
int optionValues[4];
optionValues[0] = 0;
optionValues[1] = 1;
optionValues[2] = 2;
optionValues[3] = 3;
str += F("<select name='");
str += name;
str += "'>";
for (byte x = 0; x < 3; x++)
for (byte x = 0; x < 4; x++)
{
str += F("<option value='");
str += optionValues[x];
@@ -1323,14 +1326,9 @@ void handle_tools() {
struct EventStruct TempEvent;
parseCommandString(&TempEvent, webrequest);
if (PluginCall(PLUGIN_WRITE, &TempEvent, webrequest))
{
// TODO
}
else
{
TempEvent.Source = VALUE_SOURCE_HTTP;
if (!PluginCall(PLUGIN_WRITE, &TempEvent, webrequest))
ExecuteCommand(webrequest.c_str());
}
reply += printWebString;
reply += F("</table></form>");
@@ -1505,7 +1503,8 @@ void handle_control() {
struct EventStruct TempEvent;
parseCommandString(&TempEvent, webrequest);
TempEvent.Source = VALUE_SOURCE_HTTP;
printToWeb = true;
printWebString = "";
String reply = "";
@@ -1514,10 +1513,15 @@ void handle_control() {
reply += F("Unknown or restricted command!");
reply += printWebString;
reply += F("</table></form>");
WebServer.send(200, "text/html", reply);
if (printToWebJSON)
WebServer.send(200, "application/json", reply);
else
WebServer.send(200, "text/html", reply);
printWebString = "";
printToWeb = false;
printToWebJSON = false;
}
@@ -1628,6 +1632,7 @@ void handle_advanced() {
String wdi2caddress = WebServer.arg("wdi2caddress");
String usessdp = WebServer.arg("usessdp");
String edit = WebServer.arg("edit");
String wireclockstretchlimit = WebServer.arg("wireclockstretchlimit");
if (edit.length() != 0)
{
@@ -1655,6 +1660,9 @@ void handle_advanced() {
Settings.DST = (dst == "on");
Settings.WDI2CAddress = wdi2caddress.toInt();
Settings.UseSSDP = (usessdp == "on");
#if ESP_CORE >= 210
Settings.WireClockStretchLimit = wireclockstretchlimit.toInt();
#endif
SaveSettings();
}
@@ -1749,6 +1757,12 @@ void handle_advanced() {
reply += F("<input type=checkbox name='usessdp'>");
#endif
#if ESP_CORE >= 210
reply += F("<TR><TD>I2C ClockStretchLimit:<TD><input type='text' name='wireclockstretchlimit' value='");
reply += Settings.WireClockStretchLimit;
reply += F("'>");
#endif
reply += F("<TR><TD><TD><input class=\"button-link\" type='submit' value='Submit'>");
reply += F("<input type='hidden' name='edit' value='1'>");
reply += F("</table></form>");
+4 -20
View File
@@ -37,14 +37,13 @@ boolean CPlugin_001(byte function, struct EventStruct *event, String& string)
{
String authHeader = "";
#if ESP_CORE >= 210
if ((SecuritySettings.ControllerUser) && (SecuritySettings.ControllerPassword))
if ((SecuritySettings.ControllerUser[0] != 0) && (SecuritySettings.ControllerPassword[0] != 0))
{
String base64Authorization;
base64 encoder;
String auth = SecuritySettings.ControllerUser;
auth += ":";
auth += SecuritySettings.ControllerPassword;
base64Authorization = base64::encode(auth);
authHeader = "Authorization: Basic " + base64Authorization + " \r\n";
authHeader = "Authorization: Basic " + encoder.encode(auth) + " \r\n";
}
#endif
@@ -55,11 +54,7 @@ boolean CPlugin_001(byte function, struct EventStruct *event, String& string)
sprintf_P(log, PSTR("%s%s using port %u"), "HTTP : connecting to ", host,Settings.ControllerPort);
addLog(LOG_LEVEL_DEBUG, log);
if (printToWeb)
{
printWebString += log;
printWebString += "<BR>";
}
// Use WiFiClient class to create TCP connections
WiFiClient client;
if (!client.connect(host, Settings.ControllerPort))
@@ -67,8 +62,6 @@ boolean CPlugin_001(byte function, struct EventStruct *event, String& string)
connectionFailures++;
strcpy_P(log, PSTR("HTTP : connection failed"));
addLog(LOG_LEVEL_ERROR, log);
if (printToWeb)
printWebString += F("connection failed<BR>");
return false;
}
statusLED(true);
@@ -137,11 +130,6 @@ boolean CPlugin_001(byte function, struct EventStruct *event, String& string)
url.toCharArray(log, 80);
addLog(LOG_LEVEL_DEBUG_MORE, log);
if (printToWeb)
{
printWebString += log;
printWebString += "<BR>";
}
// This will send the request to the server
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
@@ -161,16 +149,12 @@ boolean CPlugin_001(byte function, struct EventStruct *event, String& string)
{
strcpy_P(log, PSTR("HTTP : Succes!"));
addLog(LOG_LEVEL_DEBUG, log);
if (printToWeb)
printWebString += F("Success<BR>");
success = true;
}
delay(1);
}
strcpy_P(log, PSTR("HTTP : closing connection"));
addLog(LOG_LEVEL_DEBUG, log);
if (printToWeb)
printWebString += F("closing connection<BR>");
client.flush();
client.stop();
+1 -9
View File
@@ -37,11 +37,7 @@ boolean CPlugin_003(byte function, struct EventStruct *event, String& string)
sprintf_P(log, PSTR("%s%s using port %u"), "TELNT: connecting to ", host,Settings.ControllerPort);
addLog(LOG_LEVEL_DEBUG, log);
if (printToWeb)
{
printWebString += log;
printWebString += "<BR>";
}
// Use WiFiClient class to create TCP connections
WiFiClient client;
if (!client.connect(host, Settings.ControllerPort))
@@ -49,8 +45,6 @@ boolean CPlugin_003(byte function, struct EventStruct *event, String& string)
connectionFailures++;
strcpy_P(log, PSTR("TELNT: connection failed"));
addLog(LOG_LEVEL_ERROR, log);
if (printToWeb)
printWebString += F("connection failed<BR>");
return false;
}
statusLED(true);
@@ -102,8 +96,6 @@ boolean CPlugin_003(byte function, struct EventStruct *event, String& string)
strcpy_P(log, PSTR("TELNT: closing connection"));
addLog(LOG_LEVEL_DEBUG, log);
if (printToWeb)
printWebString += F("closing connection<BR>");
client.stop();
+1 -11
View File
@@ -37,11 +37,7 @@ boolean CPlugin_004(byte function, struct EventStruct *event, String& string)
sprintf_P(log, PSTR("%s%s using port %u"), "HTTP : connecting to ", host,Settings.ControllerPort);
addLog(LOG_LEVEL_DEBUG, log);
if (printToWeb)
{
printWebString += log;
printWebString += "<BR>";
}
// Use WiFiClient class to create TCP connections
WiFiClient client;
if (!client.connect(host, Settings.ControllerPort))
@@ -49,8 +45,6 @@ boolean CPlugin_004(byte function, struct EventStruct *event, String& string)
connectionFailures++;
strcpy_P(log, PSTR("HTTP : connection failed"));
addLog(LOG_LEVEL_ERROR, log);
if (printToWeb)
printWebString += F("connection failed<BR>");
return false;
}
statusLED(true);
@@ -124,16 +118,12 @@ boolean CPlugin_004(byte function, struct EventStruct *event, String& string)
{
strcpy_P(log, PSTR("HTTP : Succes!"));
addLog(LOG_LEVEL_DEBUG, log);
if (printToWeb)
printWebString += F("Success<BR>");
success = true;
}
delay(1);
}
strcpy_P(log, PSTR("HTTP : closing connection"));
addLog(LOG_LEVEL_DEBUG, log);
if (printToWeb)
printWebString += F("closing connection<BR>");
client.flush();
client.stop();
+1
View File
@@ -58,6 +58,7 @@ boolean CPlugin_005(byte function, struct EventStruct *event, String& string)
{
cmd = event->String2;
parseCommandString(&TempEvent, cmd);
TempEvent.Source = VALUE_SOURCE_MQTT;
}
else
{
+1 -11
View File
@@ -37,11 +37,7 @@ boolean CPlugin_007(byte function, struct EventStruct *event, String& string)
sprintf_P(log, PSTR("%s%s using port %u"), "HTTP : connecting to ", host,Settings.ControllerPort);
addLog(LOG_LEVEL_DEBUG, log);
if (printToWeb)
{
printWebString += log;
printWebString += "<BR>";
}
// Use WiFiClient class to create TCP connections
WiFiClient client;
if (!client.connect(host, Settings.ControllerPort))
@@ -49,8 +45,6 @@ boolean CPlugin_007(byte function, struct EventStruct *event, String& string)
connectionFailures++;
strcpy_P(log, PSTR("HTTP : connection failed"));
addLog(LOG_LEVEL_ERROR, log);
if (printToWeb)
printWebString += F("connection failed<BR>");
return false;
}
statusLED(true);
@@ -139,16 +133,12 @@ boolean CPlugin_007(byte function, struct EventStruct *event, String& string)
{
strcpy_P(log, PSTR("HTTP : Succes!"));
addLog(LOG_LEVEL_DEBUG, log);
if (printToWeb)
printWebString += F("Success<BR>");
success = true;
}
delay(1);
}
strcpy_P(log, PSTR("HTTP : closing connection"));
addLog(LOG_LEVEL_DEBUG, log);
if (printToWeb)
printWebString += F("closing connection<BR>");
client.flush();
client.stop();
+1 -16
View File
@@ -84,11 +84,7 @@ boolean HTTPSend(struct EventStruct *event, byte varIndex, float value, unsigned
sprintf_P(log, PSTR("%s%s using port %u"), "HTTP : connecting to ", host,Settings.ControllerPort);
addLog(LOG_LEVEL_DEBUG, log);
if (printToWeb)
{
printWebString += log;
printWebString += "<BR>";
}
// Use WiFiClient class to create TCP connections
WiFiClient client;
if (!client.connect(host, Settings.ControllerPort))
@@ -96,8 +92,6 @@ boolean HTTPSend(struct EventStruct *event, byte varIndex, float value, unsigned
connectionFailures++;
strcpy_P(log, PSTR("HTTP : connection failed"));
addLog(LOG_LEVEL_ERROR, log);
if (printToWeb)
printWebString += F("connection failed<BR>");
return false;
}
statusLED(true);
@@ -120,11 +114,6 @@ boolean HTTPSend(struct EventStruct *event, byte varIndex, float value, unsigned
url.toCharArray(log, 80);
addLog(LOG_LEVEL_DEBUG_MORE, log);
if (printToWeb)
{
printWebString += log;
printWebString += "<BR>";
}
// This will send the request to the server
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
@@ -144,16 +133,12 @@ boolean HTTPSend(struct EventStruct *event, byte varIndex, float value, unsigned
{
strcpy_P(log, PSTR("HTTP : Succes!"));
addLog(LOG_LEVEL_DEBUG, log);
if (printToWeb)
printWebString += F("Success<BR>");
success = true;
}
delay(1);
}
strcpy_P(log, PSTR("HTTP : closing connection"));
addLog(LOG_LEVEL_DEBUG, log);
if (printToWeb)
printWebString += F("closing connection<BR>");
client.flush();
client.stop();
+34 -25
View File
@@ -130,6 +130,9 @@ boolean Plugin_001(byte function, struct EventStruct *event, String& string)
pinMode(Settings.TaskDevicePin1[event->TaskIndex], INPUT_PULLUP);
else
pinMode(Settings.TaskDevicePin1[event->TaskIndex], INPUT);
setPinState(PLUGIN_ID_001, Settings.TaskDevicePin1[event->TaskIndex], PIN_MODE_INPUT, 0);
switchstate[event->TaskIndex] = digitalRead(Settings.TaskDevicePin1[event->TaskIndex]);
// if boot state must be send, inverse default state
@@ -190,39 +193,37 @@ boolean Plugin_001(byte function, struct EventStruct *event, String& string)
case PLUGIN_WRITE:
{
String log = "";
String tmpString = string;
int argIndex = tmpString.indexOf(',');
if (argIndex)
tmpString = tmpString.substring(0, argIndex);
if (tmpString.equalsIgnoreCase(F("GPIO")))
String command = parseString(string, 1);
if (command == F("gpio"))
{
success = true;
if (event->Par1 >= 0 && event->Par1 <= 16)
{
pinMode(event->Par1, OUTPUT);
digitalWrite(event->Par1, event->Par2);
setPinState(PLUGIN_ID_001, event->Par1, PIN_MODE_OUTPUT, event->Par2);
log = String(F("SW : GPIO ")) + String(event->Par1) + String(F(" Set to ")) + String(event->Par2);
addLog(LOG_LEVEL_INFO, log);
if (printToWeb)
printWebString += log;
SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_001, event->Par1, log, 0));
}
}
if (tmpString.equalsIgnoreCase(F("PWM")))
if (command == F("pwm"))
{
success = true;
if (event->Par1 >= 0 && event->Par1 <= 16)
{
pinMode(event->Par1, OUTPUT);
analogWrite(event->Par1, event->Par2);
setPinState(PLUGIN_ID_001, event->Par1, PIN_MODE_PWM, event->Par2);
log = String(F("SW : GPIO ")) + String(event->Par1) + String(F(" Set PWM to ")) + String(event->Par2);
addLog(LOG_LEVEL_INFO, log);
if (printToWeb)
printWebString += log;
SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_001, event->Par1, log, 0));
}
}
if (tmpString.equalsIgnoreCase(F("Pulse")))
if (command == F("pulse"))
{
success = true;
if (event->Par1 >= 0 && event->Par1 <= 16)
@@ -231,29 +232,29 @@ boolean Plugin_001(byte function, struct EventStruct *event, String& string)
digitalWrite(event->Par1, event->Par2);
delay(event->Par3);
digitalWrite(event->Par1, !event->Par2);
log = String(F("SW : GPIO ")) + String(event->Par1) + String(F(" Pulsed for ")) + String(event->Par3) + String(F(" mS<BR>"));
setPinState(PLUGIN_ID_001, event->Par1, PIN_MODE_OUTPUT, event->Par2);
log = String(F("SW : GPIO ")) + String(event->Par1) + String(F(" Pulsed for ")) + String(event->Par3) + String(F(" mS"));
addLog(LOG_LEVEL_INFO, log);
if (printToWeb)
printWebString += log;
SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_001, event->Par1, log, 0));
}
}
if (tmpString.equalsIgnoreCase(F("LongPulse")))
if (command == F("longpulse"))
{
success = true;
if (event->Par1 >= 0 && event->Par1 <= 16)
{
pinMode(event->Par1, OUTPUT);
digitalWrite(event->Par1, event->Par2);
setPinState(PLUGIN_ID_001, event->Par1, PIN_MODE_OUTPUT, event->Par2);
setSystemTimer(event->Par3 * 1000, PLUGIN_ID_001, event->Par1, !event->Par2, 0);
log = String(F("SW : GPIO ")) + String(event->Par1) + String(F(" Pulse set for ")) + String(event->Par3) + String(F(" S<BR>"));
log = String(F("SW : GPIO ")) + String(event->Par1) + String(F(" Pulse set for ")) + String(event->Par3) + String(F(" S"));
addLog(LOG_LEVEL_INFO, log);
if (printToWeb)
printWebString += log;
SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_001, event->Par1, log, 0));
}
}
if (tmpString.equalsIgnoreCase(F("Servo")))
if (command == F("servo"))
{
success = true;
if (event->Par1 >= 0 && event->Par1 <= 2)
@@ -268,27 +269,35 @@ boolean Plugin_001(byte function, struct EventStruct *event, String& string)
myservo2.write(event->Par3);
break;
}
setPinState(PLUGIN_ID_001, event->Par2, PIN_MODE_SERVO, event->Par3);
log = String(F("SW : GPIO ")) + String(event->Par2) + String(F(" Servo set to ")) + String(event->Par3);
addLog(LOG_LEVEL_INFO, log);
SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_001, event->Par2, log, 0));
}
if (command == F("status"))
{
if (parseString(string, 2) == F("gpio"))
{
log = String(F("SW : GPIO ")) + String(event->Par2) + String(F(" Servo set to ")) + String(event->Par3);
addLog(LOG_LEVEL_INFO, log);
if (printToWeb)
printWebString += log;
success = true;
SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_001, event->Par2, dummyString, 0));
}
}
if (tmpString.equalsIgnoreCase(F("inputSwitchState")))
if (command == F("inputswitchstate"))
{
success = true;
UserVar[event->Par1 * VARS_PER_TASK] = event->Par2;
outputstate[event->Par1] = event->Par2;
}
break;
}
case PLUGIN_TIMER_IN:
{
digitalWrite(event->Par1, event->Par2);
setPinState(PLUGIN_ID_001, event->Par1, PIN_MODE_OUTPUT, event->Par2);
break;
}
}
+34 -16
View File
@@ -48,6 +48,7 @@ boolean Plugin_009(byte function, struct EventStruct *event, String& string)
switchstate[event->TaskIndex] = Plugin_009_Read(Settings.TaskDevicePort[event->TaskIndex]);
// Turn on Pullup resistor
Plugin_009_Config(Settings.TaskDevicePort[event->TaskIndex], 1);
setPinState(PLUGIN_ID_009, Settings.TaskDevicePort[event->TaskIndex], PIN_MODE_INPUT, 0);
success = true;
break;
}
@@ -75,21 +76,19 @@ boolean Plugin_009(byte function, struct EventStruct *event, String& string)
case PLUGIN_WRITE:
{
String log = "";
String tmpString = string;
int argIndex = tmpString.indexOf(',');
if (argIndex)
tmpString = tmpString.substring(0, argIndex);
if (tmpString.equalsIgnoreCase(F("MCPGPIO")))
String command = parseString(string, 1);
if (command == F("mcpgpio"))
{
success = true;
Plugin_009_Write(event->Par1, event->Par2);
setPinState(PLUGIN_ID_009, event->Par1, PIN_MODE_OUTPUT, event->Par2);
log = String(F("MCP : GPIO ")) + String(event->Par1) + String(F(" Set to ")) + String(event->Par2);
addLog(LOG_LEVEL_INFO, log);
if (printToWeb)
printWebString += log;
SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_009, event->Par1, log, 0));
}
if (tmpString.equalsIgnoreCase(F("MCPPulse")))
if (command == F("mcppulse"))
{
success = true;
if (event->Par1 >= 0 && event->Par1 <= 128)
@@ -97,33 +96,52 @@ boolean Plugin_009(byte function, struct EventStruct *event, String& string)
Plugin_009_Write(event->Par1, event->Par2);
delay(event->Par3);
Plugin_009_Write(event->Par1, !event->Par2);
log = String(F("MCP : GPIO ")) + String(event->Par1) + String(F(" Pulsed for ")) + String(event->Par3) + String(F(" mS<BR>"));
setPinState(PLUGIN_ID_009, event->Par1, PIN_MODE_OUTPUT, event->Par2);
log = String(F("MCP : GPIO ")) + String(event->Par1) + String(F(" Pulsed for ")) + String(event->Par3) + String(F(" mS"));
addLog(LOG_LEVEL_INFO, log);
if (printToWeb)
printWebString += log;
SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_009, event->Par1, log, 0));
}
}
if (tmpString.equalsIgnoreCase(F("MCPLongPulse")))
if (command == F("mcplongpulse"))
{
success = true;
if (event->Par1 >= 0 && event->Par1 <= 128)
{
Plugin_009_Write(event->Par1, event->Par2);
setPinState(PLUGIN_ID_009, event->Par1, PIN_MODE_OUTPUT, event->Par2);
setSystemTimer(event->Par3 * 1000, PLUGIN_ID_009, event->Par1, !event->Par2, 0);
log = String(F("MCP : GPIO ")) + String(event->Par1) + String(F(" Pulse set for ")) + String(event->Par3) + String(F(" S<BR>"));
log = String(F("MCP : GPIO ")) + String(event->Par1) + String(F(" Pulse set for ")) + String(event->Par3) + String(F(" S"));
addLog(LOG_LEVEL_INFO, log);
if (printToWeb)
printWebString += log;
SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_009, event->Par1, log, 0));
}
}
if (command == F("status"))
{
if (parseString(string, 2) == F("mcp"))
{
success = true;
String status = "";
if (hasPinState(PLUGIN_ID_009, event->Par2)) // has been set as output
status = getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_009, event->Par2, dummyString, 0);
else
{
int state = Plugin_009_Read(event->Par2); // report as input
if (state != -1)
status = getPinStateJSON(NO_SEARCH_PIN_STATE, PLUGIN_ID_009, event->Par2, dummyString, state);
}
SendStatus(event->Source, status);
}
}
break;
}
case PLUGIN_TIMER_IN:
{
Plugin_009_Write(event->Par1, event->Par2);
setPinState(PLUGIN_ID_009, event->Par1, PIN_MODE_OUTPUT, event->Par2);
break;
}
}
+75 -39
View File
@@ -80,25 +80,7 @@ boolean Plugin_011(byte function, struct EventStruct *event, String& string)
case PLUGIN_READ:
{
uint8_t address = PLUGIN_011_I2C_ADDRESS;
Wire.beginTransmission(address);
if (Settings.TaskDevicePluginConfig[event->TaskIndex][0] == 0)
Wire.write(2); // Digital Read
else
Wire.write(4); // Analog Read
Wire.write(Settings.TaskDevicePort[event->TaskIndex]);
Wire.write(0);
Wire.write(0);
Wire.endTransmission();
delay(1); // remote unit needs some time for conversion...
Wire.requestFrom(address, (uint8_t)0x4);
byte buffer[4];
if (Wire.available() == 4)
{
for (byte x = 0; x < 4; x++)
buffer[x] = Wire.read();
UserVar[event->BaseVarIndex] = buffer[0] + 256 * buffer[1];
}
UserVar[event->BaseVarIndex] = Plugin_011_Read(Settings.TaskDevicePluginConfig[event->TaskIndex][0], Settings.TaskDevicePort[event->TaskIndex]);
String log = F("PME : PortValue: ");
log += UserVar[event->BaseVarIndex];
addLog(LOG_LEVEL_INFO, log);
@@ -109,21 +91,19 @@ boolean Plugin_011(byte function, struct EventStruct *event, String& string)
case PLUGIN_WRITE:
{
String log = "";
String tmpString = string;
int argIndex = tmpString.indexOf(',');
if (argIndex)
tmpString = tmpString.substring(0, argIndex);
if (tmpString.equalsIgnoreCase(F("EXTGPIO")))
String command = parseString(string, 1);
if (command == F("extgpio"))
{
success = true;
Plugin_011_Write(event->Par1, event->Par2);
setPinState(PLUGIN_ID_011, event->Par1, PIN_MODE_OUTPUT, event->Par2);
log = String(F("PME : GPIO ")) + String(event->Par1) + String(F(" Set to ")) + String(event->Par2);
addLog(LOG_LEVEL_INFO, log);
if (printToWeb)
printWebString += log;
SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_011, event->Par1, log, 0));
}
if (tmpString.equalsIgnoreCase(F("EXTPWM")))
if (command == F("extpwm"))
{
success = true;
uint8_t address = PLUGIN_011_I2C_ADDRESS;
@@ -133,13 +113,13 @@ boolean Plugin_011(byte function, struct EventStruct *event, String& string)
Wire.write(event->Par2 & 0xff);
Wire.write((event->Par2 >> 8));
Wire.endTransmission();
setPinState(PLUGIN_ID_011, event->Par1, PIN_MODE_PWM, event->Par2);
log = String(F("PME : GPIO ")) + String(event->Par1) + String(F(" Set PWM to ")) + String(event->Par2);
addLog(LOG_LEVEL_INFO, log);
if (printToWeb)
printWebString += log;
SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_011, event->Par1, log, 0));
}
if (tmpString.equalsIgnoreCase(F("EXTPulse")))
if (command == F("extpulse"))
{
success = true;
if (event->Par1 >= 0 && event->Par1 <= 13)
@@ -147,39 +127,95 @@ boolean Plugin_011(byte function, struct EventStruct *event, String& string)
Plugin_011_Write(event->Par1, event->Par2);
delay(event->Par3);
Plugin_011_Write(event->Par1, !event->Par2);
log = String(F("PME : GPIO ")) + String(event->Par1) + String(F(" Pulsed for ")) + String(event->Par3) + String(F(" mS<BR>"));
setPinState(PLUGIN_ID_011, event->Par1, PIN_MODE_OUTPUT, event->Par2);
log = String(F("PME : GPIO ")) + String(event->Par1) + String(F(" Pulsed for ")) + String(event->Par3) + String(F(" mS"));
addLog(LOG_LEVEL_INFO, log);
if (printToWeb)
printWebString += log;
SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_011, event->Par1, log, 0));
}
}
if (tmpString.equalsIgnoreCase(F("EXTLongPulse")))
if (command == F("extlongpulse"))
{
success = true;
if (event->Par1 >= 0 && event->Par1 <= 13)
{
Plugin_011_Write(event->Par1, event->Par2);
setSystemTimer(event->Par3 * 1000, PLUGIN_ID_011, event->Par1, !event->Par2, 0);
log = String(F("PME : GPIO ")) + String(event->Par1) + String(F(" Pulse set for ")) + String(event->Par3) + String(F(" S<BR>"));
setPinState(PLUGIN_ID_011, event->Par1, PIN_MODE_OUTPUT, event->Par2);
log = String(F("PME : GPIO ")) + String(event->Par1) + String(F(" Pulse set for ")) + String(event->Par3) + String(F(" S"));
addLog(LOG_LEVEL_INFO, log);
if (printToWeb)
printWebString += log;
SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_011, event->Par1, log, 0));
}
}
if (command == F("status"))
{
if (parseString(string, 2) == F("ext"))
{
success = true;
String status = "";
if (hasPinState(PLUGIN_ID_011, event->Par2)) // has been set as output
status = getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_011, event->Par2, dummyString, 0);
else
{
byte port = event->Par2; // port 0-13 is digital, ports 20-27 are mapped to A0-A7
byte type = 0; // digital
if (port > 13)
{
type = 1;
port -= 20;
}
int state = Plugin_011_Read(type, port); // report as input (todo: analog reading)
if (state != -1)
status = getPinStateJSON(NO_SEARCH_PIN_STATE, PLUGIN_ID_011, event->Par2, dummyString, state);
}
SendStatus(event->Source, status);
}
}
break;
}
case PLUGIN_TIMER_IN:
{
Plugin_011_Write(event->Par1, event->Par2);
setPinState(PLUGIN_ID_011, event->Par1, PIN_MODE_OUTPUT, event->Par2);
break;
}
}
}
return success;
}
//********************************************************************************
// PME read
//********************************************************************************
int Plugin_011_Read(byte Par1, byte Par2)
{
int value = -1;
uint8_t address = PLUGIN_011_I2C_ADDRESS;
Wire.beginTransmission(address);
if (Par1 == 0)
Wire.write(2); // Digital Read
else
Wire.write(4); // Analog Read
Wire.write(Par2);
Wire.write(0);
Wire.write(0);
Wire.endTransmission();
delay(1); // remote unit needs some time for conversion...
Wire.requestFrom(address, (uint8_t)0x4);
byte buffer[4];
if (Wire.available() == 4)
{
for (byte x = 0; x < 4; x++)
buffer[x] = Wire.read();
value = buffer[0] + 256 * buffer[1];
}
return value;
}
//********************************************************************************
// PME write
//********************************************************************************
+32 -16
View File
@@ -73,50 +73,66 @@ boolean Plugin_019(byte function, struct EventStruct *event, String& string)
case PLUGIN_WRITE:
{
String log = "";
String tmpString = string;
int argIndex = tmpString.indexOf(',');
if (argIndex)
tmpString = tmpString.substring(0, argIndex);
String command = parseString(string, 1);
if (tmpString.equalsIgnoreCase(F("PCFGPIO")))
if (command == F("pcfgpio"))
{
success = true;
Plugin_019_Write(event->Par1, event->Par2);
setPinState(PLUGIN_ID_019, event->Par1, PIN_MODE_OUTPUT, event->Par2);
log = String(F("PCF : GPIO ")) + String(event->Par1) + String(F(" Set to ")) + String(event->Par2);
addLog(LOG_LEVEL_INFO, log);
if (printToWeb)
printWebString += log;
SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_019, event->Par1, log, 0));
}
if (tmpString.equalsIgnoreCase(F("PCFPulse")))
if (command == F("pcfpulse"))
{
success = true;
Plugin_009_Write(event->Par1, event->Par2);
delay(event->Par3);
Plugin_009_Write(event->Par1, !event->Par2);
log = String(F("PCF : GPIO ")) + String(event->Par1) + String(F(" Pulsed for ")) + String(event->Par3) + String(F(" mS<BR>"));
setPinState(PLUGIN_ID_019, event->Par1, PIN_MODE_OUTPUT, event->Par2);
log = String(F("PCF : GPIO ")) + String(event->Par1) + String(F(" Pulsed for ")) + String(event->Par3) + String(F(" mS"));
addLog(LOG_LEVEL_INFO, log);
if (printToWeb)
printWebString += log;
SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_019, event->Par1, log, 0));
}
if (tmpString.equalsIgnoreCase(F("PCFLongPulse")))
if (command == F("pcflongpulse"))
{
success = true;
Plugin_009_Write(event->Par1, event->Par2);
setPinState(PLUGIN_ID_019, event->Par1, PIN_MODE_OUTPUT, event->Par2);
setSystemTimer(event->Par3 * 1000, PLUGIN_ID_019, event->Par1, !event->Par2, 0);
log = String(F("PCF : GPIO ")) + String(event->Par1) + String(F(" Pulse set for ")) + String(event->Par3) + String(F(" S<BR>"));
log = String(F("PCF : GPIO ")) + String(event->Par1) + String(F(" Pulse set for ")) + String(event->Par3) + String(F(" S"));
addLog(LOG_LEVEL_INFO, log);
if (printToWeb)
printWebString += log;
SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_019, event->Par1, log, 0));
}
if (command == F("status"))
{
if (parseString(string, 2) == F("pcf"))
{
success = true;
String status = "";
if (hasPinState(PLUGIN_ID_019, event->Par2)) // has been set as output
status = getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_019, event->Par2, dummyString, 0);
else
{
int state = Plugin_019_Read(event->Par2); // report as input
if (state != -1)
status = getPinStateJSON(NO_SEARCH_PIN_STATE, PLUGIN_ID_019, event->Par2, dummyString, state);
}
SendStatus(event->Source, status);
}
}
break;
}
case PLUGIN_TIMER_IN:
{
Plugin_019_Write(event->Par1, event->Par2);
setPinState(PLUGIN_ID_019, event->Par1, PIN_MODE_OUTPUT, event->Par2);
break;
}
}
+15 -7
View File
@@ -60,18 +60,26 @@ boolean Plugin_022(byte function, struct EventStruct *event, String& string)
Plugin_022_writeRegister(PCA9685_MODE2, (byte)0x10); // set to output
Plugin_022_init = true;
}
String tmpString = string;
int argIndex = tmpString.indexOf(',');
if (argIndex)
tmpString = tmpString.substring(0, argIndex);
if (tmpString.equalsIgnoreCase(F("PCAPWM")))
String command = parseString(string, 1);
if (command == F("pcapwm"))
{
success = true;
Plugin_022_Write(event->Par1, event->Par2);
setPinState(PLUGIN_ID_022, event->Par1, PIN_MODE_PWM, event->Par2);
log = String(F("PCA : GPIO ")) + String(event->Par1) + String(F(" Set PWM to ")) + String(event->Par2);
addLog(LOG_LEVEL_INFO, log);
if (printToWeb)
printWebString += log;
SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_022, event->Par1, log, 0));
}
if (command == F("status"))
{
if (parseString(string, 2) == F("pca"))
{
success = true;
SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_022, event->Par2, dummyString, 0));
}
}
break;
}
+8
View File
@@ -1,3 +1,11 @@
// R85 13-03-2016
// Preparations for Arduino Core 2.1.0
// Fixed and tested HTTP authentication in C001
// Servo library seems to have issues in Core 2.1.0. Using the servo library from 2.0.0.
// I2C clockstretchlimit can be set using tools/advanced.
// Preparations for global pinstate maintenance and status requests
// Redesign on plugin write output reporting as it was still focussed on HTTP only.
// R84 08-03-2016
// Preparations for Arduino Core 2.1.0
// base64 encoding for HTTP authentication in C001