-
Notifications
You must be signed in to change notification settings - Fork 1
/
getTLE.ino
40 lines (40 loc) · 1.03 KB
/
getTLE.ino
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
void getTLE(int SAT){
// Make HTTP request and get TLE for satellite//
if (client.connect(server, 80)) {
#ifdef DEBUG
Serial.println("connected to server");
Serial.println("Request #: " + String(SAT) + " For: " + String(satnames[SAT]));
#endif
// Make a HTTP request: //
client.println("GET " + String(satURL[SAT]));
client.println("Accept: */*");
client.println("Host: www.celestrak.com");
client.println("Connection: close");
}
int connectLoop = 0;
while(client.connected()){
int j = 0;
while (client.available()) {
char c = client.read();
TLE[j] = c; //store characters to string
j++;
connectLoop = 0;
}
k = 0;
for (j=26; j<96; j++){ //TLE line 1 spans characters 26 - 96
TLE1[SAT][k] = TLE[j];
k++;
}
k = 0;
for (j=97; j< 167; j++){ //TLE line 2 spans characters 97 - 167
TLE2[SAT][k]= TLE[j];
k++;
}
connectLoop++;
delay(100);
if(connectLoop > 100){
client.stop();
break;
}
}
}