Description:
I am new and want to try to test the notecard in a local manner. On a brand new Notecard (SKU: NOTE-NBNAW, v9.1.1, Arduino Notecard library v1.7.1), local note retrieval with note.get fails—regardless of file name or options, immediately after adding a note. See code and log below.
Code:
#include <Wire.h>
#include <Notecard.h>
Notecard notecard;
void setup() {
Serial.begin(115200);
while (!Serial);
Wire.begin();
notecard.begin();
notecard.setDebugOutputStream(Serial);
J *req = notecard.newRequest("note.add");
JAddStringToObject(req, "file", "superlocal.qo");
J *body = JCreateObject();
JAddNumberToObject(body, "demo", 10.12);
JAddItemToObject(req, "body", body);
J *rsp = notecard.requestAndResponse(req);
if (rsp != NULL) {
Serial.println("Note added");
} else {
Serial.println("Failed to add note");
}
req = notecard.newRequest("note.get");
JAddStringToObject(req, "file", "superlocal.qo");
rsp = notecard.requestAndResponse(req);
if (rsp != NULL) {
char *fullJson = JPrint(rsp);
Serial.print("Full note.get response: ");
Serial.println(fullJson);
JFree(fullJson);
J *body = JGetObject(rsp, "body");
if (body != NULL) {
char *json = JPrint(body);
Serial.print("Fetched note body: ");
Serial.println(json);
JFree(json);
double value = JGetNumber(body, "demo");
Serial.print("Fetched value: ");
Serial.println(value);
} else {
Serial.println("No 'body' field found in response.");
}
}
}
void loop() {}
Output:
[INFO] {"req":"note.add","file":"superlocal.qo","body":{"demo":10.12},"crc":"0000:DCC0FD9A"}
[INFO] {"total":3}
Note added
[INFO] {"req":"note.get","file":"superlocal.qo","crc":"0001:5E0893DE"}
[INFO] {"err":"no notes available {note-noexist}","crc":"0001:2455BF6F"}
Full note.get response: {
"err": "no notes available {note-noexist}",
"crc": "0001:2455BF6F"
}
No 'body' field found in response.
Can anybody check what’s wrong with the setup? Thanks.