-
Notifications
You must be signed in to change notification settings - Fork 3
/
Day6_GPS_Tracker_final.c
95 lines (57 loc) · 1.11 KB
/
Day6_GPS_Tracker_final.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include<avr/io.h>
#include<util/delay.h>
#include "serial.h"
#include "lcd.h"
void beep()
{
write(porta,3,h);
_delay_ms(300);
write(porta,3,l);
}
int main()
{
beep();
char url[120],response[10];
serial_init(9600);
serial_select(3);
lcd_init();
lcd_string_P(PSTR("GPS Tracker"));
set_timeout(30); //Auto Reset If code gets blocked for more than 30 seconds
gsm_init();
reset_timeout();
gprs_init();
reset_timeout();
agps_init();
//gps_init();
reset_timeout();
gprs_connect();
reset_timeout();
char lat[10];
char lon[10];
char speed[10];
while (1)
{
if(gps_fix()==1)
{
reset_timeout();
gps_getcoordinates(lat,lon,speed);
lcd_clear();
lcd_string(lat);
lcd_gotoxy(0,1);
lcd_string(lon);
reset_timeout();
sprintf(url,"api.clobous.com/Zck77/track?&lat=%s&long=%s&speed=%s",lat,lon,speed);
http_get(url,response);
reset_timeout();
lcd_clear();
lcd_string(response);
_delay_ms(1000);
}
else{
lcd_clear();
lcd_string("NO GPS FIX");
_delay_ms(50);
}
_delay_ms(500);
}
}