Hey All!
I am trying to transmit events from my blues starter kit in order to access the location of it at all times. When I check out the events in notehub however it doesn’t use the GPS location, even though I’ve attached the antenna to the notecard. When I check out my event and click on the map, the GPS location is not available and the best location comes from triangulation using cell towers which isn’t very accurate.
After doing some digging I found that this log is constantly being printed out:
{"status":"GPS waiting to start {gps-starting} {gps-active}","mode":"periodic"}
For some reason, my GPS can’t seem to get started.
- I’ve tried staying outside for 20 minutes
- I’ve made sure the dip switch is on PASSIVE
- I’ve made sure I’ve connected the antenna correctly
I would appreciate any support on why this is happening, I’ve attached my code here that I’ve uploaded to the swan. I also include fall detection and that works just fine here.
#include <Wire.h>
#include <Notecard.h>
Notecard notecard;
void setup() {
delay(3000);
Serial.begin(115200);
Wire.begin();
notecard.begin();
notecard.setDebugOutputStream(Serial);
{
J *req = notecard.newRequest("hub.set");
if (req) {
JAddStringToObject(req, "product", "REDACTED");
JAddStringToObject(req, "mode", "continuous");
notecard.sendRequest(req);
}
}
{
J *req = notecard.newRequest("card.location.mode");
if (req) {
JAddStringToObject(req, "mode", "continuous");
JAddStringToObject(req, "start", "now");
JAddBoolToObject(req, "gps", true);
notecard.sendRequest(req);
}
}
{
J *req = notecard.newRequest("card.location.track");
if(req){
JAddBoolToObject(req, "start", true);
JAddBoolToObject(req, "heartbeat", true);
JAddIntToObject(req, "hours", 12);
}
}
{
J *req = notecard.newRequest("card.motion.mode");
if (req) {
JAddBoolToObject(req, "start", true);
JAddNumberToObject(req, "sensitivity", 2);
notecard.sendRequest(req);
}
}
}
void loop() {
{
double lat=0, lon=0;
bool valid = false;
J *req = notecard.newRequest("card.location");
if (req) {
JAddNumberToObject(req, "hours", 1);
J *rsp = notecard.requestAndResponse(req);
if (rsp) {
lat = JGetNumber(rsp, "lat");
lon = JGetNumber(rsp, "lon");
valid = JGetBool(rsp, "valid");
notecard.deleteResponse(rsp);
}
}
J *noteReq = notecard.newRequest("note.add");
if (noteReq) {
JAddStringToObject(noteReq, "file", "track.qo");
JAddBoolToObject(noteReq, "sync", true);
J *body = JAddObjectToObject(noteReq, "body");
if (body) {
if (valid) {
JAddNumberToObject(body, "lat", lat);
JAddNumberToObject(body, "lon", lon);
} else {
JAddStringToObject(body, "location", "invalid");
}
}
notecard.sendRequest(noteReq);
}
}
{
J *mreq = notecard.newRequest("card.motion");
if (mreq) {
JAddNumberToObject(mreq, "minutes", 1);
J *mrsp = notecard.requestAndResponse(mreq);
if (mrsp) {
bool alert = JGetBool(mrsp, "alert");
if (alert) {
Serial.println("Fall (free-fall) detected!");
J *fallReq = notecard.newRequest("note.add");
if (fallReq) {
JAddStringToObject(fallReq, "file", "track.qo");
JAddBoolToObject(fallReq, "sync", true);
J *body = JAddObjectToObject(fallReq, "body");
if (body) {
JAddStringToObject(body, "event", "FALL_DETECTED");
}
notecard.sendRequest(fallReq);
}
}
notecard.deleteResponse(mrsp);
}
}
}
delay(15000);
}