I am debugging the GPS function and referring to the sample code of the official GPS. As for the code of reading GPS data, I have a question that is the way of obtaining GPS data. Why we can't use the non-blocking interrupt mode? Now it is read through the while loop, which will cause the program to stay here all the time and affect the execution of other functions. Is there any non-blocking way such as interrupt or reminder to get THE GPS data?
int main(void)
{
nrf_gnss_data_frame_t gps_data;
u8_t cnt = 0;
#ifdef CONFIG_SUPL_CLIENT_LIB
static struct supl_api supl_api = {
.read = supl_read,
.write = supl_write,
.handler = inject_agps_type,
.logger = supl_logger,
.counter_ms = k_uptime_get
};
#endif
printk("Staring GPS application\n");
if (init_app() != 0) {
return -1;
}
#ifdef CONFIG_SUPL_CLIENT_LIB
int rc = supl_init(&supl_api);
if (rc != 0) {
return rc;
}
#endif
printk("Getting GPS data...\n");
while (1) {
do {
/* Loop until we don't have more
* data to read
*/
} while (process_gps_data(&gps_data) > 0);
if (!got_first_fix) {
cnt++;
printk("\033[1;1H");
printk("\033[2J");
print_satellite_stats(&gps_data);
printk("\nScanning [%c] ",
update_indicator[cnt%4]);
}
if (((k_uptime_get() - fix_timestamp) >= 1) &&
(got_first_fix)) {
printk("\033[1;1H");
printk("\033[2J");
print_satellite_stats(&gps_data);
printk("---------------------------------\n");
print_pvt_data(&last_fix);
printk("\n");
print_nmea_data();
printk("---------------------------------");
update_terminal = false;
}
k_sleep(K_MSEC(500));
}
return 0;
}