Andrew Boyson
/
iot
Backing up an unused program in case of future need
Diff: main.cpp
- Revision:
- 0:09f915e6f9f6
- Child:
- 2:06fa34661f19
diff -r 000000000000 -r 09f915e6f9f6 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Apr 13 09:21:02 2016 +0000 @@ -0,0 +1,76 @@ +#include "mbed.h" +#include "time.h" +#include "log.h" +#include "at.h" +#include "ntp.h" +#include "esp.h" +#include "io.h" +#include "server.h" +#include "wifi.h" + +static Timer stopTimer; + +int main() +{ + + stopTimer.reset(); + stopTimer.start(); + + Led1 = 0; Led2 = 0; Led3 = 0; Led4 = 0; + + TimeInit(); + LogInit(); + EspInit(); + AtInit(); + NtpInit(); + ServerInit(); //Call this after any connections (ntp) are reserved + + int r = 0; + while (1) + { + r = WifiMain(); + if (r) + { + break; + } + r = AtMain(); + if (r) + { + break; + } + r = EspMain(); + if (r) + { + break; + } + r = NtpMain(); + if (r) + { + break; + } + r = ServerMain(); + if (r) + { + break; + } + + + switch (WifiStatus) + { + case WIFI_STOPPED: Led2 = 0; Led3 = 0; Led4 = 1; break; + case WIFI_READY: Led2 = 0; Led3 = 1; Led4 = 0; break; + case WIFI_CONNECTED: Led2 = 1; Led3 = 0; Led4 = 0; break; + case WIFI_GOT_IP: Led2 = 0; Led3 = 0; Led4 = 0; break; + + } + //Led1 = AtBusy(); + //if (stopTimer.read() > 20) break; + } + + Led1 = 1; Led2 = 1; Led3 = 1; Led4 = 1; + + LogCrLf("Finished"); + LogSave(); + wait(1); + return EXIT_SUCCESS; +}