ethernet.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #pragma once
  2. #include "esp_err.h"
  3. #include "sdkconfig.h"
  4. #include <stdbool.h>
  5. #ifdef CONFIG_ETH_W5500_ENABLED
  6. esp_err_t ethernet_init(void);
  7. bool ethernet_is_connected(void);
  8. bool ethernet_is_link_up(void);
  9. esp_err_t ethernet_get_ip_str(char *ip_str, size_t len);
  10. void ethernet_get_mac_str(char *mac_str, size_t len);
  11. void ethernet_set_hostname(const char *device_name);
  12. #else // !CONFIG_ETH_W5500_ENABLED
  13. static inline esp_err_t ethernet_init(void) {
  14. return ESP_ERR_NOT_SUPPORTED;
  15. }
  16. static inline bool ethernet_is_connected(void) {
  17. return false;
  18. }
  19. static inline bool ethernet_is_link_up(void) {
  20. return false;
  21. }
  22. static inline esp_err_t ethernet_get_ip_str(char *ip_str, size_t len) {
  23. if (ip_str && len > 0) {
  24. ip_str[0] = '\0';
  25. }
  26. return ESP_ERR_NOT_SUPPORTED;
  27. }
  28. static inline void ethernet_get_mac_str(char *mac_str, size_t len) {
  29. if (mac_str && len > 0) {
  30. mac_str[0] = '\0';
  31. }
  32. }
  33. static inline void ethernet_set_hostname(const char *device_name) {
  34. (void)device_name;
  35. }
  36. #endif // CONFIG_ETH_W5500_ENABLED