#include "ESP12F.h"
#include <WidgetRTC.h>


WidgetTerminal terminal(V60);
BlynkTimer timerRTC;
BlynkTimer timerStatus;
WidgetRTC rtc;

/* **************************************************************
  Fonction Perso
 ***************************************************************/
uint8_t uart_send(uint8_t *in, uint8_t nbTr, uint8_t *out) {
  int i;
  
  for (i = 0; i < nbTr; i++) {
    Serial.write(in[i]);
  }
  for (; i < SIZEMES; i++) {
    Serial.write(0xAA);
  }

  int time = 0;
  while (Serial.available() < SIZEMES) {
    time++;
    if (time > 1000000) {
      terminal.print("erreur 1 :");
      terminal.println(in[0]);
      terminal.flush();
      return 1;
    }
  }

  Serial.readBytes(out, SIZEMES);


  if (out[0] & MASKMES != in[0] & MASKMES) {
    terminal.print("erreur 2");
    terminal.flush();
    return 2;
  }

  
  terminal.print("in[0] : ");
  terminal.println(in[0]);
  terminal.flush();

  return 0;
}

uint8_t transmition(uint8_t *in, uint8_t nbTr, uint8_t *out) {
  return uart_send(in, nbTr, out);
}

void SyncRTC(){
  uint8_t nbTr = 8;
  uint8_t out[8];
  uint8_t in[nbTr];
  in[0]=SYNCRTC;
  in[1]=year();
  in[2]=month();
  in[3]=day();
  in[4]=5;
  in[5]=hour();
  in[6]=minute();
  in[7]=second();
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

void Status(){
  uint8_t nbTr = 1;
  uint8_t out[8];
  uint8_t in[nbTr];
  in[0]=STATUS;
  in[1]=
  transmition(in, nbTr, out);
  switch(out[1]){
    case 0:
      //tous est ok
      break;
    case 1:
      Blynk.syncAll();
      SyncRTC();
      break;
  }
}
/* **************************************************************
    Fonction Arduino
 ***************************************************************/

void setup() {
    
  Blynk.begin(auth, ssid, pass, IPAddress(192, 168, 1, 18), 8081);
  timerRTC.setInterval(1000L*600, SyncRTC); // une synchro de la RTC par heure
  timerStatus.setInterval(10000L, Status); // un status toute les 10 sec
  Serial.begin(115200);
}



void loop() {
  Blynk.run();
  timerRTC.run();
  timerStatus.run();

  
 }

 BLYNK_WRITE(V60){
  Status();
}

/* **************************************************************
  Fonction Blynk
 ***************************************************************/
 
BLYNK_WRITE(V6) {
  uint8_t nbTr = 2;
  uint8_t out[8];
  uint8_t in[nbTr];
  in[0]=STOP;
  in[1]=param.asInt();
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

BLYNK_WRITE(V7) {
  uint8_t nbTr = 2;
  uint8_t out[8];
  uint8_t in[nbTr];
  in[0]=ESSAI;
  in[1]=param.asInt();
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}


BLYNK_CONNECTED() {
  rtc.begin();
}

///**********S0**********/

//Max S0
BLYNK_WRITE(V10) {
  uint8_t nbTr = 3;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[0].Max = param.asInt();
  in[0]=WRITETABVAL;
  in[1]=0;
  in[2]=TabSortie[0].Max;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//Pente S0
BLYNK_WRITE(V20){
  uint8_t nbTr = 3;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[0].Pente = param.asInt();
  in[0]=WRITETABVAL;
  in[1]=0+0x80;
  in[2]=TabSortie[0].Pente;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//HeureDem S0
BLYNK_WRITE(V30){
  uint8_t nbTr = 4;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[0].HeureDem = param.asLong() / 60;
  in[0] = WRITETABHEU;
  in[1] = 0;
  in[2] =TabSortie[0].HeureDem /60;
  in[3] =TabSortie[0].HeureDem % 60;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//HeureArret S0
BLYNK_WRITE(V40){
  uint8_t nbTr = 4;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[0].HeureArret = param.asLong() / 60;
  in[0] = WRITETABHEU;
  in[1] = 0+0x80;
  in[2] =TabSortie[0].HeureArret / 60;
  in[3] =TabSortie[0].HeureArret % 60;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//Essai  S0
BLYNK_WRITE(V50) {
  uint8_t nbTr = 4;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[0].Essai = param.asInt();
  in[0] = WRITEVALESS;
  in[1] = 0;
  in[2] = TabSortie[0].Essai;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//**********S1**********/

//Max S1
BLYNK_WRITE(V11) {
  uint8_t nbTr = 3;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[1].Max = param.asInt();
  in[0]=WRITETABVAL;
  in[1]=1;
  in[2]=TabSortie[1].Max;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//Pente S1
BLYNK_WRITE(V21){
  uint8_t nbTr = 3;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[1].Pente = param.asInt();
  in[0]=WRITETABVAL;
  in[1]=1+0x80;
  in[2]=TabSortie[1].Pente;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//HeureDem S1
BLYNK_WRITE(V31){
  uint8_t nbTr = 4;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[1].HeureDem = param.asLong() / 60;
  in[0] = WRITETABHEU;
  in[1] = 1;
  in[2] =TabSortie[1].HeureDem /60;
  in[3] =TabSortie[1].HeureDem % 60;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//HeureArret S1
BLYNK_WRITE(V41){
  uint8_t nbTr = 4;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[1].HeureArret = param.asLong() / 60;
  in[0] = WRITETABHEU;
  in[1] = 1+0x80;
  in[2] =TabSortie[1].HeureArret / 60;
  in[3] =TabSortie[1].HeureArret % 60;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//Essai  S1
BLYNK_WRITE(V51) {
  uint8_t nbTr = 4;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[1].Essai = param.asInt();
  in[0] = WRITEVALESS;
  in[1] = 1;
  in[2] = TabSortie[1].Essai;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//**********S2**********/

//Max S2
BLYNK_WRITE(V12) {
  uint8_t nbTr = 3;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[2].Max = param.asInt();
  in[0]=WRITETABVAL;
  in[1]=2;
  in[2]=TabSortie[2].Max;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//Pente S2
BLYNK_WRITE(V22){
  uint8_t nbTr = 3;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[2].Pente = param.asInt();
  in[0]=WRITETABVAL;
  in[1]=2+0x80;
  in[2]=TabSortie[2].Pente;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//HeureDem S2
BLYNK_WRITE(V32){
  uint8_t nbTr = 4;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[2].HeureDem = param.asLong() / 60;
  in[0] = WRITETABHEU;
  in[1] = 2;
  in[2] =TabSortie[2].HeureDem /60;
  in[3] =TabSortie[2].HeureDem % 60;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//HeureArret S2
BLYNK_WRITE(V42){
  uint8_t nbTr = 4;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[2].HeureArret = param.asLong() / 60;
  in[0] = WRITETABHEU;
  in[1] = 2+0x80;
  in[2] =TabSortie[2].HeureArret / 60;
  in[3] =TabSortie[2].HeureArret % 60;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//Essai  S2
BLYNK_WRITE(V52) {
  uint8_t nbTr = 4;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[2].Essai = param.asInt();
  in[0] = WRITEVALESS;
  in[1] = 2;
  in[2] =TabSortie[2].Essai;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//**********S3**********/

//Max S3
BLYNK_WRITE(V13) {
  uint8_t nbTr = 3;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[3].Max = param.asInt();
  in[0]=WRITETABVAL;
  in[1]=3;
  in[2]=TabSortie[3].Max;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//Pente S3
BLYNK_WRITE(V23){
  uint8_t nbTr = 3;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[3].Pente = param.asInt();
  in[0]=WRITETABVAL;
  in[1]=3+0x80;
  in[2]=TabSortie[3].Pente;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//HeureDem S3
BLYNK_WRITE(V33){
  uint8_t nbTr = 4;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[3].HeureDem = param.asLong() / 60;
  in[0] = WRITETABHEU;
  in[1] = 3;
  in[2] =TabSortie[3].HeureDem /60;
  in[3] =TabSortie[3].HeureDem % 60;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//HeureArret S3
BLYNK_WRITE(V43){
  uint8_t nbTr = 4;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[3].HeureArret = param.asLong() / 60;
  in[0] = WRITETABHEU;
  in[1] = 3+0x80;
  in[2] =TabSortie[3].HeureArret / 60;
  in[3] =TabSortie[3].HeureArret % 60;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//Essai  S3
BLYNK_WRITE(V53) {
  uint8_t nbTr = 4;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[3].Essai = param.asInt();
  in[0] = WRITEVALESS;
  in[1] = 3;
  in[2] =TabSortie[3].Essai;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//**********S4**********/

//Max S4
BLYNK_WRITE(V14) {
  uint8_t nbTr = 3;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[4].Max = param.asInt();
  in[0]=WRITETABVAL;
  in[1]=4;
  in[2]=TabSortie[4].Max;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//Pente S4
BLYNK_WRITE(V24){
  uint8_t nbTr = 3;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[4].Pente = param.asInt();
  in[0]=WRITETABVAL;
  in[1]=4+0x80;
  in[2]=TabSortie[4].Pente;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//HeureDem S4
BLYNK_WRITE(V34){
  uint8_t nbTr = 4;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[4].HeureDem = param.asLong() / 60;
  in[0] = WRITETABHEU;
  in[1] = 4;
  in[2] =TabSortie[4].HeureDem /60;
  in[3] =TabSortie[4].HeureDem % 60;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//HeureArret S4
BLYNK_WRITE(V44){
  uint8_t nbTr = 4;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[4].HeureArret = param.asLong() / 60;
  in[0] = WRITETABHEU;
  in[1] = 4+0x80;
  in[2] =TabSortie[4].HeureArret / 60;
  in[3] =TabSortie[4].HeureArret % 60;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//Essai  S4
BLYNK_WRITE(V54) {
  uint8_t nbTr = 4;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[4].Essai = param.asInt();
  in[0] = WRITEVALESS;
  in[1] = 4;
  in[2] =TabSortie[4].Essai;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//**********S5**********/

//Max S5
BLYNK_WRITE(V15) {
  uint8_t nbTr = 3;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[5].Max = param.asInt();
  in[0]=WRITETABVAL;
  in[1]=5;
  in[2]=TabSortie[5].Max;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//Pente S5
BLYNK_WRITE(V25){
  uint8_t nbTr = 3;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[5].Pente = param.asInt();
  in[0]=WRITETABVAL;
  in[1]=5+0x80;
  in[2]=TabSortie[5].Pente;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//HeureDem S5
BLYNK_WRITE(V35){
  uint8_t nbTr = 4;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[5].HeureDem = param.asLong() / 60;
  in[0] = WRITETABHEU;
  in[1] = 5;
  in[2] =TabSortie[5].HeureDem /60;
  in[3] =TabSortie[5].HeureDem % 60;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//HeureArret S5
BLYNK_WRITE(V45){
  uint8_t nbTr = 4;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[5].HeureArret = param.asLong() / 60;
  in[0] = WRITETABHEU;
  in[1] = 5+0x80;
  in[2] =TabSortie[5].HeureArret / 60;
  in[3] =TabSortie[5].HeureArret % 60;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//Essai  S5
BLYNK_WRITE(V55) {
  uint8_t nbTr = 4;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[5].Essai = param.asInt();
  in[0] = WRITEVALESS;
  in[1] = 5;
  in[2] =TabSortie[5].Essai;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//**********S6**********/

//Max S6
BLYNK_WRITE(V16) {
  uint8_t nbTr = 3;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[6].Max = param.asInt();
  in[0]=WRITETABVAL;
  in[1]=6;
  in[2]=TabSortie[6].Max;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//Pente S6
BLYNK_WRITE(V26){
  uint8_t nbTr = 3;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[6].Pente = param.asInt();
  in[0]=WRITETABVAL;
  in[1]=6+0x80;
  in[2]=TabSortie[6].Pente;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//HeureDem S6
BLYNK_WRITE(V36){
  uint8_t nbTr = 4;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[6].HeureDem = param.asLong() / 60;
  in[0] = WRITETABHEU;
  in[1] = 6;
  in[2] =TabSortie[6].HeureDem /60;
  in[3] =TabSortie[6].HeureDem % 60;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//HeureArret S6
BLYNK_WRITE(V46){
  uint8_t nbTr = 4;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[6].HeureArret = param.asLong() / 60;
  in[0] = WRITETABHEU;
  in[1] = 6+0x80;
  in[2] =TabSortie[6].HeureArret / 60;
  in[3] =TabSortie[6].HeureArret % 60;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//Essai  S6
BLYNK_WRITE(V56) {
  uint8_t nbTr = 4;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[6].Essai = param.asInt();
  in[0] = WRITEVALESS;
  in[1] = 6;
  in[2] =TabSortie[6].Essai;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//**********S7**********/

//Max S7
BLYNK_WRITE(V17) {
  uint8_t nbTr = 3;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[7].Max = param.asInt();
  in[0]=WRITETABVAL;
  in[1]=7;
  in[2]=TabSortie[7].Max;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//Pente S7
BLYNK_WRITE(V27){
  uint8_t nbTr = 3;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[7].Pente = param.asInt();
  in[0]=WRITETABVAL;
  in[1]=7+0x80;
  in[2]=TabSortie[7].Pente;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//HeureDem S7
BLYNK_WRITE(V37){
  uint8_t nbTr = 4;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[7].HeureDem = param.asLong() / 60;
  in[0] = WRITETABHEU;
  in[1] = 7;
  in[2] =TabSortie[7].HeureDem /60;
  in[3] =TabSortie[7].HeureDem % 60;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//HeureArret S7
BLYNK_WRITE(V47){
  uint8_t nbTr = 4;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[7].HeureArret = param.asLong() / 60;
  in[0] = WRITETABHEU;
  in[1] = 7+0x80;
  in[2] =TabSortie[7].HeureArret / 60;
  in[3] =TabSortie[7].HeureArret % 60;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//Essai  S7
BLYNK_WRITE(V57) {
  uint8_t nbTr = 4;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[7].Essai = param.asInt();
  in[0] = WRITEVALESS;
  in[1] = 7;
  in[2] =TabSortie[7].Essai;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//**********S8**********/

//Max S8
BLYNK_WRITE(V18) {
  uint8_t nbTr = 3;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[8].Max = param.asInt();
  in[0]=WRITETABVAL;
  in[1]=8;
  in[2]=TabSortie[8].Max;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//Pente S8
BLYNK_WRITE(V28){
  uint8_t nbTr = 3;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[8].Pente = param.asInt();
  in[0]=WRITETABVAL;
  in[1]=8+0x80;
  in[2]=TabSortie[8].Pente;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//HeureDem S8
BLYNK_WRITE(V38){
  uint8_t nbTr = 4;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[8].HeureDem = param.asLong() / 60;
  in[0] = WRITETABHEU;
  in[1] = 8;
  in[2] =TabSortie[8].HeureDem /60;
  in[3] =TabSortie[8].HeureDem % 60;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//HeureArret S8
BLYNK_WRITE(V48){
  uint8_t nbTr = 4;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[8].HeureArret = param.asLong() / 60;
  in[0] = WRITETABHEU;
  in[1] = 8+0x80;
  in[2] =TabSortie[8].HeureArret / 60;
  in[3] =TabSortie[8].HeureArret % 60;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//Essai  S8
BLYNK_WRITE(V58) {
  uint8_t nbTr = 4;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[8].Essai = param.asInt();
  in[0] = WRITEVALESS;
  in[1] = 8;
  in[2] =TabSortie[8].Essai;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//**********S9**********/

//Max S9
BLYNK_WRITE(V19) {
  uint8_t nbTr = 3;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[9].Max = param.asInt();
  in[0]=WRITETABVAL;
  in[1]=9;
  in[2]=TabSortie[9].Max;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//Pente S9
BLYNK_WRITE(V29){
  uint8_t nbTr = 3;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[9].Pente = param.asInt();
  in[0]=WRITETABVAL;
  in[1]=9+0x80;
  in[2]=TabSortie[9].Pente;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//HeureDem S9
BLYNK_WRITE(V39){
  uint8_t nbTr = 4;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[9].HeureDem = param.asLong() / 60;
  in[0] = WRITETABHEU;
  in[1] = 9;
  in[2] =TabSortie[9].HeureDem /60;
  in[3] =TabSortie[9].HeureDem % 60;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//HeureArret S9
BLYNK_WRITE(V49){
  uint8_t nbTr = 4;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[9].HeureArret = param.asLong() / 60;
  in[0] = WRITETABHEU;
  in[1] = 9+0x80;
  in[2] =TabSortie[9].HeureArret / 60;
  in[3] =TabSortie[9].HeureArret % 60;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}

//Essai  S9
BLYNK_WRITE(V59) {
  uint8_t nbTr = 4;
  uint8_t out[8];
  uint8_t in[nbTr];
  TabSortie[9].Essai = param.asInt();
  in[0] = WRITEVALESS;
  in[1] = 9;
  in[2] =TabSortie[9].Essai;
  if (transmition(in, nbTr, out) == 0) {
    //TODO erreur transmit
  }
}
