RÉSOLUS ESP envoi, message push, Mail, et client Profitez en.

Bonjour,

J'ai réalisé un système d'alarme composé de 2 nano un lecteur carte sd une RTC d'un esp et d'un ecran Nexion.

La partie du code ci-bas est la prog de l'esp.
Une appli crée avec APP Inventor sous Android me permet de verrouiller et déverrouiller le systèm et aussi de voir l’état des différents détecteurs.
Après que le message Push et le Mail soit envoyé l'ESP ne communique plus !

Y aurait'il un conflit ?
Ou alors un server.stop qui manque.

Ce programme n'est pas de mon cru c'est un ensemble récolter ici et là que j'ai rassemblé et dont je ne métrite pas les astuces.

Merci a ceux qui peuvent me venir en aide.

Si besoin pour d'autre je peux ajouter à la demande le Gsender.cpp et Gsender.h

#include <ESP8266WiFi.h>
#include "Gsender.h"
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>




const char* ssid = "votre ssid";                           // WIFI network name
const char* password = "votre password";                       // WIFI network password


String Mes1 = "Alarme Intrusion EN COURS envoie via Alarme ESP8266";  
String Mes2 = "Alarme Intrusion VERROUILLER envoie via Alarme ESP8266"; 
String Mes3 = "Alarme Intrusion DEVERROUILLER envoie via Alarme ESP8266"; 
String Mes4 = "Alarme Intrusion TEST envoie via Alarme ESP8266";
String serialCommand1;
char serialLetter1;


// pour PUSH
const char* host = "api.pushbullet.com";
const int httpsPort = 443;
const char* PushBulletAPIKEY = "votre clef "; //get it from your pushbullet account
const char* fingerprint = "votre finger print"; //got it using https://www.grc.com/fingerprints.htm



IPAddress ip(192, 168, 0, 210);  
IPAddress gateway(192, 168, 0, 1);  
IPAddress subnet(255, 255, 255, 0);
ESP8266WebServer server(8888); // on instancie un serveur écoutant sur le port 8888


void setup(void)
{
WiFi.config(ip, gateway, subnet);
WiFi.begin(ssid, password);
Serial.begin(9600);
delay(1000);


 server.on("/", [](){
    // on recupere le parametre msg dans l'url
    String text=server.arg("msg");
    
    
      if (text == "led"){
       Serial.print ("!led*");
       text = "";
      }
      if (text == "sir"){
       Serial.print ("!sir*");
       text = "";
      }
      if (text == "state"){
       Serial.print ("!state*");
       text = "";
      } 
       text = "";
  });


  server.begin();


}



 


void loop(void){


  if (WiFi.status() != WL_CONNECTED)
    {
      WiFi.begin(ssid, password);
        {
          delay(5000);
          if (WiFi.status() != WL_CONNECTED)
            {
              delay(5000);
              WiFi.begin(ssid, password);
            }
        }    
    }
  
  server.handleClient();
  


   if ( Serial.available() > 0 ) {   // Lecture des commande venant Du Master arduino
    serialLetter1 = Serial.read();
    if (serialLetter1 != '\n' ) {
      serialCommand1 += serialLetter1;
      
  }

  if (serialCommand1.startsWith("*") || serialCommand1.startsWith("L") ) {

 
      if (serialCommand1 == "*1"){   // Intrusion en cours
            server.stop();
            Mail(Mes1);  
            sendNotification(Mes1); 
            serialCommand1 ="";
            server.begin();
            }
      if (serialCommand1 == "*2"){// Verrouiller
            server.stop();
            Mail(Mes2); 
            sendNotification(Mes2);
            serialCommand1 ="";
            server.begin();
            }
      if (serialCommand1 == "*3"){ // Deverrouiller
            server.stop();
            Mail(Mes3); 
            sendNotification(Mes3);
            serialCommand1 ="";
            server.begin();
            }
      if (serialCommand1 == "*4"){   // Test
             server.stop();
             Mail(Mes4);
             sendNotification(Mes4);
             serialCommand1 ="";
             server.begin();
            }
          if (serialCommand1.startsWith("L") && serialCommand1.endsWith("!")){
                 server.send(200, "text/plain",  serialCommand1);
                 serialCommand1 ="";
          }
   }
   else {serialCommand1 = "";}
      
  }

}
void sendNotification(String message){
 
  WiFiClientSecure client;
//  Serial.print("connecting to ");
//  Serial.println(host);
  if (!client.connect(host, httpsPort)) {
  //  Serial.println("connection failed");
    return;
  }

  if (client.verify(fingerprint, host)) {
  //  Serial.println("certificate matches");
  } else {
   // Serial.println("certificate doesn't match");
  }
  String url = "/v2/pushes";

String messagebody = "{\"type\": \"note\", \"title\": \"ESP8266\", \"body\": \""  + message + ("\"") +("}")+ ("\r\n");
 // Serial.println (messagebody);
 // Serial.print("requesting URL: ");
 // Serial.println(url);

  client.print(String("POST ") + url + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" +
               "Authorization: Bearer " + PushBulletAPIKEY + "\r\n" +
               "Content-Type: application/json\r\n" +
               "Content-Length: " +
               String(messagebody.length()) + "\r\n\r\n");
  client.print(messagebody);



//  Serial.println("request sent");

  //print the response

  while (client.available() == 0);

  while (client.available()) {
    String line = client.readStringUntil('\n');
 //   Serial.println(line);
  }
  
}



void Mail(String message){
 
    Gsender *gsender = Gsender::Instance();    // Getting pointer to class instance
    String subject = "ESP ALARME SUJET";
    String texte  = message;
    if(gsender->Subject(subject)->Send("votre mail", texte)) {
    //    Serial.println("Message send.");
    } else {
    //    Serial.print("Error sending message: ");
    //    Serial.println(gsender->getError());
    }
}

Bon je répond a moi même, dans ce code il n'y a pas de problèmes, profité donc car il reprend l'envoie vers gmail et pushbulett.
Après avoir pose divers renifler j'ai trouve que c'est dans la prog du nano qui reçois les info de l'esp que ce trouve mon bug. Y a plus cas ....