Mirror of espurna firmware for wireless switches and more
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.

51 lines
1018 B

  1. /*
  2. NETWORKING MODULE
  3. Copyright (C) 2022 by Maxim Prokhorov <prokhorov dot max at outlook dot com>
  4. */
  5. #pragma once
  6. #include <Arduino.h>
  7. #include <IPAddress.h>
  8. #include <memory>
  9. #include <lwip/init.h>
  10. #include <lwip/err.h>
  11. #include "types.h"
  12. namespace espurna {
  13. namespace network {
  14. namespace dns {
  15. struct Host {
  16. String name;
  17. IPAddress addr;
  18. err_t err;
  19. };
  20. using HostPtr = std::shared_ptr<Host>;
  21. using HostCallback = std::function<void(HostPtr)>;
  22. // DNS request is lauched in the background, HostPtr should be waited upon
  23. HostPtr resolve(String);
  24. // ...or, user callback is executed when DNS client is ready to return something
  25. void resolve(String, HostCallback);
  26. // Block until the HostPtr becomes available for reading, or when timeout occurs
  27. bool wait_for(HostPtr, duration::Milliseconds);
  28. // Arduino style result
  29. IPAddress gethostbyname(String, duration::Milliseconds);
  30. IPAddress gethostbyname(String);
  31. } // namespace dns
  32. } // namespace network
  33. } // namespace espurna
  34. void networkSetup();