Can someone please explain to me why this simple basic TCPClient code returns -1, is the spark core even capable of making TCPClient / Server connections without being attached at the umbilical to a PC via serial ports, because nothing I try no matter how basic seems to work. URL doesn’t work, IP doesnt work nothing about TCPClient seems to work. I have managed to get it working over serial but thats not what I want.
Actually if it did work with Serial connected, I’d argue your topic title does not actually reflect your experience (before @Dave edited the topic title )
Have you tried a short delay before client.connect() and between this and client.connected()?
This is (in my experience and opinion) a bug. @ScuffR, there should not be any need to have a delay, but yes that should fix it. I have had two topics with conversation about this in the forum. delay(10000) before client.connect() should fix it.
The reason why Serial works is because of the delay of the Spark waiting for you to connect the Serial port.
Ok, I have sucessfully got it work how I expect it to, but it still requires a Serial.begin(9600) despite not being attached via serial and it also requires SPARK_WLAN_Loop(); being called. I tried adding delays but just couldn’t get it to work, unfortunately the api call times out for the first 30 seconds of the core going live then works as normal.
No idea why you seem to need Serial.begin() for client.connect() to work.
There is (I can see) nothing in the implementation of either class that would suggest any dependencies between them.
What kind of delay time have you tested?
Could you try something like
void setup()
{
unsigned long ms = millis();
Spark.variable("update", &update, INT);
while(millis() - ms < 5000) // play a bit with this number
SPARK_WLAN_Loop();
// now try connecting and the rest of setup
...
}