I'm working on a project with the PIC-IoT WG wifi development board. I'm trying to modify the demo code to be able to use it on my own servers. The demo uses code like this in several places:
#include <time.h>
static void connectMQTT()
{
uint32_t currentTime = time(NULL);
if (currentTime > 0)
{
updateJWT(currentTime + UNIX_OFFSET);
MQTT_CLIENT_connect();
}
debug_print("CLOUD: MQTT Connect");
sendSubscribe = true;
}
and every time I turn it on, for 15-20 minutes it tries connecting to the server, but these parts of the code don't run, as time(NULL)
seems to return 0.
As far as I understand, in case of PIC microcontrollers time(NULL) should return the number of instruction cycles.
Why does it return 0? Why does it stop returning 0?