Skip to content

Commit

Permalink
[Minimal OTA] Make minimal OTA build fit again
Browse files Browse the repository at this point in the history
  • Loading branch information
TD-er committed Jan 12, 2021
1 parent d2c2038 commit 3386806
Show file tree
Hide file tree
Showing 43 changed files with 181 additions and 166 deletions.
6 changes: 0 additions & 6 deletions src/ESPEasy_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ namespace std
#include "user_interface.h"
}

#ifdef FEATURE_MDNS
#include <ESP8266mDNS.h>
#endif
#define SMALLEST_OTA_IMAGE 276848 // smallest known 2-step OTA image
#define MAX_SKETCH_SIZE 1044464 // 1020 kB - 16 bytes
#define PIN_D_MAX 16
Expand All @@ -117,9 +114,6 @@ namespace std
// #include "esp32_ping.h"
#include <rom/rtc.h>
#include "esp_wifi.h" // Needed to call ESP-IDF functions like esp_wifi_....
#ifdef FEATURE_MDNS
#include <ESPmDNS.h>
#endif
#define PIN_D_MAX 39
#define MAX_SKETCH_SIZE 1900544 // 0x1d0000 look at partitions in csv file
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/_C018.ino
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ bool CPlugin_018(CPlugin::Function function, struct EventStruct *event, String&
addHtml(c018_add_joinChanged_script_element_line(F("devaddr"), false));
addHtml(c018_add_joinChanged_script_element_line(F("nskey"), false));
addHtml(c018_add_joinChanged_script_element_line(F("appskey"), false));
addHtml("}");
addHtml('}');
html_add_script_end();
}

Expand Down
8 changes: 4 additions & 4 deletions src/_N001_Email.ino
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ boolean NPlugin_001_send(const NotificationSettingsStruct& notificationsettings,
mailheader.replace(String(F("$emailfrom")), notificationsettings.Sender);
} else {
String senderName = email_address.substring(0, pos_less);
senderName.replace("\"", ""); // Remove quotes
senderName.replace(F("\""), F("")); // Remove quotes
String address = email_address.substring(pos_less + 1);
address.replace("<", "");
address.replace(">", "");
address.replace(F("<"), F(""));
address.replace(F(">"), F(""));
address.trim();
senderName.trim();
mailheader.replace(String(F("$nodename")), senderName);
Expand All @@ -125,7 +125,7 @@ boolean NPlugin_001_send(const NotificationSettingsStruct& notificationsettings,
mailheader.replace(String(F("$ato")), notificationsettings.Receiver);
mailheader.replace(String(F("$subject")), aSub);
mailheader.replace(String(F("$espeasyversion")), String(BUILD));
aMesg.replace("\r", F("<br/>")); // re-write line breaks for Content-type: text/html
aMesg.replace(F("\r"), F("<br/>")); // re-write line breaks for Content-type: text/html

// Wait for Client to Start Sending
// The MTA Exchange
Expand Down
2 changes: 1 addition & 1 deletion src/_P020_Ser2Net.ino
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ boolean Plugin_020(byte function, struct EventStruct *event, String& string)
if (Settings.UseRules)
{
String message = (char *)serial_buf;
int NewLinePos = message.indexOf("\r\n");
int NewLinePos = message.indexOf(F("\r\n"));

if (NewLinePos > 0) {
message = message.substring(0, NewLinePos);
Expand Down
4 changes: 2 additions & 2 deletions src/_P022_PCA9685.ino
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ boolean Plugin_022(byte function, struct EventStruct *event, String& string)
{
LoadTaskSettings(event->TaskIndex);
String name = line.substring(0, dotPos);
name.replace("[", "");
name.replace("]", "");
name.replace(F("["), F(""));
name.replace(F("]"), F(""));

if (name.equalsIgnoreCase(getTaskDeviceName(event->TaskIndex))) {
line = line.substring(dotPos + 1);
Expand Down
16 changes: 3 additions & 13 deletions src/_P026_Sysinfo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@


#include "src/DataStructs/ESPEasy_packed_raw_data.h"
#include "src/ESPEasyCore/ESPEasyNetwork.h"
#include "src/Helpers/Memory.h"
#include "ESPEasy-Globals.h"

#define PLUGIN_026
#define PLUGIN_ID_026 26
Expand Down Expand Up @@ -226,23 +228,11 @@ float P026_get_value(int type)
break;
}
case 5:
{
value = NetworkLocalIP()[0];
break;
}
case 6:
{
value = NetworkLocalIP()[1];
break;
}
case 7:
{
value = NetworkLocalIP()[2];
break;
}
case 8:
{
value = NetworkLocalIP()[3];
value = NetworkLocalIP()[type - 5];
break;
}
case 9:
Expand Down
2 changes: 1 addition & 1 deletion src/_P042_Candle.ino
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ boolean Plugin_042(byte function, struct EventStruct *event, String& string)
addHtml(F(" document.getElementById('web_RGB_Red').value = Math.round(picker.rgb[0]);"));
addHtml(F(" document.getElementById('web_RGB_Green').value = Math.round(picker.rgb[1]);"));
addHtml(F(" document.getElementById('web_RGB_Blue').value = Math.round(picker.rgb[2]);"));
addHtml("}");
addHtml('}');
addHtml(F("</script>"));

addHtml(F("<script type='text/javascript'>window.addEventListener('load', function(){"));
Expand Down
2 changes: 1 addition & 1 deletion src/_P095_ILI9341.ino
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ boolean Plugin_095(byte function, struct EventStruct *event, String& string)
addLog(LOG_LEVEL_INFO, F("Fail to parse command correctly; please check API documentation"));
String log2 = F("Parsed command = \"");
log2 += string;
log2 += "\"";
log2 += F("\"");
addLog(LOG_LEVEL_INFO, log2);
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/src/Commands/InternalCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ bool checkNrArguments(const char *cmd, const char *Line, int nrArguments) {

// 0 arguments means argument on pos1 is valid (the command) and argpos 2 should not be there.
if (HasArgv(Line, nrArguments + 2)) {
#ifndef BUILD_NO_DEBUG
if (loglevelActiveFor(LOG_LEVEL_ERROR)) {
String log;
log.reserve(128);
Expand Down Expand Up @@ -103,6 +104,7 @@ bool checkNrArguments(const char *cmd, const char *Line, int nrArguments) {
log += F(" See: https://github.com/letscontrolit/ESPEasy/issues/2724");
addLog(LOG_LEVEL_ERROR, log);
}
#endif

if (Settings.TolerantLastArgParse()) {
return true;
Expand Down Expand Up @@ -286,7 +288,9 @@ bool executeInternalCommand(command_case_data & data)
case 'n': {
COMMAND_CASE_R( "name", Command_Settings_Name, 1); // Settings.h
COMMAND_CASE_R("nosleep", Command_System_NoSleep, 1); // System.h
#ifdef USES_NOTIFIER
COMMAND_CASE_R( "notify", Command_Notifications_Notify, 2); // Notifications.h
#endif
COMMAND_CASE_R("ntphost", Command_NTPHost, 1); // Time.h
break;
}
Expand Down Expand Up @@ -373,8 +377,10 @@ bool executeInternalCommand(command_case_data & data)
break;
}
case 'w': {
#ifndef LIMIT_BUILD_SIZE
COMMAND_CASE_R("wdconfig", Command_WD_Config, 3); // WD.h
COMMAND_CASE_R( "wdread", Command_WD_Read, 2); // WD.h
#endif

if (data.cmd_lc[1] == 'i') {
COMMAND_CASE_R( "wifiapmode", Command_Wifi_APMode, 0); // WiFi.h
Expand Down
4 changes: 4 additions & 0 deletions src/src/Commands/Notifications.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "../Commands/Notifications.h"

#ifdef USES_NOTIFIER

#include "../Commands/Common.h"

#include "../../ESPEasy_common.h"
Expand Down Expand Up @@ -30,3 +32,5 @@ String Command_Notifications_Notify(struct EventStruct *event, const char* Line)
}
return return_command_success();
}

#endif
6 changes: 6 additions & 0 deletions src/src/Commands/Notifications.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
#ifndef COMMAND_NOTIFICATIONS_H
#define COMMAND_NOTIFICATIONS_H

#include "../../ESPEasy_common.h"

#ifdef USES_NOTIFIER

class String;

String Command_Notifications_Notify(struct EventStruct *event, const char* Line);

#endif

#endif // COMMAND_NOTIFICATIONS_H
3 changes: 3 additions & 0 deletions src/src/Commands/wd.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "../Commands/wd.h"

#ifndef LIMIT_BUILD_SIZE

#include "../Commands/Common.h"

Expand Down Expand Up @@ -37,3 +38,5 @@ String Command_WD_Read(EventStruct *event, const char* Line)
}
return return_command_success();
}

#endif
6 changes: 6 additions & 0 deletions src/src/Commands/wd.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
#ifndef COMMAND_WD_H
#define COMMAND_WD_H

#include "../Commands/Common.h"

#ifndef LIMIT_BUILD_SIZE

class String;
struct EventStruct;

String Command_WD_Config(EventStruct *event, const char* Line);
String Command_WD_Read(EventStruct *event, const char* Line);

#endif

#endif // COMMAND_WD_H
2 changes: 1 addition & 1 deletion src/src/CustomBuild/define_plugin_sets.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ To create/register a plugin, you have to :
#define USES_C008 // Generic HTTP
// #define USES_C009 // FHEM HTTP
// #define USES_C010 // Generic UDP
#define USES_C013 // ESPEasy P2P network
// #define USES_C013 // ESPEasy P2P network

// #define NOTIFIER_SET_STABLE
#define NOTIFIER_SET_NONE
Expand Down
3 changes: 3 additions & 0 deletions src/src/DataStructs/C013_p2p_dataStructs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "../Globals/Plugins.h"
#include "../../ESPEasy_common.h"

#ifdef USES_C013

C013_SensorInfoStruct::C013_SensorInfoStruct()
{
Expand Down Expand Up @@ -44,3 +45,5 @@ bool C013_SensorDataStruct::isValid() const
}
return true;
}

#endif
3 changes: 2 additions & 1 deletion src/src/DataStructs/C013_p2p_dataStructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

// These structs are sent to other nodes, so make sure not to change order or offset in struct.


#ifdef USES_C013
struct C013_SensorInfoStruct
{
C013_SensorInfoStruct();
Expand Down Expand Up @@ -41,5 +41,6 @@ struct C013_SensorDataStruct
float Values[VARS_PER_TASK];
};

#endif

#endif // DATASTRUCTS_C013_P2P_DATASTRUCTS_H
19 changes: 18 additions & 1 deletion src/src/DataStructs/GpioFactorySettingsStruct.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "GpioFactorySettingsStruct.h"
#include "../DataStructs/GpioFactorySettingsStruct.h"

#include "../CustomBuild/ESPEasyDefaults.h"

Expand All @@ -22,6 +22,7 @@ GpioFactorySettingsStruct::GpioFactorySettingsStruct(DeviceModel model)
}

switch (model) {
#if defined(ESP8266) && !defined(LIMIT_BUILD_SIZE)
case DeviceModel_Sonoff_Basic:
case DeviceModel_Sonoff_TH1x:
case DeviceModel_Sonoff_S2x:
Expand Down Expand Up @@ -88,6 +89,22 @@ GpioFactorySettingsStruct::GpioFactorySettingsStruct(DeviceModel model)
i2c_sda = -1; // GPIO4 conflicts with relay control.
i2c_scl = -1; // GPIO5 conflicts with SW input
break;
#else
case DeviceModel_Sonoff_Basic:
case DeviceModel_Sonoff_TH1x:
case DeviceModel_Sonoff_S2x:
case DeviceModel_Sonoff_TouchT1:
case DeviceModel_Sonoff_POWr2:
case DeviceModel_Sonoff_POW:
case DeviceModel_Sonoff_TouchT2:
case DeviceModel_Sonoff_TouchT3:
case DeviceModel_Sonoff_4ch:
case DeviceModel_Shelly1:
case DeviceModel_ShellyPLUG_S:
break;
#endif


#ifdef ESP32
case DeviceMode_Olimex_ESP32_PoE:
button[0] = 34; // BUT1 Button
Expand Down
1 change: 1 addition & 0 deletions src/src/DataStructs/GpioFactorySettingsStruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "../DataTypes/NetworkMedium.h"



struct GpioFactorySettingsStruct {
GpioFactorySettingsStruct(DeviceModel model = DeviceModel_default);

Expand Down
4 changes: 2 additions & 2 deletions src/src/ESPEasyCore/ESPEasyNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ String NetworkCreateRFCCompliantHostname(bool force_add_unitnr) {
String createRFCCompliantHostname(const String& oldString) {
String result(oldString);

result.replace(" ", "-");
result.replace("_", "-"); // See RFC952
result.replace(' ', '-');
result.replace('_', '-'); // See RFC952
return result;
}

Expand Down
Loading

0 comments on commit 3386806

Please sign in to comment.