Files
L'électron rare f55093d6fe
ESP-IDF CI / Host Tests (Unity) (push) Successful in 1m8s
CI / firmware-native (push) Successful in 2m57s
Rust Protection Tests / Cargo test (host) (push) Failing after 3m21s
ESP-IDF CI / ESP-IDF Build (v5.4) (push) Failing after 6m55s
ESP-IDF CI / Memory Budget Gate (push) Has been skipped
qa-cicd-environments / qa-kxkm-s3-build (push) Successful in 8m53s
qa-cicd-environments / qa-sim-host (push) Successful in 2m2s
qa-cicd-environments / qa-kxkm-s3-memory-budget (push) Successful in 11m17s
chore: import KXKM Batterie Parallelator
Context: the project archive (KXKM_Batterie_Parallelator-main) had
no git history locally; a fresh repository is needed to host it on
git.saillant.cc (electron/KXKM_Batterie_Parallelator).

Approach: initialize a new repo on branch main, stage the archive
content, and harden .gitignore before the first commit.

Changes:
- Import the full project tree: firmware/, firmware-idf/,
  firmware-rs/, iosApp/, kxkm-bmu-app/, kxkm-api/, hardware/,
  docs/, specs/, scripts/, models/, tests/
- Keep project dotfiles tracked despite the trailing '.*' ignore
  rule: .github/, .claude/, .superpowers/, .gitattributes,
  .markdownlint.json
- Extend .gitignore: firmware/src/credentials.h (local secrets,
  template kept), kxkm-bmu-app/**/build/ (66 MB compiled iOS
  framework), .remember/ (session data)

Impact: the project can now be maintained on the self-hosted Gitea
forge with a clean, secret-free initial history.
2026-07-04 12:32:28 +02:00

91 lines
2.8 KiB
C++

/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* @file WiFiHandler.cpp
* @brief Implémentation de la classe WiFiHandler pour gérer la connexion WiFi.
* @details Créé par Clément Saillant pour Komplex Kapharnum assisté par IA.
*/
#include "WiFiHandler.h"
#include <KxLogger.h>
// Assurez-vous que `debugLogger` est déclaré et initialisé correctement
extern KxLogger debugLogger;
/**
* @brief Constructeur de la classe WiFiHandler.
* @param ssid Le SSID du réseau WiFi.
* @param password Le mot de passe du réseau WiFi.
*/
WiFiHandler::WiFiHandler(const char *ssid, const char *password)
: ssid(ssid), password(password) {}
/**
* @brief Constructeur de la classe WiFiHandler pour les réseaux sans mot de passe.
* @param ssid Le SSID du réseau WiFi.
*/
WiFiHandler::WiFiHandler(const char *ssid)
: ssid(ssid), password(NULL) {}
/**
* @brief Démarrer la connexion WiFi.
*/
void WiFiHandler::begin() {
WiFi.mode(WIFI_STA);
WiFi.setHostname("BatteryMonitor");
if (password) {
WiFi.begin(ssid, password);
} else {
WiFi.begin(ssid);
}
constexpr int kWifiTimeoutMs = 30000;
int elapsed = 0;
while (WiFi.status() != WL_CONNECTED && elapsed < kWifiTimeoutMs) {
vTaskDelay(1000 / portTICK_PERIOD_MS);
elapsed += 1000;
debugLogger.println(KxLogger::WIFI,"Connecting to WiFi...");
}
if (WiFi.status() != WL_CONNECTED) {
debugLogger.println(KxLogger::WIFI,"WiFi connection timeout after 30s");
return;
}
debugLogger.println(KxLogger::WIFI,"=======================> Connected to WiFi");
debugLogger.println(KxLogger::WIFI,WiFi.localIP().toString());
}
WiFiHandler::WiFiHandler() {}
void WiFiHandler::begin(const char* ssid, const char* password) {
WiFi.begin(ssid, password);
constexpr int kWifiTimeoutMs = 30000;
int elapsed = 0;
while (WiFi.status() != WL_CONNECTED && elapsed < kWifiTimeoutMs) {
delay(1000);
elapsed += 1000;
Serial.println("Connecting to WiFi...");
}
if (WiFi.status() != WL_CONNECTED) {
Serial.println("WiFi connection timeout");
return;
}
Serial.println("Connected to WiFi");
}
bool WiFiHandler::isConnected() {
return WiFi.status() == WL_CONNECTED;
}