My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

wifi.cpp 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifdef ARDUINO_ARCH_ESP32
  20. #include "../../inc/MarlinConfigPre.h"
  21. #if ENABLED(WIFISUPPORT)
  22. #include <WiFi.h>
  23. #include <ESPmDNS.h>
  24. #include <ESPAsyncWebServer.h>
  25. #include "wifi.h"
  26. AsyncWebServer server(80);
  27. #ifndef WIFI_HOSTNAME
  28. #define WIFI_HOSTNAME DEFAULT_WIFI_HOSTNAME
  29. #endif
  30. void wifi_init() {
  31. WiFi.mode(WIFI_STA);
  32. WiFi.begin(WIFI_SSID, WIFI_PWD);
  33. while (WiFi.waitForConnectResult() != WL_CONNECTED) {
  34. delay(5000);
  35. ESP.restart();
  36. }
  37. delay(10);
  38. // Loop forever (watchdog kill) on failure
  39. if (!MDNS.begin(WIFI_HOSTNAME)) for(;;) delay(5000);
  40. MDNS.addService("http", "tcp", 80);
  41. }
  42. #endif // WIFISUPPORT
  43. #endif // ARDUINO_ARCH_ESP32