Req = notecard.newRequest("card.time");

Hi,

For many years I have successfully used the following in my Arduino code

req = notecard.newRequest(“card.time”);

if (req) {

J\* rsp = notecard.requestAndResponse(req);

t_unix_date= JGetNumber(rsp, "time");

 if(debug){

    Serial.print("Time: ");

    Serial.println(t_unix_date);

  }

rtc.setTime(t_unix_date);

notecard.deleteResponse(rsp);

}

But after an Ardunio update, it stopped working. I have replaced JGetNumber with JGetInt, but it still does not work, as below

10:52:11.883 -> [INFO] {"req":"card.time","crc":"0003:1110F247"}

10:52:11.918 -> [INFO] {"req":"card.time"}

10:52:11.918 -> Time: 0

I’m using Arduino IDE 2.3.10 and Norecards v1.5 and a sync has occurred before this request.

Help will be appreciated.

hussat

Hi @hussat,

It looks like your Notecard isn’t returning a time from the card.time request. Can you paste the raw response after issuing that request? Most likely this Notecard has not successfully synced with Notehub, which is required in order to retrieve current date/time at startup.

Also, you may want to update your note-arduino version as 1.5 is getting a little old!

Thanks,
Rob

> {"req":"card.time"}
{
 "minutes": 600,
 "lat": -35.5617675,
 "lon": 148.30733984375,
 "area": "New South Wales",
 "country": "AU",
 "zone": "AEST,Australia/Sydney",
 "time": 1782281514
}
Start making requests below.
(For advanced info, use the 'help' command.)
********************************************
~ Connected to serial
~ Sync Status Monitor enabled
~ DeviceUID dev:867730051808016 (NOTE-NBGL-500) running firmware 11.3.1.17696

Hi @hussat,

It looks like the response from your card.time request is correct. Also you have a rogue backslash in the first line of your code sample above, it should be:

J* rsp = notecard.requestAndResponse(req);

Thanks,
Rob