I am trying to implement a simple location tracking logic to publish the device's GNSS location every N seconds. I have an MSOM board running device OS v5.9.0. I found the particle-som-gnss library and am trying this example code here as is. However,
the Serial.available() is always false, and so the check on line 43 always fails
when I commented that out just to see, what comes through c never becomes 'g' or 'p'
What are you using for the serial terminal? The particle serial monitor cannot be used because it's only a monitor and cannot send data to the device. There are other options available that will work.
Sorry, not sure what you mean. I am not really monitoring Serial directly. Please point me to any docs that will help me do that, because my debugging approach right now is very roundabout. I added Particle.publish() statements with log messages then look at the Events tab on Console
I am running the usage.cpp linked in the original post as is without changes.
The example program waits for characters to be typed at the USB serial terminal connected to the M-SoM. In order to type to the device, you need to use one of the terminal programs other than particle serial monitor or the Particle CLI terminal in Workbench. There's a list in the link above.
Hi, @madvn I've sketched out a simple example that removes the serial interface and instead periodically queries the location. Warning that this has not been tested, but should be a useful reference point.
#include "Particle.h"
#include "location.h"
SYSTEM_MODE(AUTOMATIC);
SYSTEM_THREAD(ENABLED);
SerialLogHandler logHandler(LOG_LEVEL_INFO);
LocationPoint point = {};
bool ready = true;
bool locFound = false;
void getCb(LocationResults results) {
Log.info("async callback returned %d", (int)results);
if (results == LocationResults::Fixed) {
locFound = true;
Log.info("Position fixed!");
Log.info("Lat %0.5lf, lon %0.5lf", point.latitude, point.longitude);
Log.info("Alt %0.1f m, speed %0.1f m/s, heading %0.1f deg", point.altitude, point.speed, point.heading);
} else {
Log.info("Position not fixed. :(");
}
}
time_t lastRun = 0;
const uint32_t intervalSeconds = 86400; // 24 hours
void setup() {
LocationConfiguration config;
config.enableAntennaPower(GNSS_ANT_PWR);
Location.begin(config);
lastRun = Time.now(); // initialize with boot time
}
void loop() {
if (Time.now() - lastRun >= intervalSeconds) {
lastRun = Time.now(); // update last run time
Log.info("Starting daily GNSS acquisition");
Location.getLocation(point, getCb, true);
}
if(locFound){
locFound = false;
// do work
}
}
I'm giving it a shot - results == LocationResults::Fixed is False. Looks like result is always 6 (Timeout). Will try and debug that.
Related dumb question: How/where do I see the logs from the Log.info statements. Currently I replace them with Particle.publish which is certainly not the best/right way to do it.
Hey @madvn, how do you have your device powered & connected? Are you using a Muon or custom hardware? How are you programming it?
Make sure you have the MSoM's GNSS antenna connected to the correct uFL connector.
Any Log.info calls will go through the serial port. It's much more ergonomic if you program & monitor logs over the serial port via the VSCode Workbench extension.
I have an M404 on a M.2 SoM breakout board. Looks like the M404 has Device OS 5.9.0. Its powered using the adapter that came with the breakout board and its plugged into my laptop via USB. I am flashing the program via the web IDE. I've verified that the GNSS antenna is plugged into the correct connector.