Konfiguration über http
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
976B

  1. /*
  2. * struct.h
  3. *
  4. * Created on: 07.04.2020
  5. * Author: agr
  6. */
  7. #ifndef STRUCT_H_
  8. #define STRUCT_H_
  9. #include <PubSubClient.h>
  10. #include <Ethernet.h>
  11. struct config_t
  12. {
  13. byte config_set;
  14. byte use_dhcp;
  15. byte dhcp_refresh_minutes;
  16. byte mac[6];
  17. byte ip[4];
  18. byte gateway[4];
  19. byte subnet[4];
  20. byte dns_server[4];
  21. unsigned int webserverPort;
  22. byte mqtt_server[4];
  23. unsigned int mqttserverPort;
  24. } eeprom_config;
  25. int EEPROM_readAnything(int ee, config_t& value)
  26. {
  27. byte* p = (byte*)(void*)&value;
  28. unsigned int i;
  29. for (i = 0; i < sizeof(value); i++)
  30. *p++ = EEPROM.read(ee++);
  31. return i;
  32. }
  33. int EEPROM_writeAnything(int ee, const config_t& value)
  34. {
  35. const byte* p = (const byte*)(const void*)&value;
  36. unsigned int i;
  37. for (i = 0; i < sizeof(value); i++)
  38. EEPROM.write(ee++, *p++);
  39. return i;
  40. }
  41. EthernetClient MQTTethClient;
  42. PubSubClient MQTTclient(MQTTethClient);
  43. #endif /* STRUCT_H_ */