Yeah it works!

Dependencies:   GPS RF22 mbed

Fork of Geofence_sender by Umair Ishfaq

Revision:
2:c1f0b54834a5
Parent:
0:bdfb6afe26e0
diff -r 93cb484f564a -r c1f0b54834a5 main.cpp
--- a/main.cpp	Thu Dec 31 16:33:07 2015 +0000
+++ b/main.cpp	Fri Jan 01 19:31:35 2016 +0000
@@ -19,10 +19,11 @@
  
  
 // send messages forever
-void send_loop() {
+int send_loop() {
     uint8_t data[32] = "";
+    int flagcheck1=0;
  
-    while (1) {
+    while (flagcheck1==0) {
         
         if(af.sample()==1)
         {
@@ -34,10 +35,12 @@
         pc.printf("\n\rStart sending ... ");
         if (rf22.sendtoWait(data, sizeof(data), receiver_adress)) {
             pc.printf("Send to %i ACK: >>%s<< ", receiver_adress,(char*)data);
-        } else {
+        } 
+        else {
             pc.printf("Send to %i NOTACK: >>%s<< ", receiver_adress,(char*)data);
         }
         pc.printf("sleeping 2 seconds...  ");
+        flagcheck1=1;
         wait(1); 
         }
         else
@@ -49,10 +52,8 @@
         } // Wait 2 Seconds
     }
 }
- 
-int main() {
- 
-    pc.baud(9600);
+ void rfcheck()
+ {
     pc.printf("\n\rConnected to mbed\n\r");
  
     pc.printf ("RF22-Test-Reliable-Send V1.0\n\r");
@@ -71,7 +72,13 @@
     // Code for sending
     pc.printf("I am sending with address %i to adress %i ...\n\r",sender_adress,receiver_adress  );
     rf22.setThisAddress(sender_adress);     // sender-adress
+  
+  }
+int main() {
  
+    pc.baud(9600);
+    rfcheck();
+    
     send_loop();                // start sending
 }
  
\ No newline at end of file