Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of dgps by
Diff: packet.h
- Revision:
- 45:0d6ef4cbd4c7
- Parent:
- 41:df156ae5631b
- Child:
- 46:f89fc45811a1
--- a/packet.h Wed Apr 23 04:45:36 2014 +0000
+++ b/packet.h Thu Apr 24 16:16:57 2014 +0000
@@ -68,7 +68,11 @@
//wait_ms(100);
}
- void openConnection(char close_conn = 0){
+ void openConnection(char close_conn = 0, char hover_attempt = 0){
+ EvTimer t;
+ t.set_s_period(30);
+ t.start_timer();
+ char timed_out = 0;
do{
USB::getSerial().printf("trying to connect...\r\n");
if(getTCPConStatus){
@@ -78,7 +82,20 @@
}
setTCPConStatus = 1;
wait_us(100000);
- }while(!getTCPConStatus);
+ timed_out = t.get_num_trips();
+ }while(!getTCPConStatus && !timed_out);
+ t.stop_timer();
+ if(timed_out>0){
+ if(hover_attempt){
+ //emergency landing goes here
+ USB::getSerial().printf("Second Attempt Connection failure. Emergency Landing.\r\n");
+ }else{
+ //hover and give it another shot
+ USB::getSerial().printf("First Attempt Connection failure. Hover and retry.\r\n");
+ //hover code goes here
+ openConnection(close_conn, 1);
+ }
+ }
}
void closeConnection(){
