src_legacy/2017/pixelgateway.cpp
// wait for data and handle incomming data
wait for data and handle incomming data
wait for data and handle incomming data
void protocoll_receive_data(){
  if (client.available()){
    char c = client.read();
    if (c== 255) {
      aliveTickCnt++;
      if (logLevel != MUTE && !loadingImgData && (aliveTickCnt % aliveTickModulo) == 0) {
        Serial.print("*");
        aliveTickCnt = 0;
      }
      protocoll_clean_cmd();
      resetTimeout();
    }
    else if (cmdIndex > 5){
      Serial.println("Protocol Error. More than 6 bytes transmitted.");
    }
    else {
      cmd[cmdIndex++]=(unsigned char)c;
    }
  }
  else if (reachedTimeout()){
      client_disconnect();
      nextPoiState = POI_CLIENT_CONNECTING;
  }
  else if (!client.connected()){
    client_disconnect(); 
    nextPoiState = POI_CLIENT_CONNECTING;
  }
}
void protocoll_receive_data ( ) { if ( client . available ( ) ) { char c = client . read ( ) ; if ( c == 255 ) { aliveTickCnt ++ ; if ( logLevel != MUTE && ! loadingImgData && ( aliveTickCnt % aliveTickModulo ) == 0 ) { Serial . print ( " " ) ; aliveTickCnt = 0 ; } protocoll_clean_cmd ( ) ; resetTimeout ( ) ; } else if ( cmdIndex > 5 ) { Serial . println ( " " ) ; } else { cmd [ cmdIndex ++ ] = ( unsigned char ) c ; } } else if ( reachedTimeout ( ) ) { client_disconnect ( ) ; nextPoiState = POI_CLIENT_CONNECTING ; } else if ( ! client . connected ( ) ) { client_disconnect ( ) ; nextPoiState = POI_CLIENT_CONNECTING ; } }
wait for data and handle incomming data
wait for data and handle incomming data
// data available //printf("READ: %d\n", c); // start byte detected // command // no data - disconnect after timeout // no longer connected // required?