Skip to content

Commit

Permalink
Add support for Arduino 3.0.1 for esp32
Browse files Browse the repository at this point in the history
  • Loading branch information
cziter15 committed Jun 16, 2024
1 parent 4662124 commit c45a7b4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
23 changes: 19 additions & 4 deletions platformio/libsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
# https://github.com/cziter15/ksIotFrameworkLib/blob/master/LICENSE

from logger import *
ksPrintLog(Colors.Green, "Running extra script for library.")

try:
Import("projenv", "env")
ksPrintLog(Colors.Green, "Running extra script for library.")

ksPrintLog(Colors.Magenta, "Building library environment list.")
environments = [env, DefaultEnvironment(), projenv]

for lb in env.GetLibBuilders():
environments.append(lb.env)

Expand All @@ -25,9 +25,24 @@
e.ProcessFlags("-DCORE_DEBUG_LEVEL=0")
e.ProcessFlags("-DNO_GLOBAL_ARDUINO_OTA=1")
e.ProcessFlags("-DWEBSOCKETS_SAVE_RAM=1")

# ESP32 version of Arduino has some changes for class names
if e["PIOPLATFORM"].startswith("espressif32"):
cpp_defines_dict = {}
for item in e["CPPDEFINES"]:
if isinstance(item, tuple):
key, value = item
cpp_defines_dict[key] = value
elif isinstance(item, str):
cpp_defines_dict[item] = 1
if (int(cpp_defines_dict.get('ARDUINO', None)) >= 10812):
e.ProcessFlags("-DWiFiClientSecure=NetworkClientSecure")
e.ProcessFlags("-DWiFiClient=NetworkClient")
e.ProcessFlags("-DWiFiServer=NetworkServer")
e.ProcessFlags("-DWiFiUDP=NetworkUDP")
e.ProcessFlags("-DARDUINO_3_OR_ABOVE=1")

ksPrintLog(Colors.Magenta, "Successfully manipulated flags on [" + str(len(environments)) + "] environments.")

ksPrintLog(Colors.Magenta, "Successfully tweaked platform settings for [" + str(len(environments)) + "] environments.")
ksPrintLog(Colors.Green, "Extra script finished.")
except BaseException as err:
ksPrintLog(Colors.Red, "Error while executing script. Are you on newest platformio core?")
Expand Down
3 changes: 0 additions & 3 deletions src/ksf/comp/ksMqttConfigProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
#pragma once

#include "ksConfigProvider.h"

class WiFiManager;

namespace ksf::comps
{
class ksMqttConnector;
Expand Down
18 changes: 9 additions & 9 deletions src/ksf/ksConstants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ namespace ksf
void initializeFramework()
{
#ifdef ESP32
// TODO: In case of esp32 arduino 3
//esp_task_wdt_config_t twdt_config = {
// .timeout_ms = KSF_WATCHDOG_TIMEOUT_SECS * 1000,
// .idle_core_mask = (1 << CONFIG_SOC_CPU_CORES_NUM) - 1, // Bitmask of all cores
// .trigger_panic = false,
//};
//esp_task_wdt_init(&twdt_config);

#if DARDUINO_3_OR_ABOVE
esp_task_wdt_config_t twdt_config = {
.timeout_ms = KSF_WATCHDOG_TIMEOUT_SECS * 1000,
.idle_core_mask = (1 << CONFIG_SOC_CPU_CORES_NUM) - 1, // Bitmask of all cores
.trigger_panic = false,
};
esp_task_wdt_init(&twdt_config);
#else
/* Setup watchdog. */
esp_task_wdt_init(KSF_WATCHDOG_TIMEOUT_SECS, true);

#endif
/* Initialize filesystem. */
LittleFS.begin(true);
#endif
Expand Down

0 comments on commit c45a7b4

Please sign in to comment.