123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- /*
- * Module_MqttClient.h
- *
- * Created on: 2021/11/6
- * Author: folus
- */
- #ifndef MODULE_MQTTCLIENT_H_
- #define MODULE_MQTTCLIENT_H_
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <sys/time.h>
- #include <sys/timeb.h>
- #include <sys/types.h>
- #include <sys/ioctl.h>
- #include <sys/socket.h>
- #include <sys/ipc.h>
- #include <sys/shm.h>
- #include <sys/mman.h>
- #include <linux/wireless.h>
- #include <arpa/inet.h>
- #include <netinet/in.h>
- #include <dirent.h>
- #include <sys/prctl.h>
- #include <unistd.h>
- #include <stdarg.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <fcntl.h>
- #include <termios.h>
- #include <errno.h>
- #include <errno.h>
- #include <string.h>
- #include <time.h>
- #include <ctype.h>
- #include <ifaddrs.h>
- #include <stdbool.h>
- #include <stddef.h>
- #include <stdint.h>
- #include <signal.h>
- #include "json-c/json.h"
- #include "mosquitto.h"
- #define TEST_MODE
- #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)
- #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)
- #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)
- enum TIMER_IDX
- {
- TMR_IDX_0=0,
- TMR_IDX_1,
- TMR_IDX_2,
- TMR_IDX_3,
- TMR_IDX_4,
- TMR_IDX_5,
- TMR_IDX_CNT
- };
- enum GUN_TYPE
- {
- GUN_TYPE_UNKNOWN=0,
- GUN_TYPE_CHAdeMO,
- GUN_TYPE_CCS,
- GUN_TYPE_GBT,
- GUN_TYPE_DO,
- GUN_TYPE_AC
- };
- enum SWITCH_STS
- {
- OFF=0,
- ON
- };
- enum BOOLEAN_STS
- {
- NO=0,
- YES
- };
- enum QOS_TYPE
- {
- QOS_ONLY_TX=0,
- QOS_ENSURE_BROKER,
- QOS_ENSURE_SUBSCRIBE
- };
- enum RETAIN_TYPE
- {
- RETAIN_NO=0,
- RETAIN_YES
- };
- typedef struct TEXT_LIST
- {
- uint16_t textviewIndex;
- char textString[256];
- char textFont[32];
- char textStyle[32];
- uint8_t textSize;
- uint16_t layout_x;
- uint16_t layout_y;
- }Text_List;
- typedef struct IMAGE_LIST
- {
- uint16_t imageviewIndex;
- uint16_t imgsrc_addr;
- uint16_t layout_x;
- uint16_t layout_y;
- uint16_t width;
- uint16_t height;
- }Image_List;
- typedef struct VIDEO_LIST
- {
- uint16_t videoviewIndex;
- uint16_t videosrc_addr;
- uint16_t layout_x;
- uint16_t layout_y;
- uint16_t width;
- uint16_t height;
- }Video_List;
- typedef struct QRCODE_LIST
- {
- uint16_t qrCodeIndex;
- int8_t qrCodeContent[512];
- int8_t errorCorrection[8];
- uint16_t layout_x;
- uint16_t layout_y;
- uint16_t width;
- uint16_t height;
- }QrCode_List;
- #define ARRAY_SIZE(A) (sizeof(A) / sizeof(A[0]))
- #define is_error(ptr) ((unsigned long)ptr > (unsigned long)-4000L)
- #define BROKER_PORT 1883
- #define BROKER_ADDRESS "192.168.0.10"
- #define TIMEOUT_KEEPALIVE 60
- #define LOGIN_USER NULL
- #define LOGIN_PASSWD NULL
- #define PASS 1
- #define FAIL -1
- #define PROFILE_CONNECT_TIMEOUT "connect_timeout"
- #define OTA_TYPE_UI "ota_ui"
- #define OTA_TYPE_APK "ota_apk"
- #define OTA_TYPE_SDCARD "ota_sdcard"
- #define FONT_STYLE_NORMAL "normal"
- #define FONT_STYLE_BOLD "bold"
- #define FONT_STYLE_ITALIC "italic"
- #define FONT_STYLE_BOLD_ITALIC "bold_italic"
- #define FONT_ARIAL "Arial"
- enum BRIGHTNESS_LEVEL
- {
- BRIGHTNESS_LEVEL_0=0,
- BRIGHTNESS_LEVEL_1,
- BRIGHTNESS_LEVEL_2,
- BRIGHTNESS_LEVEL_3,
- BRIGHTNESS_LEVEL_4,
- BRIGHTNESS_LEVEL_5,
- BRIGHTNESS_LEVEL_6,
- BRIGHTNESS_LEVEL_7,
- BRIGHTNESS_LEVEL_8,
- BRIGHTNESS_LEVEL_9,
- BRIGHTNESS_LEVEL_10,
- BRIGHTNESS_LEVEL_11,
- BRIGHTNESS_LEVEL_AUTO,
- };
- enum FONT_SIZE
- {
- FONT_SIZE_8PX=8,
- FONT_SIZE_10PX=10,
- FONT_SIZE_12PX=12,
- FONT_SIZE_14PX=14,
- FONT_SIZE_16PX=16,
- FONT_SIZE_20PX=20,
- FONT_SIZE_24PX=24,
- FONT_SIZE_34PX=34,
- FONT_SIZE_48PX=48,
- FONT_SIZE_60PX=60,
- FONT_SIZE_96PX=96,
- };
- struct ClientInfo
- {
- int8_t verHW[32];
- int8_t verFW_OS[32];
- int8_t verFW_APK[32];
- int8_t verFW_UI[32];
- int8_t macAddr[32];
- int8_t orientation[32];
- }clientInfo;
- extern int StoreLogMsg(const char *fmt, ...);
- extern int publish_data(struct mosquitto *mosq, char *topic, char *outputStr);
- extern int publish_profile(struct mosquitto *mosq, char *parameter, char *value);
- extern int publish_upgrade(struct mosquitto *mosq, char *otaType, char *url, char *checksum, char *verInfo);
- extern int publish_restart(struct mosquitto *mosq, uint8_t isHardReset);
- extern int publish_power_saving(struct mosquitto *mosq, uint8_t isSleep);
- extern int publish_back_dimming(struct mosquitto *mosq, uint8_t lightLevel);
- extern int publish_timesync(struct mosquitto *mosq);
- extern int publish_textview_add(struct mosquitto *mosq, Text_List *textList, uint8_t listCount);
- extern int publish_imageview_add(struct mosquitto *mosq, Image_List *imageList, uint8_t listCount);
- extern int publish_videoview_add(struct mosquitto *mosq, Video_List *videoList, uint8_t listCount);
- extern int publish_qrcodeimage_add(struct mosquitto *mosq, QrCode_List *qrCodeList, uint8_t listCount);
- extern int publish_view_remove(struct mosquitto *mosq, Text_List *textList, uint8_t textListCount,
- Image_List *imageList, uint8_t imageListCount,
- Video_List *videoList, uint8_t videoListCount,
- QrCode_List *qrCodeList, uint8_t qrCodeListCount);
- extern int publish_clear_screen(struct mosquitto *mosq);
- extern int publish_audio_volume(struct mosquitto *mosq, uint8_t volume);
- extern int publish_trigger_report_status(struct mosquitto *mosq);
- #endif /* MODULE_MQTTCLIENT_H_ */
|