Backing up an unused program in case of future need

Dependencies:   mbed

main.cpp

Committer:
andrewboyson
Date:
2016-04-13
Revision:
0:09f915e6f9f6
Child:
2:06fa34661f19

File content as of revision 0:09f915e6f9f6:

#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;
}