//make sure to upload with ESP32 Dev Module selected as the board under tools>Board>ESP32 Arduino

#include <Arduino.h>
#include <WiFi.h>
#include "motors.h"
#include "webserver.h"
#include "ota.h"


const char* ssid     = "iot";
const char* pwd      = "Rijnstraat214";

void setup(void) 
{
  Serial.begin(115200);
  delay(1000);
  log_i("init hardware");  
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid,pwd );
  if (WiFi.waitForConnectResult() != WL_CONNECTED) 
  {
    log_e("WiFi Failed! rebooting in 2sec");
    delay(2000);
    ESP.restart();
  }
  log_i("IP address: %s", WiFi.localIP().toString());
  initOTA("MiniSkidi");
  
  setupmotors();
  setup_webserver();
}

void loop() 
{
  loop_webserver();
  loopOTA();
}