Esempio n. 1
0
void bringUpWifi()
{
    unsigned triesBeforeChipReset = 2000;
    unsigned count = 0;
    while(!wifiConnected)
    {
        // Start by putting chip in known state
        esp.enable();
        delay(500);
        hardResetEspChip();
        delay(1000);
        esp.reset();
        delay(500);
        while(!esp.ready())
        {
            digitalWrite(HEART_BEAT_LED, HIGH);
            delay(1000);
            digitalWrite(HEART_BEAT_LED, LOW);
            delay(1000);
            if(count >= 3)
            {
                debugSerial.println("ARDUINO: Resetting ESP chip");
                esp.enable();
                delay(500);
                hardResetEspChip();
                delay(1000);
                esp.reset();
                delay(500);
                count = 0;
            }

            count++;
        }


        /*setup wifi*/
        debugSerial.println("ARDUINO: Setting up wifi");
        esp.wifiConnect(SSID,PASSWORD);
        // We should chill here until we get a wifi connection
        while(!wifiConnected && (count < triesBeforeChipReset) )
        {
            esp.process();
            delay(100);
            ++count;
        }
        count = 0;
    }
}
void ArduinoWifiClass::connect(char* ssid,char* pwd){
	esp.wifiConnect(ssid, pwd);
}