Ping not working on develop branch?

I was trying out the develop branch but I don’t seem to be able to get the ping working… Can someone validate that this is an issue? I used this as example code:

/* Includes ------------------------------------------------------------------*/
#include "application.h"

SYSTEM_MODE(SEMI_AUTOMATIC);

uint8_t sparkApi[] = {62, 116, 130, 8};
IPAddress sparkApiIP = sparkApi;

/* This function is called once at start up ----------------------------------*/
void setup()
{
    // Initiate serial communication
    Serial.begin(9600);

    while(!Serial.available())  // Wait here until the user presses ENTER
       Spark.process();        // in the Serial Terminal. Call the BG Tasks

    WiFi.on();
    WiFi.clearCredentials();
    WiFi.setCredentials("SSID", "PW");

    if (WiFi.hasCredentials()) {
        Serial.println("Has credentials go into connecting mode...");

        // Check for proper internet connection
        WiFi.connect();

        Serial.println("Connecting...");

        // Keep waiting untill ip is assigned
        while (WiFi.connecting() == true) {
            Serial.println("Connecting...");
        }

        while (!WiFi.ready());

        // Connect!
        Spark.connect();
    }
}

/* This function loops forever --------------------------------------------*/
void loop()
{
    if (Spark.connected()) {
        Serial.println("Connected...");
        Serial.print("Pingcount: ");
        Serial.println(WiFi.ping(sparkApiIP, 2));
    }
    delay(100);
}

Just curious did Serial.println("Connecting..."); print?

I remember there’s some weirdness going on with WiFi.clearCredentials(); followed by WiFi.setCredentials("SSID", "PW"); not returning correctly.

yes… Core connected as normal and printed out Connecting… an after that connected… Just always return 0 on the count of pings…

Core? develop branch is not fully tested against the Core so it might not be working :wink:

Should I be using feature-hal then for core?

@geert and @kennethlimcp, if I recall, ping is weird on the Core due to the CC3000. Doing a ping OUT of the Core first seems to set something in the CC3000 which will subsequently start responding to external pings. @kennethlimcp, can you confirm?

I would recommend V0.3.4 in the release that corresponds to what you are using on the Web IDE for now

There might be but we need to test further :wink:

So even on the V0.3.4 branch this is gonna be an issue @peekay123?

Quick way to find out would be to use the Web IDE and compile the code to test :wink:

@geert, yes the issue is still there since it is a CC3000 problem. Try the ping out trick to see if it works.

HI @geert

Can you try an experiment for me? Can you try reversing the order of bytes in the uint8_t byte array?

uint8_t sparkApi[] = {8, 130, 116, 62};

I think some code was removed when ping was ported to the HAL for the Core.

@kennethlimcp yes I know but the thing is I’ve been using the ping on the feature/hal branch without really experiencing issues until yesterday when we did a longer test with more cores. Also on the V0.3.4 branch it wasn’t an issue… I just was wondering what @peekay123 ment with “Ping is weid on the core”… If he ment that sometimes it does work and sometimes it doesn’t then I’m not gonna use it in my firmware of course and if so, or the weirdness was also on the V0.3.4 branch because like I said I had experienced issues before until we did a test with more cores…

I would do a CC3000 patch if things were working and it suddenly did not :wink:

2 Likes

Hi @geert

The “weird” things about ping on the Core that I know of are:

  • It does not always work to ping another host on the first try. I believe this to be a TI CC3000 ARP issue. The second try always works in my experience.

  • The TI CC3000 does not always answer ping’s autonomously. This one is strange in that if the Core has started the Cloud connected, pings will not be answered, but if it has not started it, they will.

  • Pinging a remote host from a Core seems to clear up certain connection problems for UDP connections when the Cloud is not used. This again seems to be ARP problems inside the TI CC3000.

3 Likes

This makes @kennethlimcp advice to repatch the TI CC3000 an especially good idea!

1 Like

Unfortunately the cores are built in a casing and it’s rather hard to open up all the prototypes and patch the CC3000 every time the pinging feature stops working on the CC3000… So I’m just gonna figure out another way to do this. Maybe I can just try opening a tcp connection first if that succeeds I can safely call Spark.connect(). Thanks for the help guys!