Browse Source

[Add][AX80][Module_LcmControl_Wistron]

2022.04.08 / Folus Wen

Actions:
1. Add Module_LcmControl_Wistron.

Files:
1. As follow commit history

Image version: D0.01.XX.XXXX.XX
Image checksum: XXXXXXXX

Hardware PWB P/N : XXXXXXX
Hardware Version : XXXXXXX
FolusWen 3 years ago
parent
commit
56daeb8fbf

+ 336 - 0
EVSE/Projects/AX80/Apps/LCM_Wistron/LcmCommandDriver.c

@@ -0,0 +1,336 @@
+/*
+ * LcmCommandDriver.c
+ *
+ *  Created on: 2022/3/31
+ *      Author: folus
+ */
+
+#include "Module_LcmControl_Wistron.h"
+
+/**
+ *
+ * @param mosq
+ * @param topic
+ * @param outputStr
+ * @return
+ */
+int publish_data(struct mosquitto *mosq, char *topic, char *outputStr)
+{
+	int result;
+
+	result = mosquitto_publish(mosq, NULL, topic, strlen(outputStr), outputStr, QOS_ENSURE_BROKER, RETAIN_YES);
+
+	if(result != MOSQ_ERR_SUCCESS)DEBUG_ERROR("Publish %s error publishing: %s\n", topic, mosquitto_strerror(result));
+
+	return (result != MOSQ_ERR_SUCCESS)?FAIL:PASS;
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_profile(struct mosquitto *mosq, char *parameter, char *value)
+{
+	json_object *payload = json_object_new_object();
+	char outputStr[2048]={0};
+
+	json_object_object_add(payload, parameter, json_object_new_string(value));
+
+	sprintf(outputStr, "%s", json_object_to_json_string_ext(payload, JSON_C_TO_STRING_PLAIN));
+	json_object_put(payload);
+
+	return publish_data(mosq, "client/profile", outputStr);
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_upgrade(struct mosquitto *mosq, char *otaType, char *url, char *checksum, char *verInfo)
+{
+	json_object *payload = json_object_new_object();
+	char outputStr[2048]={0};
+
+	json_object_object_add(payload, "task_name", json_object_new_string(otaType));
+
+	if((strstr(otaType, OTA_TYPE_APK) != NULL) || (strstr(otaType, OTA_TYPE_UI) != NULL))
+		json_object_object_add(payload, "ftp server", json_object_new_string(url));
+
+	if(strstr(otaType, OTA_TYPE_UI) != NULL)
+	{
+		json_object_object_add(payload, "file_checksum", json_object_new_string(checksum));
+		json_object_object_add(payload, "version_info", json_object_new_string(verInfo));
+	}
+
+	sprintf(outputStr, "%s", json_object_to_json_string_ext(payload, JSON_C_TO_STRING_PLAIN));
+	json_object_put(payload);
+
+	return publish_data(mosq, "client/command", outputStr);
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_restart(struct mosquitto *mosq, uint8_t isHardReset)
+{
+	json_object *payload = json_object_new_object();
+	char outputStr[2048]={0};
+
+	json_object_object_add(payload, "task_name", json_object_new_string(isHardReset?"restart":"reset"));
+
+	sprintf(outputStr, "%s", json_object_to_json_string_ext(payload, JSON_C_TO_STRING_PLAIN));
+	json_object_put(payload);
+
+	return publish_data(mosq, "client/command", outputStr);
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_power_saving(struct mosquitto *mosq, uint8_t isSleep)
+{
+	json_object *payload = json_object_new_object();
+	char outputStr[2048]={0};
+
+	json_object_object_add(payload, "task_name", json_object_new_string("power_saving"));
+	json_object_object_add(payload, "mode", json_object_new_string(isSleep?"1":"0"));
+
+	sprintf(outputStr, "%s", json_object_to_json_string_ext(payload, JSON_C_TO_STRING_PLAIN));
+	json_object_put(payload);
+
+	return publish_data(mosq, "client/command", outputStr);
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_back_dimming(struct mosquitto *mosq, uint8_t lightLevel)
+{
+	json_object *payload = json_object_new_object();
+	char outputStr[2048]={0};
+	char buf[8];
+
+	json_object_object_add(payload, "task_name", json_object_new_string("backlight"));
+
+	sprintf(buf, "%d", lightLevel);
+	json_object_object_add(payload, "brightness", json_object_new_string(buf));
+
+	sprintf(outputStr, "%s", json_object_to_json_string_ext(payload, JSON_C_TO_STRING_PLAIN));
+	json_object_put(payload);
+
+	return publish_data(mosq, "client/command", outputStr);
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_timesync(struct mosquitto *mosq)
+{
+	char outputStr[64]={0};
+	time_t CurrentTime;
+	struct tm *tm;
+	struct timeval tv;
+
+	CurrentTime = time(NULL);
+	tm=localtime(&CurrentTime);
+	gettimeofday(&tv, NULL); // get microseconds, 10^-6
+
+	sprintf(outputStr,"%04d-%02d-%02dT%02d:%02d:%02d+00:00", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec);
+
+	return publish_data(mosq, "client/timesync", outputStr);
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_textview_add(struct mosquitto *mosq, Text_List *textList, uint8_t listCount)
+{
+	json_object *payload = json_object_new_array();
+	char outputStr[2048]={0};
+
+	for(int idx=0;idx<listCount;idx++)
+	{
+		json_object *textview = json_object_new_object();
+		char buf[32];
+
+		sprintf(buf, "%d", textList[idx].textviewIndex);
+		json_object_object_add(textview, "textviewIndex", json_object_new_string(buf));
+
+		json_object_object_add(textview, "textString", json_object_new_string(textList[idx].textString));
+		json_object_object_add(textview, "textFont", json_object_new_string(textList[idx].textFont));
+		json_object_object_add(textview, "textStyle", json_object_new_string(textList[idx].textStyle));
+
+		sprintf(buf, "%d", textList[idx].textSize);
+		json_object_object_add(textview, "textSize", json_object_new_string(buf));
+		sprintf(buf, "%d", textList[idx].layout_x);
+		json_object_object_add(textview, "layout_x", json_object_new_string(buf));
+		sprintf(buf, "%d", textList[idx].layout_y);
+		json_object_object_add(textview, "layout_y", json_object_new_string(buf));
+
+		json_object_array_add(payload, textview);
+	}
+
+	sprintf(outputStr, "%s", json_object_to_json_string_ext(payload, JSON_C_TO_STRING_PLAIN));
+	json_object_put(payload);
+
+	return publish_data(mosq, "client/layout/textview", outputStr);
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_imageview_add(struct mosquitto *mosq, Image_List *imageList, uint8_t listCount)
+{
+	json_object *payload = json_object_new_array();
+	char outputStr[2048]={0};
+
+	for(int idx=0;idx<listCount;idx++)
+	{
+		json_object *imageview = json_object_new_object();
+		char buf[32];
+
+		sprintf(buf, "%d", imageList[idx].imageviewIndex);
+		json_object_object_add(imageview, "imageviewIndex", json_object_new_string(buf));
+
+		sprintf(buf, "%d", imageList[idx].imgsrc_addr);
+		json_object_object_add(imageview, "imgsrc_addr", json_object_new_string(buf));
+
+		sprintf(buf, "%d", imageList[idx].layout_x);
+		json_object_object_add(imageview, "layout_x", json_object_new_string(buf));
+
+		sprintf(buf, "%d", imageList[idx].layout_y);
+		json_object_object_add(imageview, "layout_y", json_object_new_string(buf));
+
+		sprintf(buf, "%d", imageList[idx].width);
+		json_object_object_add(imageview, "width", json_object_new_string(buf));
+
+		sprintf(buf, "%d", imageList[idx].height);
+		json_object_object_add(imageview, "height", json_object_new_string(buf));
+
+		json_object_array_add(payload, imageview);
+	}
+
+	sprintf(outputStr, "%s", json_object_to_json_string_ext(payload, JSON_C_TO_STRING_PLAIN));
+	json_object_put(payload);
+
+	return publish_data(mosq, "client/layout/imageview", outputStr);
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_videoview_add(struct mosquitto *mosq, Video_List *videoList, uint8_t listCount)
+{
+	json_object *payload = json_object_new_array();
+	char outputStr[2048]={0};
+
+	for(int idx=0;idx<listCount;idx++)
+	{
+		json_object *imageview = json_object_new_object();
+		char buf[32];
+
+		sprintf(buf, "%d", videoList[idx].videoviewIndex);
+		json_object_object_add(imageview, "videoviewIndex", json_object_new_string(buf));
+
+		sprintf(buf, "%d", videoList[idx].videosrc_addr);
+		json_object_object_add(imageview, "videosrc_addr", json_object_new_string(buf));
+
+		sprintf(buf, "%d", videoList[idx].layout_x);
+		json_object_object_add(imageview, "layout_x", json_object_new_string(buf));
+
+		sprintf(buf, "%d", videoList[idx].layout_y);
+		json_object_object_add(imageview, "layout_y", json_object_new_string(buf));
+
+		sprintf(buf, "%d", videoList[idx].width);
+		json_object_object_add(imageview, "width", json_object_new_string(buf));
+
+		sprintf(buf, "%d", videoList[idx].height);
+		json_object_object_add(imageview, "height", json_object_new_string(buf));
+
+		json_object_array_add(payload, imageview);
+	}
+
+	sprintf(outputStr, "%s", json_object_to_json_string_ext(payload, JSON_C_TO_STRING_PLAIN));
+	json_object_put(payload);
+
+	return publish_data(mosq, "client/layout/videoview", outputStr);
+}
+
+/**
+ *
+ * @param mosq
+ */
+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)
+{
+	json_object *payload = json_object_new_object();
+	json_object *text = json_object_new_array();
+	json_object *image = json_object_new_array();
+	json_object *video = json_object_new_array();
+
+	char outputStr[2048]={0};
+
+	// Remove text view
+	for(int idx=0;idx<textListCount;idx++)
+	{
+		json_object *textview = json_object_new_object();
+		char buf[8];
+		sprintf(buf, "%d", textList[idx].textviewIndex);
+		json_object_object_add(textview, "textviewIndex", json_object_new_string(buf));
+
+		json_object_array_add(text, textview);
+	}
+	json_object_object_add(payload, "rm_textview_list", text);
+
+	// Remove image view
+	for(int idx=0;idx<imageListCount;idx++)
+	{
+		json_object *imageview = json_object_new_object();
+		char buf[8];
+		sprintf(buf, "%d", imageList[idx].imageviewIndex);
+		json_object_object_add(imageview, "imageviewIndex", json_object_new_string(buf));
+
+		json_object_array_add(image, imageview);
+	}
+	json_object_object_add(payload, "rm_imageview_list", image);
+
+	// Remove video view
+	for(int idx=0;idx<videoListCount;idx++)
+	{
+		json_object *videoview = json_object_new_object();
+		char buf[8];
+		sprintf(buf, "%d", videoList[idx].videoviewIndex);
+		json_object_object_add(videoview, "videoviewIndex", json_object_new_string(buf));
+
+		json_object_array_add(video, videoview);
+	}
+	json_object_object_add(payload, "rm_videoview_list", video);
+
+	sprintf(outputStr, "%s", json_object_to_json_string_ext(payload, JSON_C_TO_STRING_PLAIN));
+	json_object_put(payload);
+
+	return publish_data(mosq, "client/layout/remove", outputStr);
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_clear_screen(struct mosquitto *mosq)
+{
+	json_object *payload = json_object_new_object();
+	char outputStr[2048]={0};
+
+	json_object_object_add(payload, "task_name", json_object_new_string("clear_screen"));
+
+	sprintf(outputStr, "%s", json_object_to_json_string_ext(payload, JSON_C_TO_STRING_PLAIN));
+	json_object_put(payload);
+
+	return publish_data(mosq, "client/command", outputStr);
+}

+ 1070 - 0
EVSE/Projects/AX80/Apps/LCM_Wistron/Module_LcmControl_Wistron.c

@@ -0,0 +1,1070 @@
+/*
+ * Module_LcmControl_Wistron.c
+ *
+ *  Created on: 2021/11/6
+ *      Author: folus
+ */
+
+#include "Module_LcmControl_Wistron.h"
+#include "define.h"
+
+struct SysConfigAndInfo			*ShmSysConfigAndInfo;
+struct StatusCodeData 			*ShmStatusCodeData;
+struct OCPP16Data				*ShmOCPP16Data;
+struct OCPP20Data				*ShmOCPP20Data;
+
+ParsingRatedCur modelnameInfo	= {0};
+uint8_t gunType[4] 				= {0};
+
+struct timespec					timer[TMR_IDX_CNT];
+
+/**
+ *
+ * @param fmt
+ * @return
+ */
+int StoreLogMsg(const char *fmt, ...)
+{
+	char Buf[4096+256];
+	char buffer[4096];
+	time_t CurrentTime;
+	struct tm *tm;
+	struct timeval tv;
+	va_list args;
+
+	va_start(args, fmt);
+	int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
+	va_end(args);
+
+	memset(Buf,0,sizeof(Buf));
+	CurrentTime = time(NULL);
+	tm=localtime(&CurrentTime);
+	gettimeofday(&tv, NULL); // get microseconds, 10^-6
+
+	sprintf(Buf,"echo -n \'[%04d.%02d.%02d %02d:%02d:%02d.%03ld]%s\' >>  /Storage/SystemLog/[%04d.%02d]Module_LcmControl_Wistron_Log",
+			tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,(tv.tv_usec/1000),
+			buffer,
+			tm->tm_year+1900,tm->tm_mon+1);
+
+#ifdef SystemLogMessage
+	system((const char*)Buf);
+#endif
+
+#ifdef ConsloePrintLog
+	printf("[%04d.%02d.%02d %02d:%02d:%02d.%03ld]%s", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,(tv.tv_usec/1000), buffer);
+#endif
+
+	return rc;
+}
+
+/**
+ *
+ * @param data
+ * @param length
+ * @return
+ */
+uint32_t crc32(uint8_t *data, uint32_t length)
+{
+	uint32_t crc=0xFFFFFFFF;
+
+	for(size_t i=0;i<length;i++)
+	{
+		char ch=data[i];
+		for(size_t j=0;j<8;j++)
+		{
+			uint32_t b=(ch^crc)&1;
+
+			crc>>=1;
+
+			if(b) crc=crc^0xEDB88320;
+
+			ch>>=1;
+		}
+	}
+
+	return ~crc;
+}
+
+/**
+ *
+ * @param filename
+ * @return
+ */
+uint32_t getFileCrc32(char *filename)
+{
+	uint32_t result = 0;
+
+	int fd = open(filename, O_RDONLY);
+    if(fd < 0)
+    {
+        DEBUG_ERROR("Can not open file %s\n", filename);
+    }
+    else
+    {
+    	struct stat st;
+		stat(filename, &st);
+		uint8_t data[st.st_size];
+
+		if(read(fd,data,st.st_size) == st.st_size)
+		{
+			result = crc32(data, st.st_size);
+		}
+
+		close(fd);
+    }
+
+	return result;
+}
+
+/**
+ *
+ * @param timer
+ */
+void refreshStartTimer(struct timespec *timer)
+{
+	clock_gettime(CLOCK_MONOTONIC, timer);
+}
+
+/**
+ *
+ * @param timer
+ * @return
+ */
+int getDiffSecNow(struct timespec timer)
+{
+	struct timespec timerNow;
+
+	clock_gettime(CLOCK_MONOTONIC, &timerNow);
+
+	return (int)((((unsigned long)(timerNow.tv_sec - timer.tv_sec) * 1000) + ((unsigned long)((timerNow.tv_nsec / 1000000) - (timer.tv_nsec / 1000000))))/1000);
+}
+
+/**
+ *
+ * @return
+ */
+int InitShareMemory()
+{
+	int result = PASS;
+	int MeterSMId;
+
+	//Initial ShmSysConfigAndInfo
+	if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
+    {
+		DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
+		result = FAIL;
+	}
+    else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
+    {
+    	DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
+    	result = FAIL;
+   	}
+    else
+    {}
+
+   	// Initial ShmStatusCodeData
+   	if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
+    {
+   		DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
+   		result = FAIL;
+	}
+    else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
+    {
+    	DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
+    	result = FAIL;
+   	}
+    else
+    {}
+
+	// Initial ShmOCPP16Data
+	if ((MeterSMId = shmget(ShmOcppModuleKey, sizeof(struct OCPP16Data), 0777)) < 0)
+	{
+		DEBUG_ERROR("shmget ShmOCPP16Data NG\n");
+		result = FAIL;
+	}
+	else if ((ShmOCPP16Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
+	{
+		DEBUG_ERROR("shmat ShmOCPP16Data NG\n");
+		result = FAIL;
+	}
+	else
+	{}
+
+	// Initial ShmOCPP20Data
+	if ((MeterSMId = shmget(ShmOcpp20ModuleKey, sizeof(struct OCPP20Data), 0777)) < 0)
+	{
+		DEBUG_ERROR("shmget ShmOCPP20Data NG\n");
+		result = FAIL;
+	}
+	else if ((ShmOCPP20Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
+	{
+		DEBUG_ERROR("shmat ShmOCPP20Data NG\n");
+		result = FAIL;
+	}
+	else
+	{}
+
+	// Parsing model name to get related info about charger
+	if(RatedCurrentParsing((char*)ShmSysConfigAndInfo->SysConfig.ModelName, &modelnameInfo) != -1)
+	{
+		DEBUG_INFO("Model name rated power: %d\n", modelnameInfo.ratedPower);
+		if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') &&
+		   ((ShmSysConfigAndInfo->SysConfig.ModelName[1]=='B') ||
+			(ShmSysConfigAndInfo->SysConfig.ModelName[1]=='K') ||
+			(ShmSysConfigAndInfo->SysConfig.ModelName[1]=='O'))
+		   ) // 'D' means DC
+		{
+			// DO series
+			for(int gun_index=0; gun_index<GENERAL_GUN_QUANTITY ; gun_index++)
+			{
+				gunType[gun_index] = GUN_TYPE_DO;
+
+				switch(modelnameInfo.ParsingInfo[gun_index].GunType)
+				{
+					case Gun_Type_Chademo:
+						DEBUG_INFO("Gun-%02d type: Cabinet CHAdeMO\n", gun_index);
+						break;
+					case Gun_Type_CCS_2:
+						DEBUG_INFO("Gun-%02d type: Cabinet CCS\n", gun_index);
+						break;
+					case Gun_Type_GB:
+						DEBUG_INFO("Gun-%02d type: Cabinet GBT\n", gun_index);
+						break;
+					case Gun_Type_AC:
+						DEBUG_INFO("Gun-%02d type: Cabinet AC\n", gun_index);
+						break;
+					default:
+						DEBUG_WARN("Gun-%02d type: Cabinet unknown\n", gun_index);
+						break;
+				}
+			}
+		}
+		else
+		{
+			for(int gun_index=0;gun_index<modelnameInfo.GetGunCount;gun_index++)
+			{
+				switch(modelnameInfo.ParsingInfo[gun_index].GunType)
+				{
+					case Gun_Type_Chademo:
+						gunType[gun_index] = GUN_TYPE_CHAdeMO;
+						DEBUG_INFO("Gun-%02d type: CHAdeMO\n", gun_index);
+						break;
+					case Gun_Type_CCS_2:
+						gunType[gun_index] = GUN_TYPE_CCS;
+						DEBUG_INFO("Gun-%02d type: CCS\n", gun_index);
+						break;
+					case Gun_Type_GB:
+						gunType[gun_index] = GUN_TYPE_GBT;
+						DEBUG_INFO("Gun-%02d type: GBT\n", gun_index);
+						break;
+					case Gun_Type_AC:
+						gunType[gun_index] = GUN_TYPE_AC;
+						DEBUG_INFO("Gun-%02d type: AC\n", gun_index);
+						break;
+					default:
+						DEBUG_WARN("Gun-%02d type: Unknown\n", gun_index);
+						break;
+				}
+			}
+		}
+	}
+	else
+	{
+		DEBUG_ERROR("Model name parsing fail.\n");
+		result = FAIL;
+	}
+
+	// Initial all timer
+	for(uint8_t idxTmr=0;idxTmr<TMR_IDX_CNT;idxTmr++)
+	{
+		refreshStartTimer(&timer[idxTmr]);
+	}
+
+    return result;
+}
+
+/**
+ *
+ * @param mosq
+ * @param userdata
+ * @param msg
+ * @return
+ */
+int on_message(struct mosquitto *mosq, void *userdata, const struct mosquitto_message *msg)
+{
+	json_object *payload;
+
+	payload = json_tokener_parse(msg->payload);
+	if(!is_error(payload))
+	{
+		/*
+		 *	TODO:
+		 *		1. Process message depend on receive topic
+		 *		2. Message maybe could define as JSON format
+		 */
+		if(strstr(msg->topic, "client/connect"))
+		{
+			DEBUG_INFO("HW_version: %s\n", json_object_get_string(json_object_object_get(payload, "HW_version")));
+			DEBUG_INFO("FW_version_OS: %s\n", json_object_get_string(json_object_object_get(payload, "FW_version_OS")));
+			DEBUG_INFO("FW_version_APK: %s\n", json_object_get_string(json_object_object_get(payload, "FW_version_APK")));
+			DEBUG_INFO("FW_version_UI: %s\n", json_object_get_string(json_object_object_get(payload, "FW_version_UI")));
+			DEBUG_INFO("MAC_addr: %s\n", json_object_get_string(json_object_object_get(payload, "MAC_addr")));
+			DEBUG_INFO("Orientation: %s\n", json_object_get_string(json_object_object_get(payload, "Orientation")));
+		}
+		else if(strstr(msg->topic, "client/touch"))
+		{
+			if(json_object_object_get(payload, "touchlist") != NULL)
+			{
+				for(int idx=0;idx<json_object_array_length(json_object_object_get(payload, "touchlist"));idx++)
+				{
+					DEBUG_INFO("Touch point-%d(%s-%s)=> x: %s, y: %s\n", idx,
+																  json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(payload, "touchlist"), idx), "obj_type")),
+																  json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(payload, "touchlist"), idx), "obj_onClick")),
+																  json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(payload, "touchlist"), idx), "touch_point_x")),
+																  json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(payload, "touchlist"), idx), "touch_point_y")));
+				}
+			}
+		}
+		else if(strstr(msg->topic, "client/info"))
+		{
+			if(json_object_object_get(payload, "status") != NULL)
+			{
+				switch(atoi(json_object_get_string(json_object_object_get(payload, "status"))))
+				{
+					case 1:
+						DEBUG_INFO("Status normal.\n");
+						break;
+					case 2:
+						DEBUG_INFO("Status downloading.\n");
+						break;
+					case 3:
+						DEBUG_INFO("Status uploading.\n");
+						break;
+					case 4:
+						DEBUG_INFO("Status reboot.\n");
+						break;
+					case 5:
+						DEBUG_INFO("Status reset.\n");
+						break;
+					default:
+						DEBUG_INFO("Unknown status.\n");
+						break;
+				}
+			}
+		}
+		else if(strstr(msg->topic, "client/profile") ||
+				strstr(msg->topic, "client/command") ||
+				strstr(msg->topic, "client/timesync") ||
+				strstr(msg->topic, "client/layout/textview") ||
+				strstr(msg->topic, "client/layout/imageview") ||
+				strstr(msg->topic, "client/layout/videoview") ||
+				strstr(msg->topic, "client/layout/remove"))
+		{
+			// Skip topic publish from CSU
+		}
+		else
+		{
+			DEBUG_INFO("Unknown topic: %s\n", msg->topic);
+			DEBUG_INFO("Unknown payload: %s\n", msg->payload);
+		}
+	}
+	else
+	{
+		DEBUG_WARN("Payload is not JSON format.\n");
+	}
+	json_object_put(payload);
+
+	return 0;
+}
+
+/**
+ *
+ * @param mosq
+ * @param obj
+ * @param reason_code
+ */
+void on_connect(struct mosquitto *mosq, void *obj, int reason_code)
+{
+	DEBUG_INFO("on_connect: %s\n", mosquitto_connack_string(reason_code));
+	if(reason_code != 0)mosquitto_disconnect(mosq);
+}
+
+/**
+ *
+ * @param mosq
+ * @param obj
+ * @param reason_code
+ */
+void on_disconnect(struct mosquitto *mosq, void *obj, int reason_code)
+{
+	DEBUG_INFO("on_disconnect: %s\n", mosquitto_connack_string(reason_code));
+	if(reason_code != 0)mosquitto_disconnect(mosq);
+}
+
+/**
+ *
+ * @param mosq
+ * @param obj
+ * @param mid
+ */
+void on_publish(struct mosquitto *mosq, void *obj, int mid)
+{}
+
+//==========================================================================
+// Page routine
+//==========================================================================
+/**
+ *
+ * @param targetChargingInfoData
+ */
+void page_Booting(struct ChargingInfoData *targetChargingInfoData)
+{
+	/*
+	 * 	TODO:
+	 * 	1. Page content
+	 */
+}
+
+/**
+ *
+ * @param targetChargingInfoData
+ */
+void page_Idle(struct ChargingInfoData *targetChargingInfoData)
+{
+	/*
+	 * 	TODO:
+	 * 	1. Page content
+	 */
+}
+
+/**
+ *
+ * @param targetChargingInfoData
+ */
+void page_Authorizing(struct ChargingInfoData *targetChargingInfoData)
+{
+	/*
+	 * 	TODO:
+	 * 	1. Page content
+	 */
+
+}
+
+/**
+ *
+ * @param targetChargingInfoData
+ */
+void page_Preparing(struct ChargingInfoData *targetChargingInfoData)
+{
+	/*
+	 * 	TODO:
+	 * 	1. Page content
+	 */
+}
+
+/**
+ *
+ * @param targetChargingInfoData
+ */
+void page_Charging(struct ChargingInfoData *targetChargingInfoData)
+{
+	/*
+	 * 	TODO:
+	 * 	1. Page content
+	 */
+}
+
+/**
+ *
+ * @param targetChargingInfoData
+ */
+void page_Terminating(struct ChargingInfoData *targetChargingInfoData)
+{
+	/*
+	 * 	TODO:
+	 * 	1. Page content
+	 */
+}
+
+/**
+ *
+ * @param targetChargingInfoData
+ */
+void page_Complete(struct ChargingInfoData *targetChargingInfoData)
+{
+	/*
+	 * 	TODO:
+	 * 	1. Page content
+	 */
+}
+
+/**
+ *
+ * @param targetChargingInfoData
+ */
+void page_Reservation(struct ChargingInfoData *targetChargingInfoData)
+{
+	/*
+	 * 	TODO:
+	 * 	1. Page content
+	 */
+}
+
+/**
+ *
+ * @param targetChargingInfoData
+ */
+void page_Maintain(struct ChargingInfoData *targetChargingInfoData)
+{
+	/*
+	 * 	TODO:
+	 * 	1. Page content
+	 */
+}
+
+/**
+ *
+ * @param targetChargingInfoData
+ */
+void page_Update(struct ChargingInfoData *targetChargingInfoData)
+{
+	/*
+	 * 	TODO:
+	 * 	1. Page content
+	 */
+}
+
+/**
+ *
+ * @param targetChargingInfoData
+ */
+void page_AlarmFault(struct ChargingInfoData *targetChargingInfoData)
+{
+	/*
+	 * 	TODO:
+	 * 	1. Page content
+	 */
+}
+
+/**
+ *
+ * @param targetChargingInfoData
+ */
+void page_Unknown(struct ChargingInfoData *targetChargingInfoData)
+{
+	/*
+	 * 	TODO:
+	 * 	1. Page content
+	 */
+}
+
+//==========================================================================
+// Command publish sample routine
+//==========================================================================
+/**
+ *
+ * @param mosq
+ */
+int publish_profile_sample(struct mosquitto *mosq)
+{
+	return publish_profile(mosq, PROFILE_CONNECT_TIMEOUT, "10000");
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_upgrade_sample(struct mosquitto *mosq)
+{
+	char url[128];
+	char chkCrc32[16];
+
+	sprintf(url, "ftp://ftpuser:ftppasswd@%s/mnt/dummy_Image.zip", BROKER_ADDRESS);
+
+	sprintf(chkCrc32, "0x%08X", getFileCrc32("/root/main"));
+
+	return publish_upgrade(mosq, OTA_TYPE_UI, url, chkCrc32, "V0.01");
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_restart_sample(struct mosquitto *mosq)
+{
+	return publish_restart(mosq, TRUE);
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_power_saving_sample(struct mosquitto *mosq)
+{
+	return publish_power_saving(mosq, TRUE);
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_back_dimming_sample(struct mosquitto *mosq)
+{
+	return publish_back_dimming(mosq, BRIGHTNESS_LEVEL_AUTO);
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_timesync_sample(struct mosquitto *mosq)
+{
+	return publish_timesync(mosq);
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_textview_add_sample(struct mosquitto *mosq)
+{
+	Text_List textList[2] = {0};
+
+	for(int idx=0;idx<ARRAY_SIZE(textList);idx++)
+	{
+		textList[idx].textviewIndex = idx;
+		sprintf(textList[idx].textString, "%08d", (rand()%99999999+10000000));
+		sprintf(textList[idx].textFont, FONT_ARIAL);
+		sprintf(textList[idx].textStyle, FONT_STYLE_NORMAL);
+		textList[idx].textSize = FONT_SIZE_20PX;
+		textList[idx].layout_x = (rand()%800+100);
+		textList[idx].layout_y = (rand()%800+100);
+	}
+
+	return publish_textview_add(mosq, textList, ARRAY_SIZE(textList));
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_imageview_add_sample(struct mosquitto *mosq)
+{
+	Image_List imageList[2] = {0};
+
+	for(int idx=0;idx<ARRAY_SIZE(imageList);idx++)
+	{
+		imageList[idx].imageviewIndex = idx;
+		imageList[idx].imgsrc_addr = (rand()%10+0);
+		imageList[idx].layout_x = (rand()%800+100);
+		imageList[idx].layout_y = (rand()%800+100);
+		imageList[idx].width = (rand()%800+100);
+		imageList[idx].height = (rand()%800+100);
+	}
+
+	return publish_imageview_add(mosq, imageList, ARRAY_SIZE(imageList));
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_videoview_add_sample(struct mosquitto *mosq)
+{
+	Video_List videoList[2] = {0};
+
+	for(int idx=0;idx<ARRAY_SIZE(videoList);idx++)
+	{
+		videoList[idx].videoviewIndex = idx;
+		videoList[idx].videosrc_addr = (rand()%10+0);
+		videoList[idx].layout_x = (rand()%800+100);
+		videoList[idx].layout_y = (rand()%800+100);
+		videoList[idx].width = (rand()%800+100);
+		videoList[idx].height = (rand()%800+100);
+	}
+
+	return publish_videoview_add(mosq, videoList, ARRAY_SIZE(videoList));
+}
+/**
+ *
+ * @param mosq
+ */
+int publish_view_remove_sample(struct mosquitto *mosq)
+{
+	Text_List textList[2] = {0};
+	Image_List imageList[2] = {0};
+	Video_List videoList[2] = {0};
+
+	// Remove text view
+	for(int idx=0;idx<ARRAY_SIZE(textList);idx++)
+	{
+		textList[idx].textviewIndex = idx;
+	}
+
+	// Remove image view
+	for(int idx=0;idx<ARRAY_SIZE(imageList);idx++)
+	{
+		imageList[idx].imageviewIndex = idx;
+	}
+
+	// Remove video view
+	for(int idx=0;idx<ARRAY_SIZE(videoList);idx++)
+	{
+		videoList[idx].videoviewIndex = idx;
+	}
+
+	return publish_view_remove(mosq, textList, ARRAY_SIZE(textList), imageList, ARRAY_SIZE(imageList), videoList, ARRAY_SIZE(videoList));
+}
+
+/**
+ *
+ * @param mosq
+ */
+int publish_clear_screen_sample(struct mosquitto *mosq)
+{
+	return publish_clear_screen(mosq);
+}
+
+/**
+ *
+ * @return
+ */
+int main(void)
+{
+	struct mosquitto *mosq;
+	int result;
+
+	//===========================================
+	// Initial share memory
+	//===========================================
+	if(InitShareMemory() == FAIL)
+	{
+		DEBUG_ERROR("InitShareMemory NG\n");
+
+		sleep(5);
+		return FAIL;
+	}
+	else
+	{
+		DEBUG_INFO("Share memory initial OK.\n");
+	}
+
+	//===========================================
+	// Start mosquitto broker
+	//===========================================
+	system("killall mosquitto");
+	sleep(1);
+	system("/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf -d");
+	DEBUG_INFO("Broker target: %s:%d\n", BROKER_ADDRESS, BROKER_PORT);
+
+	//===========================================
+	// Initialize mosquitto library
+	//===========================================
+	mosquitto_lib_init();
+
+	//===========================================
+	// Initialize subscriber callback
+	//===========================================
+	if(fork())
+	{
+		DEBUG_INFO("Initialize subscribe callback function.\n");
+		result = mosquitto_subscribe_callback(on_message,
+											  NULL,
+											  "client/#",
+											  QOS_ENSURE_BROKER,
+											  BROKER_ADDRESS,
+											  BROKER_PORT,
+											  NULL,
+											  TIMEOUT_KEEPALIVE,
+											  true,
+											  LOGIN_USER,
+											  LOGIN_PASSWD,
+											  NULL,
+											  NULL);
+		if(result)DEBUG_ERROR("Subscribe initialization error: %s\n", mosquitto_strerror(result));
+
+		return -1;
+	}
+
+	//===========================================
+	// Initialize publisher client instance
+	//===========================================
+	DEBUG_INFO("Initialize publisher from host side.\n");
+	mosq = mosquitto_new(NULL, true, NULL);
+	if(mosq == NULL)
+	{
+		DEBUG_ERROR("Publisher initialization error: Out of memory.\n");
+		return -1;
+	}
+	mosquitto_connect_callback_set(mosq, on_connect);
+	mosquitto_disconnect_callback_set(mosq, on_disconnect);
+	mosquitto_publish_callback_set(mosq, on_publish);
+
+	//===========================================
+	// Publisher connect to broker
+	//===========================================
+	DEBUG_INFO("Publisher connect to broker.\n");
+	result = mosquitto_connect(mosq, BROKER_ADDRESS, BROKER_PORT, TIMEOUT_KEEPALIVE);
+	if(result != MOSQ_ERR_SUCCESS)
+	{
+		mosquitto_destroy(mosq);
+		DEBUG_ERROR("Connect broker error: %s\n", mosquitto_strerror(result));
+		return -1;
+	}
+
+	//===========================================
+	// Publisher start loop
+	//===========================================
+	DEBUG_INFO("Publisher loop start.\n");
+	result = mosquitto_loop_start(mosq);
+	if(result != MOSQ_ERR_SUCCESS)
+	{
+		mosquitto_destroy(mosq);
+		DEBUG_ERROR("MQTT loop start initialization error: %s\n", mosquitto_strerror(result));
+		return -1;
+	}
+
+	DEBUG_INFO("Module_LcmControl_Wistron initialized.\n");
+
+	//===========================================
+	// Main loop
+	//===========================================
+	for(;;)
+	{
+#ifndef TEST_MODE
+		struct ChargingInfoData *targetChargingInfoData;
+		uint8_t tempIndex;
+		static struct PREVIOUS_DATA
+		{
+			uint8_t gun_selected;
+			uint8_t SystemStatus;
+		}previousData;
+
+		// Get selected gun info
+		switch(gunType[ShmSysConfigAndInfo->SysInfo.CurGunSelected])
+		{
+			case GUN_TYPE_CHAdeMO:
+				if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
+				{
+					tempIndex = ((ShmSysConfigAndInfo->SysInfo.CurGunSelected==2) ? 1: 0);
+				}
+				else
+				{
+					tempIndex = ShmSysConfigAndInfo->SysInfo.CurGunSelected;
+				}
+
+				for (int index = 0; index < CHAdeMO_QUANTITY; index++)
+				{
+					if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
+					{
+						targetChargingInfoData = &ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index];
+					}
+				}
+				break;
+
+			case GUN_TYPE_CCS:
+				if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
+				{
+					tempIndex = ((ShmSysConfigAndInfo->SysInfo.CurGunSelected==2) ? 1: 0);
+				}
+				else
+				{
+					tempIndex = ShmSysConfigAndInfo->SysInfo.CurGunSelected;
+				}
+
+				for (int index = 0; index < CCS_QUANTITY; index++)
+				{
+					if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
+					{
+						targetChargingInfoData = &ShmSysConfigAndInfo->SysInfo.CcsChargingData[index];
+					}
+				}
+				break;
+
+			case GUN_TYPE_GBT:
+				if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
+				{
+					tempIndex = ((ShmSysConfigAndInfo->SysInfo.CurGunSelected==2) ? 1: 0);
+				}
+				else
+				{
+					tempIndex = ShmSysConfigAndInfo->SysInfo.CurGunSelected;
+				}
+
+				for (int index = 0; index < GB_QUANTITY; index++)
+				{
+					if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
+					{
+						targetChargingInfoData = &ShmSysConfigAndInfo->SysInfo.GbChargingData[index];
+					}
+				}
+				break;
+
+			case GUN_TYPE_DO:
+				tempIndex = ShmSysConfigAndInfo->SysInfo.CurGunSelected;
+
+				for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
+				{
+					if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
+					{
+						targetChargingInfoData = &ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData;
+					}
+				}
+				break;
+
+			case GUN_TYPE_AC:
+				if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
+				{
+					tempIndex = 2;
+				}
+				else
+				{
+					tempIndex = ShmSysConfigAndInfo->SysInfo.CurGunSelected;
+				}
+
+				for (int index = 0; index < AC_QUANTITY; index++)
+				{
+					if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
+					{
+						targetChargingInfoData = &ShmSysConfigAndInfo->SysInfo.AcChargingData[index];
+					}
+				}
+
+				break;
+
+			case GUN_TYPE_UNKNOWN:
+			default:
+				break;
+		}
+
+		// If selected gun or system status changed, clear page all content
+		if((previousData.gun_selected != ShmSysConfigAndInfo->SysInfo.CurGunSelected) ||
+		   (previousData.SystemStatus != targetChargingInfoData->SystemStatus))
+		{
+			publish_clear_screen(mosq);
+			previousData.gun_selected = ShmSysConfigAndInfo->SysInfo.CurGunSelected;
+			previousData.SystemStatus = targetChargingInfoData->SystemStatus;
+		}
+
+		// Display page content depend on selected gun system status
+		switch(targetChargingInfoData->SystemStatus)
+		{
+			case SYS_MODE_BOOTING:
+				page_Booting(targetChargingInfoData);
+
+				break;
+
+			case SYS_MODE_IDLE:
+				page_Idle(targetChargingInfoData);
+
+				break;
+
+			case SYS_MODE_AUTHORIZING:
+				page_Authorizing(targetChargingInfoData);
+
+				break;
+
+			case SYS_MODE_PREPARING:
+				page_Preparing(targetChargingInfoData);
+				break;
+
+			case SYS_MODE_CHARGING:
+				page_Charging(targetChargingInfoData);
+				break;
+
+			case SYS_MODE_TERMINATING:
+				page_Terminating(targetChargingInfoData);
+				break;
+
+			case SYS_MODE_COMPLETE:
+				page_Complete(targetChargingInfoData);
+				break;
+
+			case SYS_MODE_RESERVATION:
+				page_Reservation(targetChargingInfoData);
+				break;
+
+			case SYS_MODE_MAINTAIN:
+				page_Maintain(targetChargingInfoData);
+				break;
+
+			case SYS_MODE_UPDATE:
+				page_Update(targetChargingInfoData);
+				break;
+
+			case SYS_MODE_ALARM:
+			case SYS_MODE_FAULT:
+				page_AlarmFault(targetChargingInfoData);
+				break;
+
+			default:
+				page_Unknown(targetChargingInfoData);
+				break;
+		}
+#else
+		// For test command
+		char cmd[128];
+
+		system("clear");
+		memset(cmd, 0x00, ARRAY_SIZE(cmd));
+		printf("\n ===== main menu ==================================");
+		printf("\n  1: publish_profile_sample.");
+		printf("\n  2: publish_upgrade_sample.");
+		printf("\n  3: publish_restart_sample.");
+		printf("\n  4: publish_power_saving_sample.");
+		printf("\n  5: publish_back_dimming_sample.");
+		printf("\n  6: publish_timesync.");
+		printf("\n  7: publish_textview_add_sample.");
+		printf("\n  8: publish_imageview_add_sample.");
+		printf("\n  9: publish_videoview_add_sample.");
+		printf("\n  10: publish_view_remove_sample.");
+		printf("\n  11: publish_clear_screen.");
+		printf("\n ==================================================");
+		printf("\n  Please input item to test: ");
+		scanf("%s", &cmd[0]);
+
+		switch(atoi(cmd))
+		{
+			case 1:
+				publish_profile_sample(mosq);
+				break;
+			case 2:
+				publish_upgrade_sample(mosq);
+				break;
+			case 3:
+				publish_restart_sample(mosq);
+				break;
+			case 4:
+				publish_power_saving_sample(mosq);
+				break;
+			case 5:
+				publish_back_dimming_sample(mosq);
+				break;
+			case 6:
+				publish_timesync_sample(mosq);
+				break;
+			case 7:
+				publish_textview_add_sample(mosq);
+				break;
+			case 8:
+				publish_imageview_add_sample(mosq);
+				break;
+			case 9:
+				publish_videoview_add_sample(mosq);
+				break;
+			case 10:
+				publish_view_remove_sample(mosq);
+				break;
+			case 11:
+				publish_clear_screen_sample(mosq);
+				break;
+		}
+#endif
+
+		usleep(500000);
+	}
+
+	mosquitto_lib_cleanup();
+
+	return -1;
+}

+ 204 - 0
EVSE/Projects/AX80/Apps/LCM_Wistron/Module_LcmControl_Wistron.h

@@ -0,0 +1,204 @@
+/*
+ * 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;
+
+#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,
+};
+
+
+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_view_remove(struct mosquitto *mosq, Text_List *textList, uint8_t textListCount,  Image_List *imageList, uint8_t imageListCount,  Video_List *videoList, uint8_t videoListCount);
+extern int publish_clear_screen(struct mosquitto *mosq);
+
+#endif /* MODULE_MQTTCLIENT_H_ */

+ 10 - 1
EVSE/Projects/AX80/Apps/Makefile

@@ -7,9 +7,11 @@ Lib_Module_Upgrade = "-L../../../Modularization" -lModule_Upgrade
 Lib_Module_RatedCurrent = "-L../../../Modularization" -lm -lModule_RatedCurrent
 Lib_SQLite3 = "-L../../../Modularization/ocppfiles" -lsqlite3
 Lib_JSONC = "-L../../../GPL/json-c-json-c-0.13.1-20180305/release/lib" -ljson-c
+Lib_MOSQUITTO = "-L../../../GPL/mosquitto-2.0.13/release/usr/local/lib" -lmosquitto
+
 
 all: CopyFile apps
-apps: CCS_Task Module_InternalComm_Task Module_FactoryConfig_Task Module_AlarmDetect_Task Module_CSU_Task Module_Speaker_Task Module_LcmControl_Task Module_ConfigTools_Task Module_Debug_Task Module_PowerSharing_Task Module_Cabinet Module_Dispenser
+apps: CCS_Task Module_InternalComm_Task Module_FactoryConfig_Task Module_AlarmDetect_Task Module_CSU_Task Module_Speaker_Task Module_LcmControl_Task Module_ConfigTools_Task Module_Debug_Task Module_PowerSharing_Task Module_Cabinet Module_Dispenser Module_LcmControl_Wistron_Task
 
 
 CCS_Task:
@@ -123,6 +125,13 @@ Module_Dispenser:
 	mv -f Module_Dispenser ../Images/root
 
 
+Module_LcmControl_Wistron_Task:
+	@echo "===== Module_LcmControl_Wistron_Task ==================================="
+	rm -f Module_LcmControl_Wistron
+	$(CC) -D $(Project) "-I../../../Modularization/ocppfiles/" "-I./" "-I../../" "-I../../../GPL/mosquitto-2.0.13/release/usr/local/include/" "-include../../../GPL/json-c-json-c-0.13.1-20180305/release/include/json-c/json.h" "-include../../../Modularization/Module_RatedCurrent.h" -O0  -Wall -fmessage-length=0 LCM_Wistron/LcmCommandDriver.c LCM_Wistron/Module_LcmControl_Wistron.c -lm -lrt ${Lib_JSONC} ${Lib_Module_RatedCurrent} ${Lib_MOSQUITTO} -o Module_LcmControl_Wistron
+	rm -f *.o	
+	mv -f Module_LcmControl_Wistron ../Images/root
+
 CopyFile: 
 	rm -rfv ../Images/root
 	mkdir -p ../Images/root