/*
    This sketch is combined demo of: 1) SD(esp_32) -- > SD_Test; 2) WiFi --> ETH_LAN8720
    It displays info about the card on the terminal and initializes LAN after that. You can ping the IP address shown on the terminal.

*/
#define ETH_CLK_MODE ETH_CLOCK_GPIO17_OUT
#define ETH_PHY_POWER 12

#include <ETH.h>

static bool eth_connected = false;

void WiFiEvent(WiFiEvent_t event);
void testClient(const char * host, uint16_t port);

#define BUTTON_PRESSED()  (!digitalRead (34))
void setup()
{
    Serial.begin(115200);
    WiFi.onEvent(WiFiEvent);
    ETH.begin();
    pinMode (34, INPUT);  // Button
}


void loop()
{
  if (BUTTON_PRESSED()) {
    if (eth_connected) {
      Serial.println("Button pressed");
      testClient("google.com", 80);
    }
    delay(1000);
  }
}
