From dda4cab888ee7803b16581aef954bb0ac77e8689 Mon Sep 17 00:00:00 2001 From: xlyric Date: Mon, 29 Apr 2024 18:40:33 +0200 Subject: [PATCH] correction Sonarqb 2 nettoyage code --- src/config/config.h | 3 ++- src/functions/dallasFunction.h | 15 ++------------- src/functions/display.h | 4 ++-- src/functions/drawFunctions.h | 2 +- src/functions/enphaseFunction.h | 1 - src/functions/spiffsFunctions.h | 2 +- src/main.cpp | 29 +++-------------------------- 7 files changed, 11 insertions(+), 45 deletions(-) diff --git a/src/config/config.h b/src/config/config.h index c7cd3a2..87e16ea 100644 --- a/src/config/config.h +++ b/src/config/config.h @@ -165,7 +165,8 @@ bool discovery_temp = false; #endif #define RELEASE "Version 20240501" -#define FS_RELEASE "20240501" +constexpr const int FS_RELEASE= 20240501 ; + #ifdef LIGHT_FIRMWARE #define VERSION "Light " RELEASE #else diff --git a/src/functions/dallasFunction.h b/src/functions/dallasFunction.h index 095ca3f..050f684 100644 --- a/src/functions/dallasFunction.h +++ b/src/functions/dallasFunction.h @@ -15,16 +15,6 @@ OneWire ds(ONE_WIRE_BUS); DallasTemperature sensors(&ds); DeviceAddress insideThermometer; - /* - byte present = 0; - byte type_s; - byte data[12]; - byte addr[8]; - float celsius = 0.00 ; - - int refresh = 30; - int refreshcount = 0; -*/ byte i; bool dallaspresent () { @@ -107,8 +97,7 @@ float CheckTemperature(String label, byte deviceAddress[12]){ delay(400); // conseillé 375 ms pour une 18b20 float tempC = sensors.getTempC(deviceAddress); - //Serial.print(label); - //logging.init += loguptime(); + if ( (tempC == -127.0) || (tempC == -255.0) ) { //// cas d'une sonde trop longue à préparer les valeurs @@ -116,7 +105,7 @@ float CheckTemperature(String label, byte deviceAddress[12]){ tempC = sensors.getTempC(deviceAddress); if ( (tempC == -127.0) || (tempC == -255.0) ) { Serial.print("Error getting temperature"); - //logging.Set_log_init("Dallas on error\r\n"); + /// si erreur on reprends l'ancienne valeur tempC = gDisplayValues.temperature; dallas_error++; diff --git a/src/functions/display.h b/src/functions/display.h index b420a9d..ed2f27c 100644 --- a/src/functions/display.h +++ b/src/functions/display.h @@ -27,7 +27,7 @@ extern Configmodule configmodule; extern Config config; void call_display(){ - //serial_println(F("lcd task")); + #ifdef DEVKIT1 display.clear(); #endif @@ -37,7 +37,7 @@ void call_display(){ #if WIFI_ACTIVE == true if (gDisplayValues.currentState == UP) { - //drawTime(); + drawIP(); } else { drawtext10(64, 0, "no Wifi"); diff --git a/src/functions/drawFunctions.h b/src/functions/drawFunctions.h index 292c901..7aec2a4 100644 --- a/src/functions/drawFunctions.h +++ b/src/functions/drawFunctions.h @@ -67,7 +67,7 @@ void drawIP(){ } /* -/** +/* * The screen that is displayed when the ESP has just booted * and is connecting to WiFi & AWS. */ diff --git a/src/functions/enphaseFunction.h b/src/functions/enphaseFunction.h index 87ad54c..c58f042 100644 --- a/src/functions/enphaseFunction.h +++ b/src/functions/enphaseFunction.h @@ -358,7 +358,6 @@ bool Enphase_get_7_JWT(void) { Serial.println("Error code : " + String(httpCode)); } } - //https.end(); nbErreurCtrlTocken++; if ( nbErreurCtrlTocken == 10 ) { Serial.println("Trop d'erreur : redemmarrage"); diff --git a/src/functions/spiffsFunctions.h b/src/functions/spiffsFunctions.h index 1a38de9..2abcc22 100644 --- a/src/functions/spiffsFunctions.h +++ b/src/functions/spiffsFunctions.h @@ -325,7 +325,7 @@ bool test_fs_version() { // comparaison entre le contenu du fichier et la version du code FS_RELEASE String version = file.readStringUntil('\n'); file.close(); - if (version.toInt() < String(FS_RELEASE).toInt() ) { + if (version.toInt() < FS_RELEASE ) { logging.Set_log_init("FS version is not the same as code version please update FS\r\n"); return false; diff --git a/src/main.cpp b/src/main.cpp index fc31dda..5d8cb30 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -590,8 +590,7 @@ snprintf(raison, bufferSize, "restart : %s", logging.loguptime()); #ifndef LIGHT_FIRMWARE client.publish("memory/Routeur", raison, true); #endif -//WebSerial.begin(&server); -//WebSerial.msgCallback(recvMsg); + } @@ -618,16 +617,12 @@ void loop() ESP.restart(); } -/// vérification du buffer log - // if (logging.start.length() > LOG_MAX_STRING_LENGTH - 5 ) { - // logging.start = ""; - //} + /// vérification de la tailld du buffer log_init ( 600 caractères max ) il est créé à 650 caractères ( enums.h ) /// pour éviter les buffer overflow et fuite mémoire. logging.clean_log_init(); // affichage en mode serial de la taille de la chaine de caractère logging.log_init -//Serial.print( "log_init : " ); -//Serial.println( strlen(logging.log_init) ); + // vérification de la connexion wifi @@ -729,7 +724,6 @@ if (config.dimmerlocal) { device_dimmer.send(String(instant_power * config.charge/100)); } #endif - //offset_heure_ete(); // on corrige l'heure d'été si besoin } } } @@ -867,20 +861,3 @@ void IRAM_ATTR function_next_screen(){ if (gDisplayValues.option > 2 ) { gDisplayValues.option = 1 ;}; } -/* -gDisplayValues.screenstate == HIGH ){ // if right button is pressed or HTTP call - if (digitalRead(TFT_PIN)==HIGH) { // and the status flag is LOW - gDisplayValues.screenstate = LOW ; - - digitalWrite(TFT_PIN,LOW); // and turn Off the OLED - } // - else { // otherwise... - Serial.println("button left/bottom pressed"); - gDisplayValues.screenstate = LOW ; - - digitalWrite(TFT_PIN,HIGH); // and turn On the OLED - if (config.ScreenTime !=0 ) { - timer = millis(); - } - } - }*/ \ No newline at end of file