Skip to content

Commit

Permalink
correction Sonarqb 2 nettoyage code
Browse files Browse the repository at this point in the history
  • Loading branch information
xlyric committed Apr 29, 2024
1 parent ca9cb89 commit dda4cab
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 45 deletions.
3 changes: 2 additions & 1 deletion src/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 2 additions & 13 deletions src/functions/dallasFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -107,16 +97,15 @@ 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
delay(187); /// attente de 187ms ( temps de réponse de la sonde )
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++;
Expand Down
4 changes: 2 additions & 2 deletions src/functions/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extern Configmodule configmodule;
extern Config config;

void call_display(){
//serial_println(F("lcd task"));

#ifdef DEVKIT1
display.clear();
#endif
Expand All @@ -37,7 +37,7 @@ void call_display(){

#if WIFI_ACTIVE == true
if (gDisplayValues.currentState == UP) {
//drawTime();

drawIP();
} else {
drawtext10(64, 0, "no Wifi");
Expand Down
2 changes: 1 addition & 1 deletion src/functions/drawFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void drawIP(){
}
/*
/**
/*
* The screen that is displayed when the ESP has just booted
* and is connecting to WiFi & AWS.
*/
Expand Down
1 change: 0 additions & 1 deletion src/functions/enphaseFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion src/functions/spiffsFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
29 changes: 3 additions & 26 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);


}

Expand All @@ -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
Expand Down Expand Up @@ -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
}
}
}
Expand Down Expand Up @@ -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();
}
}
}*/

0 comments on commit dda4cab

Please sign in to comment.