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.

70 lines
1.6 KiB

  1. /*
  2. UTILS MODULE
  3. Copyright (C) 2017-2019 by Xose Pérez <xose dot perez at gmail dot com>
  4. */
  5. #pragma once
  6. #include "espurna.h"
  7. struct heap_stats_t {
  8. uint32_t available;
  9. uint16_t usable;
  10. uint8_t frag_pct;
  11. };
  12. PROGMEM const char pstr_unknown[] = "UNKNOWN";
  13. #define INLINE inline __attribute__((always_inline))
  14. extern "C" uint32_t _SPIFFS_start;
  15. extern "C" uint32_t _SPIFFS_end;
  16. void setDefaultHostname();
  17. void setBoardName();
  18. const String& getDevice();
  19. const String& getManufacturer();
  20. const String& getCoreVersion();
  21. const String& getCoreRevision();
  22. int getHeartbeatMode();
  23. unsigned long getHeartbeatInterval();
  24. void heartbeat();
  25. String getAdminPass();
  26. String getBoardName();
  27. String buildTime();
  28. unsigned long getUptime();
  29. bool haveRelaysOrSensors();
  30. void getHeapStats(heap_stats_t& stats);
  31. heap_stats_t getHeapStats();
  32. void wtfHeap(bool value);
  33. unsigned int getFreeHeap();
  34. void setInitialFreeHeap();
  35. unsigned int getInitialFreeHeap();
  36. void infoHeapStats(const char* name, const heap_stats_t& stats);
  37. void infoHeapStats(bool show_frag_stats = true);
  38. void infoMemory(const char * name, unsigned int total_memory, unsigned int free_memory);
  39. void infoUptime();
  40. void info(bool first = false);
  41. bool sslCheckFingerPrint(const char * fingerprint);
  42. bool sslFingerPrintArray(const char * fingerprint, unsigned char * bytearray);
  43. bool sslFingerPrintChar(const char * fingerprint, char * destination);
  44. bool eraseSDKConfig();
  45. char * ltrim(char * s);
  46. char * strnstr(const char * buffer, const char * token, size_t n);
  47. bool isNumber(const char * s);
  48. void nice_delay(unsigned long ms);
  49. double roundTo(double num, unsigned char positions);