// M4 Feather to Notecard
serialDebug.begin(115200);
notecard.begin();
notecard.setDebugOutputStream(usbSerial);
J *req = notecard.newRequest("hub.set");
JAddStringToObject(req, "product", productUID);
JAddStringToObject(req, "mode", "continuous"); // periodic / continuous
JAddNumberToObject(req, "outbound", 20);
JAddNumberToObject(req, "inbound", 60); // up load data frequency, in mints
notecard.sendRequest(req);
req = notecard.newRequest("card.location.mode");
JAddStringToObject(req, "mode", "periodic"); // periodic / continuous
JAddNumberToObject(req, "seconds", 60); // periodic and <300s
notecard.sendRequest(req);
req = notecard.newRequest("card.location.track");
JAddBoolToObject(req, "sync", true);
JAddBoolToObject(req, "heartbeat", true);
JAddNumberToObject(req, "hours", 1);
notecard.sendRequest(req);
req = NoteNewRequest("card.motion.mode");
JAddBoolToObject(req, "start", true);
notecard.sendRequest(req);
/////////
notecard_data_update_counter++;
if(notecard_data_update_counter > 50000){
J *req = notecard.newRequest("note.add");
if( req != NULL ){
JAddStringToObject(req, "file", "sensors.qo");
JAddBoolToObject(req, "sync", true);
J *body = JAddObjectToObject(req, "body");
if (body){
JAddNumberToObject(body, "temp", temperature);
JAddNumberToObject(body, "humidity", humidity);
JAddNumberToObject(body, "cell_L", cell_min);
JAddNumberToObject(body, "cell_H", cell_max);
JAddNumberToObject(body, "SOC", cell_SOC);
JAddNumberToObject(body, "Motor_temp", engine_temp[0]);
JAddNumberToObject(body, "Motor_rpm", motor_speed[4]);
JAddNumberToObject(body, "Km/h", wheel_speed[2]);
}
notecard.sendRequest(req);
}
if( req != NULL ){
J *rsp = notecard.requestAndResponse(notecard.newRequest("card.location"));
gps_time_s = JGetInt(rsp, "time");
NoteDeleteResponse(rsp);
}
notecard_data_update_counter = 0;
}
i’m use M4 feather CAN + notecard
it can only up date to notehub.io once when power on, that’s all.
i need it can be pump up the data to notehub.io every 5 mints or maybe 10 mints.
also GPS can be keep pumping the location every 60s.
can someone help me to optimized the code?
not sure where is wrong…
thanks lot!!!