ideasx_interface.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #ifndef __IDEASX_INTERFACE_H__
  2. #define __IDEASX_INTERFACE_H__
  3. #include "esp_common.h"
  4. #include "mqtt/mqtt.h"
  5. #include "log/esp_log.h"
  6. #include "user_config.h"
  7. #include "interface/encoder_interface.h"
  8. /* Health Packet Topics and Payloads */
  9. typedef void (* ideasX_function_t)(void);
  10. typedef struct {
  11. uint8_t topic[20];
  12. uint8_t minor;
  13. uint8_t major;
  14. } hw_ver_t;
  15. typedef struct {
  16. uint8_t topic[20];
  17. uint8_t minor;
  18. uint8_t major;
  19. } fw_ver_t;
  20. typedef struct {
  21. uint8_t topic[20];
  22. bool flag;
  23. } alive_t;
  24. typedef struct {
  25. uint8_t topic[20];
  26. uint32_t value;
  27. } vcell_t;
  28. typedef struct {
  29. uint8_t topic[20];
  30. uint8_t value;
  31. } rom_t;
  32. typedef struct {
  33. uint8_t topic[20];
  34. bool flag;
  35. } ota_t;
  36. typedef struct {
  37. uint8_t topic[20];
  38. int8_t value;
  39. } rssi_t;
  40. typedef struct {
  41. uint8_t topic[20];
  42. uint8_t value[40];
  43. } ssid_t;
  44. typedef struct {
  45. uint8_t topic[20];
  46. uint8_t value[40];
  47. } bssid_t;
  48. typedef struct {
  49. uint8_t topic[20];
  50. uint32_t value;
  51. } soc_t;
  52. typedef struct{
  53. hw_ver_t hw_ver;
  54. fw_ver_t fw_ver;
  55. alive_t alive;
  56. vcell_t vcell;
  57. soc_t soc;
  58. rom_t rom;
  59. ota_t ota;
  60. ssid_t ssid;
  61. bssid_t bssid;
  62. rssi_t rssi;
  63. os_timer_t health_timer;
  64. uint32_t health_report_rate;
  65. } IdeasX_Health_t;
  66. typedef struct {
  67. uint8_t health_topic[40];
  68. uint8_t command_topic[40];
  69. uint8_t device_id[40];
  70. uint8_t mqtt_host[40];
  71. uint32_t mqtt_port;
  72. uint8_t mqtt_user[40];
  73. uint8_t mqtt_pass[40];
  74. uint8_t mqtt_client_id[40];
  75. uint32_t mqtt_keepalive;
  76. os_timer_t battery_timer;
  77. ideasX_function_t success_cb;
  78. ideasX_function_t fail_cb;
  79. } IdeasX_Config_t;
  80. typedef struct {
  81. uint8_t topic[20];
  82. uint32_t* function;
  83. } command_ota_t;
  84. typedef struct {
  85. uint8_t topic[20];
  86. uint32_t* function;
  87. } command_shutdown_t;
  88. typedef struct {
  89. command_ota_t ota;
  90. command_shutdown_t shutdown;
  91. } IdeasX_Command_t;
  92. #define HW_VERSION_HEALTH_TOPIC "hw_ver"
  93. #define FW_VERSION_HEALTH_TOPIC "fw_ver"
  94. #define ALIVE_HEALTH_TOPIC "alive"
  95. #define VCELL_HEALTH_TOPIC "vcell"
  96. #define CHARGE_HEALTH_TOPIC "charge"
  97. #define LBI_HEALTH_TOPIC "lbi"
  98. #define SOC_HEALTH_TOPIC "soc"
  99. #define ROM_HEALTH_TOPIC "rom"
  100. #define OTA_HEALTH_TOPIC "ota"
  101. #define SSID_HEALTH_TOPIC "ssid"
  102. #define BSSID_HEALTH_TOPIC "bssid"
  103. #define RSSI_HEALTH_TOPIC "rssi"
  104. #define AUTH_HEALTH_TOPIC "auth"
  105. #define HEALTH_QOS 0
  106. #define HEALTH_RETAIN 0
  107. #define HW_VERSION_MAJOR_DEFAULT 0
  108. #define HW_VERSION_MINOR_DEFAULT 0
  109. #define FW_VERSION_MAJOR_DEFAULT 0
  110. #define FW_VERSION_MINOR_DEFAULT 0
  111. #define HEALTH_REPORT_RATE_DEFAULT 120 // seconds
  112. #endif