Myriota Flex SDK 2.5.0
Loading...
Searching...
No Matches
GNSS Example

This example, at fixed intervals, will attempt to acquire a GNSS fix to retrieve the current location and time, and print it on the debug console.

#include <stdio.h>
#include "flex.h"
#define APPLICATION_NAME "GNSS Example"
// GNSS FIX Interval
#define GNSS_FIX_INTERVAL_HOURS 6
static time_t LocationAndTime(void) {
time_t time;
int32_t lat, lon;
if (FLEX_GNSSFix(&lat, &lon, &time) < 0) {
printf("Failed to get a valid GNSS sync!\n");
} else {
printf("Lat: %f, Lon: %f, Time: %u.\n", lat * 1e-7, lon * 1e-7, (unsigned int)time);
}
return FLEX_HoursFromNow(GNSS_FIX_INTERVAL_HOURS);
}
void FLEX_AppInit() {
printf("%s\n", APPLICATION_NAME);
FLEX_JobSchedule(LocationAndTime, FLEX_ASAP());
}