[Solved] Udp.write() and tcp.write() 20 second hang

it seems i finally made it to work, after researching i found similar problems with TCPClient.
Long story short the spark cloud need to be disabled as is interfering somehow.

So in here explain how to do: https://community.spark.io/t/new-feature-control-your-connection/6282/5

in particular:

[QUOTE]Connect to Wi-Fi but not the Cloud: do SYSTEM_MODE(MANUAL) and call WiFi.connect() but not Spark.connect()[/QUOTE]

This is how my setup() looks for achieving this:

void setup() {
    Serial.begin(115200);
    
    // This part helps me flash new code next time, if you are not connected is not possible!
    Spark.connect();//connect to the spark cloud
    
    //we stay connected to the cloud 
    while (!Serial.available()){
          Spark.process();
          delay(500);
    }
    //**************************************************************************************
    
    
      Spark.disconnect();//so we dont have the problem tranfering files.
      //WiFi.on();
      WiFi.connect();
      
      while (!WiFi.ready()) SPARK_WLAN_Loop();
      
      LineBreaker[0]='\015';
      LineBreaker[1]='\012';
      LineBreaker[2]='\0';

  while (!Serial.available()) //Spark.process() it seems without the spark has some problem
  
  //just to consume whatever is passed in the begin to start
  while (Serial.available()) Serial.read();

    InitSD();


 connectToMyServer(FTP_ADDRESS);
}
2 Likes