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.

74 lines
1.8 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. const String& getVersion();
  23. int getHeartbeatMode();
  24. unsigned long getHeartbeatInterval();
  25. void heartbeat();
  26. String getAdminPass();
  27. String getBoardName();
  28. String buildTime();
  29. unsigned long getUptime();
  30. bool haveRelaysOrSensors();
  31. void getHeapStats(heap_stats_t& stats);
  32. heap_stats_t getHeapStats();
  33. void wtfHeap(bool value);
  34. unsigned int getFreeHeap();
  35. void setInitialFreeHeap();
  36. unsigned int getInitialFreeHeap();
  37. void infoHeapStats(const char* name, const heap_stats_t& stats);
  38. void infoHeapStats(bool show_frag_stats = true);
  39. void infoMemory(const char * name, unsigned int total_memory, unsigned int free_memory);
  40. void infoUptime();
  41. void info(bool first = false);
  42. bool sslCheckFingerPrint(const char * fingerprint);
  43. bool sslFingerPrintArray(const char * fingerprint, unsigned char * bytearray);
  44. bool sslFingerPrintChar(const char * fingerprint, char * destination);
  45. bool eraseSDKConfig();
  46. char * ltrim(char * s);
  47. char * strnstr(const char * buffer, const char * token, size_t n);
  48. bool isNumber(const char * s);
  49. void nice_delay(unsigned long ms);
  50. double roundTo(double num, unsigned char positions);
  51. size_t hexEncode(const uint8_t* in, size_t in_size, char* out, size_t out_size);
  52. size_t hexDecode(const char* in, size_t in_size, uint8_t* out, size_t out_size);