Skip to content

Commit

Permalink
wip: config.json mounting
Browse files Browse the repository at this point in the history
  • Loading branch information
Friedjof committed Mar 14, 2024
1 parent d74525c commit 4fdae98
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
7 changes: 4 additions & 3 deletions lib/ConfigManager/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ConfigManager::ConfigManager(const char* filename) {

#if defined(ESP32S3)
// Start micro sd card
if(!SD.begin(21)){
if(!SD.begin()){
Serial.println("Card Mount Failed");
return;
}
Expand All @@ -33,9 +33,10 @@ ConfigManager::ConfigManager(const char* filename) {
ConfigManager::ConfigManager() {
this->filename = DEFAULT_CONFIG_FILE;

#if defined(ESP32S3)
#if defined(ESP32S3) && !defined(__INIT_SD_CARD__)
#define __INIT_SD_CARD__
// Start micro sd card
if(!SD.begin(21)){
if(!SD.begin()){
Serial.println("Card Mount Failed");
return;
}
Expand Down
1 change: 1 addition & 0 deletions lib/ConfigManager/ConfigManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define MAX_WIFI_PASSWORD_LENGTH 64 // maximum length of wifi password
#define MAX_FILENAME_LENGTH 32 // maximum length of filename
#define JSON_BUFFER_SIZE 4096 // size of json buffer

#define DEFAULT_CONFIG_FILE "/config.json" // default config file

#include <Arduino.h>
Expand Down
22 changes: 20 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
#include <ConfigManager.h>
#include <AlertManager.h>

#define CONFIG_FILE "/config.json"

#if defined(ESP32S3)
#define CONFIG_FILE "/sd/config.json"

#define INDEX_FILE "/sd/index.html"
#define CSS_FILE "/sd/style.css"
#define JS_FILE "/sd/script.js"
#else
#define CONFIG_FILE "/config.json"

#define INDEX_FILE "/index.html"
#define CSS_FILE "/style.css"
#define JS_FILE "/script.js"
Expand Down Expand Up @@ -79,6 +81,22 @@ void setup() {

Serial.println("Starte Hühner-Futterautomat");

#if defined(ESP32S3) && !defined(__INIT_SD_CARD__)
#define __INIT_SD_CARD__
// Start micro sd card
if(!SD.begin()){
Serial.println("Card Mount Failed");
return;
}

uint8_t cardType = SD.cardType();

if(cardType == CARD_NONE){
Serial.println("No SD card attached");
return;
}
#endif

// Setup of the alert manager
alertManager.setup();

Expand Down

0 comments on commit 4fdae98

Please sign in to comment.