Compare commits

...
17 Commits
Author SHA1 Message Date
ESPEasy release bot f59f25ee40 automaticly updated release notes for v2.0-20180510 2018-05-10 04:00:27 +02:00
Gijs NoorlanderandGitHub 14030ec15b Merge pull request #1395 from letscontrolit/revert-1389-patch-1
Revert "Update _P045_MPU6050.ino"
2018-05-09 23:42:50 +02:00
Gijs NoorlanderandGitHub 1fd6179408 Revert "Update _P045_MPU6050.ino" 2018-05-09 23:40:27 +02:00
Gijs NoorlanderandGitHub 22424fb03b Merge pull request #1389 from maartenpaauw/patch-1
Update _P045_MPU6050.ino
2018-05-09 23:33:26 +02:00
Maarten PaauwandGitHub 97cd06440e Update _P045_MPU6050.ino
Fix debug code (commented out code).
2018-05-08 23:14:08 +02:00
ESPEasy release bot 8346e39ac9 automaticly updated release notes for v2.0-20180322 2018-03-22 04:00:24 +01:00
TD-er 22371649a4 [WiFi] Take much more time for initial WiFi connect during setup
Accesspoint is still active, so it may take a lot more time to make the initial connection
2018-03-22 01:05:56 +01:00
Gijs NoorlanderandGitHub 8cbd9a0822 Merge pull request #1148 from TD-er/merge/mega_to_v2.0_0321
Merge/mega to v2.0 0321
2018-03-22 00:24:59 +01:00
TD-er 93f9d11738 [Memory] parseTemplate did not check if markers were found
"Free Mem" reported this function to be using quite a lot of memory.
Maybe that was related to parsing texts without matching ']' or '#'
Just added some checks to see if they were found.
2018-03-22 00:24:17 +01:00
TD-er cf3e0a3f0a [wifi] Make more robust checks and increase timeout
See #1145
2018-03-22 00:12:04 +01:00
s0170071andTD-er ccfd14dbd3 Serial WD crash 2018-03-22 00:11:48 +01:00
Bartlomiej ZimonandTD-er 3034738ad4 - P048 fetch params only when needed 2018-03-22 00:11:30 +01:00
TD-er 178d1c46a2 - P035 move strings to flash 2018-03-22 00:11:21 +01:00
Bartlomiej ZimonandTD-er cdfd1d986e - P023 fix command interpretation 2018-03-22 00:10:55 +01:00
Bartlomiej ZimonandTD-er 4b7aa53692 - P012 fix command interpretation 2018-03-22 00:10:50 +01:00
ESPEasy release bot cc02fa4481 automaticly updated release notes for v2.0-20180321 2018-03-21 04:00:21 +01:00
Gijs NoorlanderandGitHub ab3a406706 [merge issue] Forgotten #endif in merge 2018-03-20 23:46:43 +01:00
8 changed files with 186 additions and 118 deletions
+47
View File
@@ -1,3 +1,50 @@
-------------------------------------------------
Changes in release v2.0-20180510 (since v2.0-20180322)
-------------------------------------------------
Release date: Thu May 10 04:00:27 CEST 2018
Gijs Noorlander (1):
Revert "Update _P045_MPU6050.ino"
Maarten Paauw (1):
Update _P045_MPU6050.ino
-------------------------------------------------
Changes in release v2.0-20180322 (since v2.0-20180321)
-------------------------------------------------
Release date: Thu Mar 22 04:00:24 CET 2018
Bartlomiej Zimon (3):
- P012 fix command interpretation
- P023 fix command interpretation
- P048 fetch params only when needed
TD-er (4):
- P035 move strings to flash
[wifi] Make more robust checks and increase timeout
[Memory] parseTemplate did not check if markers were found
[WiFi] Take much more time for initial WiFi connect during setup
s0170071 (1):
Serial WD crash
-------------------------------------------------
Changes in release v2.0-20180321 (since v2.0-20180320)
-------------------------------------------------
Release date: Wed Mar 21 04:00:21 CET 2018
Gijs Noorlander (1):
[merge issue] Forgotten #endif in merge
Unknown (1):
[wifi] Setup with factory settings could not complete
-------------------------------------------------
Changes in release v2.0-20180320 (since v2.0-20180319)
-------------------------------------------------
+2 -1
View File
@@ -27,7 +27,8 @@
#define DEFAULT_DNS "192.168.0.1" // Enter your DNS
#define DEFAULT_GW "192.168.0.1" // Enter your Gateway
#define DEFAULT_SUBNET "255.255.255.0" // Enter your Subnet
#endif
#define DEFAULT_WIFI_CONNECTION_TIMEOUT 10000 // minimum timeout in ms for WiFi to be connected.
// --- Default Controller ------------------------------------------------------------------------------
#define DEFAULT_CONTROLLER false // true or false enabled or disabled, set 1st controller defaults
+65 -63
View File
@@ -1320,74 +1320,76 @@ String parseTemplate(String &tmpString, byte lineSize)
newString += tmpString.substring(0, leftBracketIndex);
tmpString = tmpString.substring(leftBracketIndex + 1);
int rightBracketIndex = tmpString.indexOf(']');
if (rightBracketIndex)
if (rightBracketIndex >= 0)
{
tmpStringMid = tmpString.substring(0, rightBracketIndex);
tmpString = tmpString.substring(rightBracketIndex + 1);
int hashtagIndex = tmpStringMid.indexOf('#');
String deviceName = tmpStringMid.substring(0, hashtagIndex);
String valueName = tmpStringMid.substring(hashtagIndex + 1);
String valueFormat = "";
hashtagIndex = valueName.indexOf('#');
if (hashtagIndex >= 0)
{
valueFormat = valueName.substring(hashtagIndex + 1);
valueName = valueName.substring(0, hashtagIndex);
}
for (byte y = 0; y < TASKS_MAX; y++)
{
if (Settings.TaskDeviceEnabled[y])
if (hashtagIndex >= 0) {
String deviceName = tmpStringMid.substring(0, hashtagIndex);
String valueName = tmpStringMid.substring(hashtagIndex + 1);
String valueFormat = "";
hashtagIndex = valueName.indexOf('#');
if (hashtagIndex >= 0)
{
LoadTaskSettings(y);
if (ExtraTaskSettings.TaskDeviceName[0] != 0)
valueFormat = valueName.substring(hashtagIndex + 1);
valueName = valueName.substring(0, hashtagIndex);
}
for (byte y = 0; y < TASKS_MAX; y++)
{
if (Settings.TaskDeviceEnabled[y])
{
if (deviceName.equalsIgnoreCase(ExtraTaskSettings.TaskDeviceName))
LoadTaskSettings(y);
if (ExtraTaskSettings.TaskDeviceName[0] != 0)
{
boolean match = false;
for (byte z = 0; z < VARS_PER_TASK; z++)
if (valueName.equalsIgnoreCase(ExtraTaskSettings.TaskDeviceValueNames[z]))
{
// here we know the task and value, so find the uservar
match = true;
String value = "";
byte DeviceIndex = getDeviceIndex(Settings.TaskDeviceNumber[y]);
if (Device[DeviceIndex].VType == SENSOR_TYPE_LONG)
value = (unsigned long)UserVar[y * VARS_PER_TASK + z] + ((unsigned long)UserVar[y * VARS_PER_TASK + z + 1] << 16);
else
value = toString(UserVar[y * VARS_PER_TASK + z], ExtraTaskSettings.TaskDeviceValueDecimals[z]);
int oidx;
if ((oidx = valueFormat.indexOf('O'))>=0) // Output
{
valueFormat.remove(oidx);
oidx = valueFormat.indexOf('!'); // inverted or active low
float val = value.toFloat();
if (oidx >= 0) {
valueFormat.remove(oidx);
value = val == 0 ? " ON" : "OFF";
} else {
value = val == 0 ? "OFF" : " ON";
}
}
if (valueFormat == "R")
{
int filler = lineSize - newString.length() - value.length() - tmpString.length() ;
for (byte f = 0; f < filler; f++)
newString += " ";
}
newString += String(value);
break;
}
if (!match) // try if this is a get config request
if (deviceName.equalsIgnoreCase(ExtraTaskSettings.TaskDeviceName))
{
struct EventStruct TempEvent;
TempEvent.TaskIndex = y;
String tmpName = valueName;
if (PluginCall(PLUGIN_GET_CONFIG, &TempEvent, tmpName))
newString += tmpName;
boolean match = false;
for (byte z = 0; z < VARS_PER_TASK; z++)
if (valueName.equalsIgnoreCase(ExtraTaskSettings.TaskDeviceValueNames[z]))
{
// here we know the task and value, so find the uservar
match = true;
String value = "";
byte DeviceIndex = getDeviceIndex(Settings.TaskDeviceNumber[y]);
if (Device[DeviceIndex].VType == SENSOR_TYPE_LONG)
value = (unsigned long)UserVar[y * VARS_PER_TASK + z] + ((unsigned long)UserVar[y * VARS_PER_TASK + z + 1] << 16);
else
value = toString(UserVar[y * VARS_PER_TASK + z], ExtraTaskSettings.TaskDeviceValueDecimals[z]);
int oidx;
if ((oidx = valueFormat.indexOf('O'))>=0) // Output
{
valueFormat.remove(oidx);
oidx = valueFormat.indexOf('!'); // inverted or active low
float val = value.toFloat();
if (oidx >= 0) {
valueFormat.remove(oidx);
value = val == 0 ? " ON" : "OFF";
} else {
value = val == 0 ? "OFF" : " ON";
}
}
if (valueFormat == "R")
{
int filler = lineSize - newString.length() - value.length() - tmpString.length() ;
for (byte f = 0; f < filler; f++)
newString += " ";
}
newString += String(value);
break;
}
if (!match) // try if this is a get config request
{
struct EventStruct TempEvent;
TempEvent.TaskIndex = y;
String tmpName = valueName;
if (PluginCall(PLUGIN_GET_CONFIG, &TempEvent, tmpName))
newString += tmpName;
}
break;
}
break;
}
}
}
@@ -1807,7 +1809,7 @@ String rulesProcessingFile(String fileName, String& event)
line = parseTemplate(line, line.length());
}
line.trim();
String lineOrg = line; // store original line for future use
line.toLowerCase(); // convert all to lower case to make checks easier
@@ -1854,9 +1856,9 @@ String rulesProcessingFile(String fileName, String& event)
{
isCommand = false;
codeBlock = false;
match = false;
match = false;
}
if (Settings.SerialLogLevel == LOG_LEVEL_DEBUG_DEV){
Serial.print(F("RuleDebug: "));
Serial.print(codeBlock);
@@ -1865,7 +1867,7 @@ String rulesProcessingFile(String fileName, String& event)
Serial.print(": ");
Serial.println(line);
}
if (match) // rule matched for one action or a block of actions
{
int split = lcAction.indexOf("if "); // check for optional "if" condition
+36 -15
View File
@@ -4,7 +4,7 @@
String WifiGetAPssid()
{
String ssid(Settings.Name);
ssid+=F("_");
ssid+=F("-");
ssid+=Settings.Unit;
return (ssid);
}
@@ -27,7 +27,10 @@ void WifiAPconfig()
{
// create and store unique AP SSID/PW to prevent ESP from starting AP mode with default SSID and No password!
// setup ssid for AP Mode when needed
WiFi.softAP(WifiGetAPssid().c_str(), SecuritySettings.WifiAPKey);
String softAPSSID=WifiGetAPssid();
String pwd = SecuritySettings.WifiAPKey;
WiFi.softAP(softAPSSID.c_str(),pwd.c_str());
// We start in STA mode
WifiAPMode(false);
@@ -77,7 +80,7 @@ void WifiAPMode(boolean state)
//********************************************************************************
// Set Wifi config
//********************************************************************************
void prepareWiFi() {
bool prepareWiFi() {
String log = "";
char hostname[40];
strncpy(hostname, WifiGetHostname().c_str(), sizeof(hostname));
@@ -97,6 +100,7 @@ void prepareWiFi() {
IPAddress dns = Settings.DNS;
WiFi.config(ip, gw, subnet, dns);
}
return selectValidWiFiSettings();
}
//********************************************************************************
@@ -104,8 +108,7 @@ void prepareWiFi() {
//********************************************************************************
boolean WifiConnect(byte connectAttempts)
{
prepareWiFi();
if (anyValidWifiSettings()) {
if (prepareWiFi()) {
//try to connect to one of the access points
bool connected = WifiConnectAndWait(connectAttempts);
if (!connected) {
@@ -127,10 +130,9 @@ boolean WifiConnect(byte connectAttempts)
// Start connect to WiFi and check later to see if connected.
//********************************************************************************
void WiFiConnectRelaxed() {
prepareWiFi();
wifiConnected = false;
wifi_connect_attempt = 0;
if (anyValidWifiSettings()) {
if (prepareWiFi()) {
tryConnectWiFi();
return;
}
@@ -161,29 +163,42 @@ bool anyValidWifiSettings() {
}
bool selectNextWiFiSettings() {
uint8_t tmp = lastWiFiSettings;
lastWiFiSettings = (lastWiFiSettings + 1) % 2;
if (!wifiSettingsValid(getLastWiFiSettingsSSID(), getLastWiFiSettingsPassphrase())) {
// other settings are not correct, switch back.
lastWiFiSettings = (lastWiFiSettings + 1) % 2;
lastWiFiSettings = tmp;
return false; // Nothing changed.
}
return true;
}
bool selectValidWiFiSettings() {
if (wifiSettingsValid(getLastWiFiSettingsSSID(), getLastWiFiSettingsPassphrase()))
return true;
return selectNextWiFiSettings();
}
bool wifiSettingsValid(const char* ssid, const char* pass) {
if (ssid[0] == 0 || (strcasecmp(ssid, "ssid") == 0)) {
return false;
}
if (pass[0] == 0) return false;
if (strlen(ssid) > 32) return false;
if (strlen(pass) > 64) return false;
return true;
}
bool wifiConnectTimeoutReached() {
if (wifi_connect_attempt == 0) return true;
if (wifiSetupConnect) {
// Initial setup of WiFi, may take much longer since accesspoint is still active.
return timeOutReached(wifi_connect_timer + 20000);
}
// wait until it connects + add some device specific random offset to prevent
// all nodes overloading the accesspoint when turning on at the same time.
const unsigned int randomOffset_in_sec = wifi_connect_attempt == 1 ? 0 : 1000 * ((ESP.getChipId() & 0xF));
return timeOutReached(wifi_connect_timer + 7000 + randomOffset_in_sec);
return timeOutReached(wifi_connect_timer + DEFAULT_WIFI_CONNECTION_TIMEOUT + randomOffset_in_sec);
}
//********************************************************************************
@@ -196,6 +211,8 @@ bool tryConnectWiFi() {
return(true); //already connected, need to disconnect first
if (!wifiConnectTimeoutReached())
return true; // timeout not reached yet, thus no need to retry again.
if (!anyValidWifiSettings())
return false;
if (wifi_connect_attempt != 0 && ((wifi_connect_attempt % 3) == 0)) {
// Change to other wifi settings.
@@ -206,8 +223,12 @@ bool tryConnectWiFi() {
//everything failed, activate AP mode (will deactivate automatically after a while if its connected again)
WifiAPMode(true);
}
const char* ssid = getLastWiFiSettingsSSID();
const char* passphrase = getLastWiFiSettingsPassphrase();
String ssid;
ssid.reserve(32);
String passphrase;
passphrase.reserve(64);
ssid = getLastWiFiSettingsSSID();
passphrase = getLastWiFiSettingsPassphrase();
String log = F("WIFI : Connecting ");
log += ssid;
log += F(" attempt #");
@@ -218,12 +239,12 @@ bool tryConnectWiFi() {
switch (wifi_connect_attempt) {
case 0:
if (lastBSSID[0] == 0)
WiFi.begin(ssid, passphrase);
WiFi.begin(ssid.c_str(), passphrase.c_str());
else
WiFi.begin(ssid, passphrase, 0, &lastBSSID[0]);
WiFi.begin(ssid.c_str(), passphrase.c_str(), 0, &lastBSSID[0]);
break;
default:
WiFi.begin(ssid, passphrase);
WiFi.begin(ssid.c_str(), passphrase.c_str());
}
++wifi_connect_attempt;
switch (WiFi.status()) {
@@ -284,9 +305,9 @@ boolean WifiConnectAndWait(byte connectAttempts)
bool checkWifiJustConnected() {
if (wifiConnected) return true;
delay(1);
if (WiFi.status() != WL_CONNECTED) {
statusLED(false);
delay(1);
return false;
}
wifiConnected = true;
+16 -17
View File
@@ -226,7 +226,22 @@ boolean Plugin_012(byte function, struct EventStruct *event, String& string)
if (argIndex)
tmpString = tmpString.substring(0, argIndex);
if (lcd && tmpString.equalsIgnoreCase(F("LCD")))
if (lcd && tmpString.equalsIgnoreCase(F("LCDCMD")))
{
success = true;
argIndex = string.lastIndexOf(',');
tmpString = string.substring(argIndex + 1);
if (tmpString.equalsIgnoreCase(F("Off"))){
lcd->noBacklight();
}
else if (tmpString.equalsIgnoreCase(F("On"))){
lcd->backlight();
}
else if (tmpString.equalsIgnoreCase(F("Clear"))){
lcd->clear();
}
}
else if (lcd && tmpString.equalsIgnoreCase(F("LCD")))
{
success = true;
argIndex = string.lastIndexOf(',');
@@ -281,22 +296,6 @@ boolean Plugin_012(byte function, struct EventStruct *event, String& string)
}
}
if (lcd && tmpString.equalsIgnoreCase(F("LCDCMD")))
{
success = true;
argIndex = string.lastIndexOf(',');
tmpString = string.substring(argIndex + 1);
if (tmpString.equalsIgnoreCase(F("Off"))){
lcd->noBacklight();
}
else if (tmpString.equalsIgnoreCase(F("On"))){
lcd->backlight();
}
else if (tmpString.equalsIgnoreCase(F("Clear"))){
lcd->clear();
}
}
break;
}
+8 -9
View File
@@ -184,14 +184,6 @@ boolean Plugin_023(byte function, struct EventStruct *event, String& string)
int argIndex = tmpString.indexOf(',');
if (argIndex)
tmpString = tmpString.substring(0, argIndex);
if (tmpString.equalsIgnoreCase(F("OLED")))
{
success = true;
argIndex = string.lastIndexOf(',');
tmpString = string.substring(argIndex + 1);
String newString = P023_parseTemplate(tmpString, 16);
Plugin_023_sendStrXY(newString.c_str(), event->Par1 - 1, event->Par2 - 1);
}
if (tmpString.equalsIgnoreCase(F("OLEDCMD")))
{
success = true;
@@ -204,9 +196,16 @@ boolean Plugin_023(byte function, struct EventStruct *event, String& string)
else if (tmpString.equalsIgnoreCase(F("Clear")))
Plugin_023_clear_display();
}
else if (tmpString.equalsIgnoreCase(F("OLED")))
{
success = true;
argIndex = string.lastIndexOf(',');
tmpString = string.substring(argIndex + 1);
String newString = P023_parseTemplate(tmpString, 16);
Plugin_023_sendStrXY(newString.c_str(), event->Par1 - 1, event->Par2 - 1);
}
break;
}
}
return success;
}
+7 -7
View File
@@ -199,13 +199,13 @@ boolean Plugin_035(byte function, struct EventStruct *event, String& string)
if (GetArgv(command, TmpStr1, 3)) IrCode = strtoul(TmpStr1, NULL, 16); //(long) TmpStr1
if (GetArgv(command, TmpStr1, 4)) IrBits = str2int(TmpStr1);
if (IrType.equalsIgnoreCase("NEC")) Plugin_035_irSender->sendNEC(IrCode, IrBits);
if (IrType.equalsIgnoreCase("JVC")) Plugin_035_irSender->sendJVC(IrCode, IrBits, 2);
if (IrType.equalsIgnoreCase("RC5")) Plugin_035_irSender->sendRC5(IrCode, IrBits);
if (IrType.equalsIgnoreCase("RC6")) Plugin_035_irSender->sendRC6(IrCode, IrBits);
if (IrType.equalsIgnoreCase("SAMSUNG")) Plugin_035_irSender->sendSAMSUNG(IrCode, IrBits);
if (IrType.equalsIgnoreCase("SONY")) Plugin_035_irSender->sendSony(IrCode, IrBits);
if (IrType.equalsIgnoreCase("PANASONIC")) Plugin_035_irSender->sendPanasonic(IrBits, IrCode);
if (IrType.equalsIgnoreCase(F("NEC"))) Plugin_035_irSender->sendNEC(IrCode, IrBits);
if (IrType.equalsIgnoreCase(F("JVC"))) Plugin_035_irSender->sendJVC(IrCode, IrBits, 2);
if (IrType.equalsIgnoreCase(F("RC5"))) Plugin_035_irSender->sendRC5(IrCode, IrBits);
if (IrType.equalsIgnoreCase(F("RC6"))) Plugin_035_irSender->sendRC6(IrCode, IrBits);
if (IrType.equalsIgnoreCase(F("SAMSUNG"))) Plugin_035_irSender->sendSAMSUNG(IrCode, IrBits);
if (IrType.equalsIgnoreCase(F("SONY"))) Plugin_035_irSender->sendSony(IrCode, IrBits);
if (IrType.equalsIgnoreCase(F("PANASONIC"))) Plugin_035_irSender->sendPanasonic(IrBits, IrCode);
}
addLog(LOG_LEVEL_INFO, F("IRTX :IR Code Sent"));
+5 -6
View File
@@ -102,18 +102,17 @@ boolean Plugin_048(byte function, struct EventStruct *event, String& string) {
String tmpString = string;
String cmd = parseString(tmpString, 1);
String param1 = parseString(tmpString, 2);
String param2 = parseString(tmpString, 3);
String param3 = parseString(tmpString, 4);
String param4 = parseString(tmpString, 5);
String param5 = parseString(tmpString, 6);
// Commands:
// MotorShieldCMD,<DCMotor>,<Motornumber>,<Forward/Backward/Release>,<Speed>
if (cmd.equalsIgnoreCase(F("MotorShieldCMD")))
{
String param1 = parseString(tmpString, 2);
String param2 = parseString(tmpString, 3);
String param3 = parseString(tmpString, 4);
String param4 = parseString(tmpString, 5);
String param5 = parseString(tmpString, 6);
// Create the motor shield object with the default I2C address
AFMS = Adafruit_MotorShield(Plugin_048_MotorShield_address);