Problems with webserver library

Hi @BKO,

There is a lot of chatter going on about Watchdog feature within the Spark Core firmware. Is there a watchdog example that i can use?,

Hi @prodders

There already is a watchdog timer that is used by the core firmware so I am not sure you need one too.

Maybe you can explain what you are trying to do and we can figure it out together?

Hi @Bko,

I’ve got this code(below) working, it hangs the core in the loop(), sometimes after a TCP call sometimes when there is no tcp call at all. I am able to put the cloud connect mode via a TCP call that works ok and the TCP call’s are no big deal in terms of data traffic.

void setup()
{

    pinMode(led0, OUTPUT);
    
    webserver.setDefaultCommand(&helloCmd);
    
    webserver.addCommand("index.html", &helloCmd);
    
    webserver.begin();

}


void loop()
{

  if (Spark.connected()) 
  {
    Spark.process();
  }
  else
  {
        if(l_timer>2000) 
        {
            l_timer =0;
            if(l_led0_status ==0)
            {
                digitalWrite(led0, HIGH); 
                l_led0_status=1;
            }
            else
            {
                digitalWrite(led0, LOW); 
                l_led0_status=0;
            }    
            delay(100);
        }
        else
        {
            char buff[128];
            int len = 128;
            
            /* process incoming connections one at a time forever */
            webserver.processConnection(buff, &len);
        }
     }
     l_timer = l_timer + 1;
}

Hi @bko,

Forgot to mention, this is at the top of setup()
SYSTEM_MODE(MANUAL);

The core is still connected to the WiFI after the ‘hang’ and i can also ‘ping’ it . My router is instructed to give the spark core a static ip address, and the wifi is just couple of meters away, and there are no other wifi clients on it.

Hi @prodders

I don’t see anything big that is wrong here (BTW, I reformatted your code-see the forum trick thread for how to do that next time). I don’t think you need the processConnection() call in the else, you could just do that all the time, for instance.

Two suggestions:

  • Update your core with deep update. Generally this removes the ability to answer ping requests but improves stability greatly!

  • Add some Serial.print() debug statements to your code to see where it is really dying.

We can also try to get @mdma involved since he ported the library. There are many other people using the webserver library. I have tried it with good results out but don’t have anything running all the time that uses it yet.

Thanks @bko,

I will do the deep update, see what happens. I did find an article about an external watchdog based on a IC 4060 counter, which i 've got to implement eventually i guess, this is due to the points the article so nicely put forward:
IC 4060 external watchdog implementation

HI @prodders

I moved this to its own topic to keep the forum neatened up.

Hi @bko,

Done the ‘deep update’ on the core and it’s been running for up to 15 hours now without a wifi drop out. Great !, I thought i already had a ‘deep update’ on the core because of it’s black print-board color (pre installed). The Spark core is is a very nice product and we are going to implement it in our ‘Point Of Sale’ product services as a tiny-proxy and printer server.

Hi @prodders

Glad to hear it is working better for you!

The change from white to black silkscreen was before the patch to the TI part, so you can’t tell just by looking. The web IDE has the status since cores connected to the cloud report their current revision.

External watchdogs are useful, but I am hoping the core will stable enough for you without that kind of extreme measure!

Hi @bko,

Is there a way to ping spark core itself, or any other way for a spark core to know it is on the local network and listening with the webserver?

hi @prodders

I am not sure which way you mean:

  1. For another host on the same network to ask the Spark core “are you there?”
  2. For the Spark core to ask “am I online now?”

Hi @bko.

for the same Spark Core to check itself “am i online”, well, to be precise, if it is locally online(off the internet),
I was thinking sort of a, loop-back, by using TCP client (webserver is running already on the same Spark Core).