My question is about getting a timestamp from a request with arduino. I added this code to “Example1_NotecardBasics.ino”:
JTIME ncTime = 0;
rsp = notecard.requestAndResponse(notecard.newRequest("card.time"));
if (rsp != NULL) {
ncTime = JGetNumber(rsp, "time");
notecard.deleteResponse(rsp);
}
Serial.print("time: ");
Serial.println(ncTime);
and I’m getting this results (loop of 15 seconds):
{"req":"card.time"}
{"minutes":-,"lat":-,"lon":-,"area":"-","country":"-","zone":"-","time":1614435657}
time: 1614435584
{"req":"card.time"}
{"minutes":-,"lat":-,"lon":-,"area":"-","country":"-","zone":"-","time":1614435673}
time: 1614435584
{"req":"card.time"}
{"minutes":-,"lat":-,"lon":-,"area":"-","country":"-","zone":"-","time":1614435689}
time: 1614435712
{"req":"card.time"}
{"minutes":-,"lat":-,"lon":-,"area":"-","country":"-","zone":"-","time":1614435705}
time: 1614435712
The result is truncated with a resolution of 128. JGetNumber returns a data type JNumber. The hardware I’m using is an AVR 8bits and JNumber seems to be a float of 4 bytes. The significant precision of a float could explain the behavior I get.
My question is how I can extract correctly a timestamp using the arduino notecard library (1.2.9)?
Thanks