diff --git a/Hard/platformio.ini b/Hard/platformio.ini index b62f6a6..2ce577b 100644 --- a/Hard/platformio.ini +++ b/Hard/platformio.ini @@ -13,6 +13,9 @@ platform = espressif32 board = arduino_nano_esp32 framework = arduino monitor_speed = 115200 +upload_port = /dev/ttyACM0 +monitor_port = /dev/ttyACM0 ; Équivalent de "Partition Scheme → Default with OTA" -board_build.partitions = min_spiffs.csv \ No newline at end of file +board_build.partitions = min_spiffs.csv +build_flags = -std=c++17 \ No newline at end of file diff --git a/Hard/src/controller.cpp b/Hard/src/controller.cpp index 14fdf8e..95f4138 100644 --- a/Hard/src/controller.cpp +++ b/Hard/src/controller.cpp @@ -9,17 +9,14 @@ Controller::Controller() { } void Controller::initController() { - for (int i = 0; i < 5; i++) { + for (unsigned short i = 0; i < 5; i++) { // créer le volet unsigned short pinDown = 9 - (2 * i); unsigned short pinUp = 8 - (2 * i); - Shutter shutter{pinUp, pinDown, i}; // i est le nom + shutters[i] = new Shutter(pinUp, pinDown, i); pinMode(i, OUTPUT); - - // stock le volet - shutters[i] = &shutter; } // Permet de correctement initaliser tout les volets @@ -33,12 +30,12 @@ void Controller::openExactePercentSpecificShutter(unsigned short shutter, float else if (percent > 100) percent = 100; - if (shutter < 0 && shutter >= 5) + if (shutter < 0 || shutter >= 5) return; float percentOpen = shutters[shutter]->percentOpen; // si le volet est deja ouvert a son pourcentage, ne rien faire - if (percent = percentOpen) + if (percent == percentOpen) return; float deltaPercent = percentOpen - percent; diff --git a/Hard/src/controller.h b/Hard/src/controller.h index 43d5106..7226ead 100644 --- a/Hard/src/controller.h +++ b/Hard/src/controller.h @@ -1,6 +1,19 @@ #ifndef CONTROLER #define CONTROLER +struct Shutter { + public: + const unsigned short pinUp; + const unsigned short pinDown; + const unsigned short name; + const unsigned short TIMETOOPEN = 10; // en secondes + + float percentOpen = 0.0f; // pourcentage d'ouverture du volet, 0: fermer | 100: ouvert + + // Constructeur + Shutter(unsigned short up, unsigned short down, unsigned short n) : pinUp(up), pinDown(down), name(n) {} +}; + class Controller { public: Shutter* shutters[5]; @@ -15,17 +28,4 @@ class Controller { void manualOpen(); }; -struct Shutter { - public: - const unsigned short pinUp; - const unsigned short pinDown; - const unsigned short name; - const unsigned short TIMETOOPEN = 10; // en secondes - - float percentOpen = 0.0f; // pourcentage d'ouverture du volet, 0: fermer | 100: ouvert - - // Constructeur - Shutter(unsigned short up, unsigned short down, unsigned short n) : pinUp(up), pinDown(down), name(n) {} -}; - #endif \ No newline at end of file diff --git a/Hard/src/main.cpp b/Hard/src/main.cpp index f51d313..2987f62 100644 --- a/Hard/src/main.cpp +++ b/Hard/src/main.cpp @@ -13,15 +13,23 @@ Updater updater; Controller controller; void setup() { - updater.update(); // vérifie les updates - controller.initController(); + Serial.begin(115200); + delay(2000); // Attendez que le moniteur se connecte + Serial.println("\n\n=== DÉMARRAGE ==="); + Serial.println("Serial connecté!"); + + updater.update(); + Serial.println("Updater terminé"); + + // controller.initController(); + // Serial.println("Contrôleur initialisé"); } void loop() { - if (millis() > timeWaitRestart) // redemarrage tout les 6mois - ESP.restart(); - else if (lastTimeCheckUpdate - millis() > timeWaitCheckUpdate) - updater.update(); + // if (millis() > timeWaitRestart) // redemarrage tout les 6mois + // ESP.restart(); + // else if (lastTimeCheckUpdate - millis() > timeWaitCheckUpdate) + // updater.update(); - controller.manualOpen(); + // controller.manualOpen(); } \ No newline at end of file diff --git a/Hard/src/updater.cpp b/Hard/src/updater.cpp index 09dc50b..90ac59a 100644 --- a/Hard/src/updater.cpp +++ b/Hard/src/updater.cpp @@ -2,6 +2,10 @@ #include "updater.h" +const int THISVERSION = 1; +const char* FIRMWAREURL = "http://89.168.57.22:6543/"; +const char* VERSIONURL = "http://89.168.57.22/6543/LastVersion.txt"; + Updater::Updater() { } @@ -9,6 +13,7 @@ bool Updater::checkUpdate() { HTTPClient http; // 1. Vérifie si une nouvelle version est disponible + Serial.println("recherche de version"); http.begin(VERSIONURL); // ton-serveur.com/version.txt"); int httpCode = http.GET(); @@ -24,6 +29,8 @@ bool Updater::checkUpdate() { return false; } + + return false; } void Updater::update() { diff --git a/Hard/src/updater.h b/Hard/src/updater.h index b461a66..df579eb 100644 --- a/Hard/src/updater.h +++ b/Hard/src/updater.h @@ -1,9 +1,9 @@ #ifndef UPDATER #define UPDATER -const int THISVERSION = 1; -const char* FIRMWAREURL = "http://89.168.57.22:6543/"; -const char* VERSIONURL = "http://89.168.57.22/6543/LastVersion.txt"; +extern const int THISVERSION; +extern const char* FIRMWAREURL; +extern const char* VERSIONURL; // Permet la mise a jour a distance class Updater { diff --git a/Hard/src/wifiManager.cpp b/Hard/src/wifiManager.cpp index 32cfcc4..59dfeee 100644 --- a/Hard/src/wifiManager.cpp +++ b/Hard/src/wifiManager.cpp @@ -3,10 +3,15 @@ #include "wifiManager.h" +const char* SSID = "Livebox-51A0"; +const char* PASSWORD = "mGmMjFh5NPL5PNLJRb"; + WifiManager::WifiManager() { - Serial.begin(115200); WiFi.begin(SSID, PASSWORD); - while (WiFi.status() != WL_CONNECTED) delay(500); + while (WiFi.status() != WL_CONNECTED) { + delay(500); + Serial.print('.'); + } Serial.println("WiFi connecté"); } \ No newline at end of file diff --git a/Hard/src/wifiManager.h b/Hard/src/wifiManager.h index 584beba..93400f9 100644 --- a/Hard/src/wifiManager.h +++ b/Hard/src/wifiManager.h @@ -1,14 +1,14 @@ #ifndef WIFIMANAGER #define WIFIMANAGER -const char* SSID = "ton_wifi"; -const char* PASSWORD = "ton_mdp"; +extern const char* SSID; +extern const char* PASSWORD; class WifiManager { public: WifiManager(); - void start(); + // void start(); }; #endif \ No newline at end of file