Backing up an unused program in case of future need

Dependencies:   mbed

Revision:
3:accba7e07a0d
Parent:
2:06fa34661f19
--- a/wifi.cpp	Fri Apr 22 09:23:57 2016 +0000
+++ b/wifi.cpp	Sat Apr 23 20:00:04 2016 +0000
@@ -1,4 +1,5 @@
 #include "mbed.h"
+#include "uart.h"
 #include  "esp.h"
 #include   "at.h"
 #include "wifi.h"
@@ -69,7 +70,9 @@
     if (AtBusy()) return 0;
     
     static int result = AT_NONE;
-    static int autoBaud = 1;
+    static int autoBaudMultiplier = 1;
+    static int autoBaudOdd = false;
+    static int autoBaudRate = 0;
     
     static Timer wifiWaitTimer;
     
@@ -110,7 +113,8 @@
                         default:
                             am = AM_AUTOBAUD;
                             result = AT_NONE;
-                            autoBaud = 1;
+                            autoBaudMultiplier = 1;
+                            autoBaudOdd = false;
                             break;
                     }
                     break;
@@ -120,20 +124,24 @@
             switch (result)
             {
                 case AT_NONE:
-                    EspBaud(9600 * autoBaud);
+                    autoBaudRate = 9600 * autoBaudMultiplier;
+                    if (autoBaudOdd) autoBaudRate += autoBaudRate >> 1; //Multiply by 1.5
+                    UartBaud(autoBaudRate);
                     AtAt(&result);
                     break;
                 case AT_SUCCESS:
+                    LogF("Connected successfully at a baud rate of %d\r\n", autoBaudRate);
                     am = AM_CHANGE_BAUD;
                     result = AT_NONE;
                     break;
                 default:
-                    if (autoBaud == 48)
+                    if (autoBaudOdd) autoBaudMultiplier <<= 1;
+                    autoBaudOdd = !autoBaudOdd;
+                    if (autoBaudMultiplier > 64)
                     {
                         LogCrLf("Could not find a baud rate to connect to ESP");
                         return -1;
                     }
-                    autoBaud++;
                     result = AT_NONE;
                     break;
             }
@@ -142,11 +150,11 @@
             switch (result)
             {
                 case AT_NONE:
-                    LogF("Changing baud to %d\r\n", CfgBaud);
+                    LogF("Changing baud rate to %d\r\n", CfgBaud);
                     AtBaud(CfgBaud, &result);
                     break;
                 case AT_SUCCESS:
-                    EspBaud(CfgBaud);
+                    UartBaud(CfgBaud);
                     am = AM_GET_STATUS;
                     result = AT_NONE;
                     break;