#include <zephyr.h>
#include <net/socket.h>

#include <stdio.h>

#include "lte_post_get.c"
#include "gps.c"



/********************************************/
int main (void)
{
  printk("Test is starting \n"); 
  /*
    int lte_err= nRF_LTE_check();
    if(lte_err==0){ printk("  find LTE_M signal........... \n");
    app_http_post("from nRF91\r"); 
      }
    else{ printk(" Couldnt find LTE_M signal........... \n");}
    k_sleep(5000);
    */
        nrf_gnss_data_frame_t gps_data;
	u8_t		      cnt = 0;
        
	printk("Staring GPS application\n");

	if (init_app() != 0) {
		return -1;
	}

	printk("Getting GPS data...\n");

	while (1) {

		do {
			
		} 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("---------------------------------");
                       /*
                        int lte_err= nRF_LTE_check();
                        if(lte_err==0){ printk("  find LTE_M signal........... \n");
                        app_http_post("from nRF91\r"); 
                                   }
                        else{ printk(" Couldnt find LTE_M signal........... \n");}
                        k_sleep(5000);
                        */
			update_terminal = false;
		}

		k_sleep(K_MSEC(500));
	}

	return 0;

}
