Fork of the espurna firmware for `mhsw` switches
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.

63 lines
1.3 KiB

  1. /*
  2. WIFI MODULE
  3. Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com>
  4. */
  5. #pragma once
  6. #include "espurna.h"
  7. #include <lwip/init.h>
  8. #if LWIP_VERSION_MAJOR == 1
  9. #include <netif/etharp.h>
  10. #elif LWIP_VERSION_MAJOR >= 2
  11. #include <lwip/etharp.h>
  12. #endif
  13. #define LWIP_INTERNAL
  14. #include <JustWifi.h>
  15. #include <Ticker.h>
  16. #undef LWIP_INTERNAL
  17. extern "C" {
  18. #include <lwip/opt.h>
  19. #include <lwip/ip.h>
  20. #include <lwip/tcp.h>
  21. #include <lwip/inet.h> // ip_addr_t
  22. #include <lwip/err.h> // ERR_x
  23. #include <lwip/dns.h> // dns_gethostbyname
  24. #include <lwip/ip_addr.h> // ip4/ip6 helpers
  25. };
  26. // ref: https://github.com/me-no-dev/ESPAsyncTCP/pull/115/files#diff-e2e636049095cc1ff920c1bfabf6dcacR8
  27. // This is missing with Core 2.3.0 and is sometimes missing from the build flags. Assume HIGH_BANDWIDTH version.
  28. #ifndef TCP_MSS
  29. #define TCP_MSS (1460)
  30. #endif
  31. using wifi_callback_f = std::function<void(justwifi_messages_t code, char * parameter)>;
  32. uint8_t wifiState();
  33. void wifiReconnectCheck();
  34. bool wifiConnected();
  35. String getNetwork();
  36. String getIP();
  37. void wifiDebug();
  38. void wifiDebug(WiFiMode_t modes);
  39. void wifiStartAP();
  40. void wifiStartSTA();
  41. void wifiDisconnect();
  42. void wifiStartWPS();
  43. void wifiStartSmartConfig();
  44. void wifiRegister(wifi_callback_f callback);
  45. void wifiSetup();
  46. void wifiLoop();