TCPClient broken? [SOLVED]

My cores connect to the cloud and can be flashed over the cloud but simple Connection with TCPClient Fails. I cannot connect either to a local Server or a Google one.
They are the black cores.
It seems similar to


but I do not have white cores to check.
The web IDE says, it compiles with v0.2.3.
Any new ideas on this Problem ?

Thanks Michael

Hi @baatsm

White and black cores have identical hardware. The only difference is that the more recently manufactured black cores come from the factory with more recent initial firmware and TI WiFi chip CC3000 firmware revision.

Which TCPClient code are you trying to get working? Can you post your exact code?

Lots of times folks have forgotten that not reading the data out of the receive side of a connection will make the core memory overflow eventually and cause a fault (flashing red LED SOS code).

Some web code seems to need a delay(20); after the final newline is sent for a HTTP GET request for reasons that are not yet understood. This issue has been captured over on github for the team to debug in the future.

it cannot even ping the local router, but it is connected to the cloud.

Thanks
Michael

sample code:

IPAddress   broker      = { 192,168,101,1 };
byte once = 0;
TCPClient tcp_client;

void setup() {
    Serial.begin(57600);
    while(!Serial.available());
    Serial.print("test tcp 0.001\n\r");
}

void loop() {

   if( !once )
   {
        once = 1;
        
        IPAddress localAddr = Network.localIP();
        Serial.print(localAddr);
        Serial.print(" on ");
        Serial.println(Network.SSID());
        Serial.println(Network.subnetMask());
        Serial.println(Network.gatewayIP());
        Serial.print("isWanReady = ");
        Serial.println(WIFI_ON == WiFi.status());
        
        Serial.print("Pinging 5 times: ");
        Serial.println(broker);
        Serial.println(Network.ping(broker));        
   
        Serial.print("connecting to ");
        Serial.println(broker);
    
        if( tcp_client.connect(broker, 80))
        {
            Serial.println("connected to broker ");
        }
        else
        {
            Serial.println("failure: TCP ");
        }
        if( tcp_client.connect("www.google.de", 80))
        {
            Serial.println("connected to www.google.de ");
        }
        else
        {
            Serial.println("failure: TCP ");
        }    
   }
}

I don’t think you have the right IP address here. The IPAddress class has assignment methods for both uint8_t and uint32_t and the {192,168,101,1} type could be int instead of uint8_t.

Try this and see if it helps:

IPAddress   broker(192,168,101,1);

I’m sorry. But this didn’t change anything.
Do you have a working ping example ?

Thank You very much.

Your example should work for ping. Something seems to wrong with your router or network setup. Please note that some hosts are not ping’able (cores after the latest TI patch, AWS hosts, some routers).

What kind of output do you get from your program on the Serial debug port?

all other Computers on my net can do the ping (Routers ip and www.google.de ) and get a Response. I even tried with two different wlan-routers.

Thanks

Here’s the Output from the USB-Serial:

test tcp 0.001
192.168.101.34 on xxxxx (ssid)
255.255.255.0 (subnet mask)
192.168.101.1 (Gateway/router)
isWanReady = 1
Pinging 5 times: 192.168.101.1
0
connecting to 192.168.101.1
failure: TCP
failure: TCP

One more thing to try–there was a change introduced recently make a long delay in setup() a problem. Try this:

   while(!Serial.available()) { SPARK_WLAN_Loop() };

Ahhh, this did the trick. Working as expected now. Now I can go on to my next Goal, connecting to an mqtt-broker.
Thank You very much.

Michael

1 Like

Glad to hear it! There are several other folks that have done MQTT broker related project–just search the forum here.