Module_LcmControl_Wistron.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /*
  2. * Module_MqttClient.h
  3. *
  4. * Created on: 2021/11/6
  5. * Author: folus
  6. */
  7. #ifndef MODULE_MQTTCLIENT_H_
  8. #define MODULE_MQTTCLIENT_H_
  9. #include <sys/types.h>
  10. #include <sys/stat.h>
  11. #include <sys/time.h>
  12. #include <sys/timeb.h>
  13. #include <sys/types.h>
  14. #include <sys/ioctl.h>
  15. #include <sys/socket.h>
  16. #include <sys/ipc.h>
  17. #include <sys/shm.h>
  18. #include <sys/mman.h>
  19. #include <linux/wireless.h>
  20. #include <arpa/inet.h>
  21. #include <netinet/in.h>
  22. #include <dirent.h>
  23. #include <sys/prctl.h>
  24. #include <unistd.h>
  25. #include <stdarg.h>
  26. #include <stdio.h>
  27. #include <stdlib.h>
  28. #include <unistd.h>
  29. #include <fcntl.h>
  30. #include <termios.h>
  31. #include <errno.h>
  32. #include <errno.h>
  33. #include <string.h>
  34. #include <time.h>
  35. #include <ctype.h>
  36. #include <ifaddrs.h>
  37. #include <stdbool.h>
  38. #include <stddef.h>
  39. #include <stdint.h>
  40. #include <signal.h>
  41. #include "json-c/json.h"
  42. #include "mosquitto.h"
  43. #define TEST_MODE
  44. #define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args)
  45. #define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args)
  46. #define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args)
  47. enum TIMER_IDX
  48. {
  49. TMR_IDX_0=0,
  50. TMR_IDX_1,
  51. TMR_IDX_2,
  52. TMR_IDX_3,
  53. TMR_IDX_4,
  54. TMR_IDX_5,
  55. TMR_IDX_CNT
  56. };
  57. enum GUN_TYPE
  58. {
  59. GUN_TYPE_UNKNOWN=0,
  60. GUN_TYPE_CHAdeMO,
  61. GUN_TYPE_CCS,
  62. GUN_TYPE_GBT,
  63. GUN_TYPE_DO,
  64. GUN_TYPE_AC
  65. };
  66. enum SWITCH_STS
  67. {
  68. OFF=0,
  69. ON
  70. };
  71. enum BOOLEAN_STS
  72. {
  73. NO=0,
  74. YES
  75. };
  76. enum QOS_TYPE
  77. {
  78. QOS_ONLY_TX=0,
  79. QOS_ENSURE_BROKER,
  80. QOS_ENSURE_SUBSCRIBE
  81. };
  82. enum RETAIN_TYPE
  83. {
  84. RETAIN_NO=0,
  85. RETAIN_YES
  86. };
  87. typedef struct TEXT_LIST
  88. {
  89. uint16_t textviewIndex;
  90. char textString[256];
  91. char textFont[32];
  92. char textStyle[32];
  93. uint8_t textSize;
  94. uint16_t layout_x;
  95. uint16_t layout_y;
  96. }Text_List;
  97. typedef struct IMAGE_LIST
  98. {
  99. uint16_t imageviewIndex;
  100. uint16_t imgsrc_addr;
  101. uint16_t layout_x;
  102. uint16_t layout_y;
  103. uint16_t width;
  104. uint16_t height;
  105. }Image_List;
  106. typedef struct VIDEO_LIST
  107. {
  108. uint16_t videoviewIndex;
  109. uint16_t videosrc_addr;
  110. uint16_t layout_x;
  111. uint16_t layout_y;
  112. uint16_t width;
  113. uint16_t height;
  114. }Video_List;
  115. typedef struct QRCODE_LIST
  116. {
  117. uint16_t qrCodeIndex;
  118. int8_t qrCodeContent[512];
  119. int8_t errorCorrection[8];
  120. uint16_t layout_x;
  121. uint16_t layout_y;
  122. uint16_t width;
  123. uint16_t height;
  124. }QrCode_List;
  125. #define ARRAY_SIZE(A) (sizeof(A) / sizeof(A[0]))
  126. #define is_error(ptr) ((unsigned long)ptr > (unsigned long)-4000L)
  127. #define BROKER_PORT 1883
  128. #define BROKER_ADDRESS "192.168.0.10"
  129. #define TIMEOUT_KEEPALIVE 60
  130. #define LOGIN_USER NULL
  131. #define LOGIN_PASSWD NULL
  132. #define PASS 1
  133. #define FAIL -1
  134. #define PROFILE_CONNECT_TIMEOUT "connect_timeout"
  135. #define OTA_TYPE_UI "ota_ui"
  136. #define OTA_TYPE_APK "ota_apk"
  137. #define OTA_TYPE_SDCARD "ota_sdcard"
  138. #define FONT_STYLE_NORMAL "normal"
  139. #define FONT_STYLE_BOLD "bold"
  140. #define FONT_STYLE_ITALIC "italic"
  141. #define FONT_STYLE_BOLD_ITALIC "bold_italic"
  142. #define FONT_ARIAL "Arial"
  143. enum BRIGHTNESS_LEVEL
  144. {
  145. BRIGHTNESS_LEVEL_0=0,
  146. BRIGHTNESS_LEVEL_1,
  147. BRIGHTNESS_LEVEL_2,
  148. BRIGHTNESS_LEVEL_3,
  149. BRIGHTNESS_LEVEL_4,
  150. BRIGHTNESS_LEVEL_5,
  151. BRIGHTNESS_LEVEL_6,
  152. BRIGHTNESS_LEVEL_7,
  153. BRIGHTNESS_LEVEL_8,
  154. BRIGHTNESS_LEVEL_9,
  155. BRIGHTNESS_LEVEL_10,
  156. BRIGHTNESS_LEVEL_11,
  157. BRIGHTNESS_LEVEL_AUTO,
  158. };
  159. enum FONT_SIZE
  160. {
  161. FONT_SIZE_8PX=8,
  162. FONT_SIZE_10PX=10,
  163. FONT_SIZE_12PX=12,
  164. FONT_SIZE_14PX=14,
  165. FONT_SIZE_16PX=16,
  166. FONT_SIZE_20PX=20,
  167. FONT_SIZE_24PX=24,
  168. FONT_SIZE_34PX=34,
  169. FONT_SIZE_48PX=48,
  170. FONT_SIZE_60PX=60,
  171. FONT_SIZE_96PX=96,
  172. };
  173. struct ClientInfo
  174. {
  175. int8_t verHW[32];
  176. int8_t verFW_OS[32];
  177. int8_t verFW_APK[32];
  178. int8_t verFW_UI[32];
  179. int8_t macAddr[32];
  180. int8_t orientation[32];
  181. }clientInfo;
  182. extern int StoreLogMsg(const char *fmt, ...);
  183. extern int publish_data(struct mosquitto *mosq, char *topic, char *outputStr);
  184. extern int publish_profile(struct mosquitto *mosq, char *parameter, char *value);
  185. extern int publish_upgrade(struct mosquitto *mosq, char *otaType, char *url, char *checksum, char *verInfo);
  186. extern int publish_restart(struct mosquitto *mosq, uint8_t isHardReset);
  187. extern int publish_power_saving(struct mosquitto *mosq, uint8_t isSleep);
  188. extern int publish_back_dimming(struct mosquitto *mosq, uint8_t lightLevel);
  189. extern int publish_timesync(struct mosquitto *mosq);
  190. extern int publish_textview_add(struct mosquitto *mosq, Text_List *textList, uint8_t listCount);
  191. extern int publish_imageview_add(struct mosquitto *mosq, Image_List *imageList, uint8_t listCount);
  192. extern int publish_videoview_add(struct mosquitto *mosq, Video_List *videoList, uint8_t listCount);
  193. extern int publish_qrcodeimage_add(struct mosquitto *mosq, QrCode_List *qrCodeList, uint8_t listCount);
  194. extern int publish_view_remove(struct mosquitto *mosq, Text_List *textList, uint8_t textListCount,
  195. Image_List *imageList, uint8_t imageListCount,
  196. Video_List *videoList, uint8_t videoListCount,
  197. QrCode_List *qrCodeList, uint8_t qrCodeListCount);
  198. extern int publish_clear_screen(struct mosquitto *mosq);
  199. extern int publish_audio_volume(struct mosquitto *mosq, uint8_t volume);
  200. extern int publish_trigger_report_status(struct mosquitto *mosq);
  201. #endif /* MODULE_MQTTCLIENT_H_ */