Skip to content

Instantly share code, notes, and snippets.

@ElectricImpSampleCode
Created January 5, 2021 11:41
Show Gist options
  • Save ElectricImpSampleCode/6ae87728bcf87f4bfd303bc179309d4b to your computer and use it in GitHub Desktop.
Save ElectricImpSampleCode/6ae87728bcf87f4bfd303bc179309d4b to your computer and use it in GitHub Desktop.
Electric Imp imp API GNSS example code: get NMEA sentences
// Get GSV (satellites in view) NMEA sentences from modem
// NOTE #1 See https://gpsd.gitlab.io/gpsd/NMEA.html#_nmea_standard_sentences
// for sentence details
// NOTE #2 Assumes you have an existing configured and enabled gnss-session
// instance, as per https://developer.electricimp.com/api/gnss-session/enable
// Callback to process read sentences
function processSentences(result) {
if (result.status == 0) {
// No error, so just output each received sentence,
// but could parse them here too
foreach (sentence in data.nmea) {
server.log(sentence);
}
} else {
// Error
server.error("Error getting NMEA sentence(s)");
}
}
// Reasd GSV (satellites in view) NMEA sentences from modem
gnssSession.readnmea(processSentences, "GSV");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment