|
@@ -0,0 +1,1179 @@
|
|
|
+/*
|
|
|
+ * Module_LcmControl_Wistron.c
|
|
|
+ *
|
|
|
+ * Created on: 2021/11/6
|
|
|
+ * Author: folus
|
|
|
+ */
|
|
|
+
|
|
|
+#include "Module_LcmControl_Wistron.h"
|
|
|
+#include "../Log/log.h"
|
|
|
+#include "../ShareMemory/shmMem.h"
|
|
|
+#include "../Define/define.h"
|
|
|
+#include "../Config.h"
|
|
|
+#include "../SelectGun/SelectGun.h"
|
|
|
+#include "main.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;
|
|
|
+ data = malloc(st.st_size);
|
|
|
+
|
|
|
+ if(read(fd,data,st.st_size) == st.st_size)
|
|
|
+ {
|
|
|
+ result = crc32(data, st.st_size);
|
|
|
+ close(fd);
|
|
|
+ } else {
|
|
|
+ DEBUG_ERROR("Read file Error %d\n", st.st_size);
|
|
|
+ }
|
|
|
+
|
|
|
+ free(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ 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"))
|
|
|
+ {
|
|
|
+ sprintf((char*)clientInfo.verHW, "%s", json_object_get_string(json_object_object_get(payload, "HW_version")));
|
|
|
+ sprintf((char*)clientInfo.verFW_OS, "%s", json_object_get_string(json_object_object_get(payload, "FW_version_OS")));
|
|
|
+ sprintf((char*)clientInfo.verFW_APK, "%s", json_object_get_string(json_object_object_get(payload, "FW_version_APK")));
|
|
|
+ sprintf((char*)clientInfo.verFW_UI, "%s", json_object_get_string(json_object_object_get(payload, "FW_version_UI")));
|
|
|
+ sprintf((char*)clientInfo.macAddr, "%s", json_object_get_string(json_object_object_get(payload, "MAC_addr")));
|
|
|
+ sprintf((char*)clientInfo.orientation, "%s", json_object_get_string(json_object_object_get(payload, "Orientation")));
|
|
|
+
|
|
|
+ DEBUG_INFO("HW_version: %s\n", clientInfo.verHW);
|
|
|
+ DEBUG_INFO("FW_version_OS: %s\n", clientInfo.verFW_OS);
|
|
|
+ DEBUG_INFO("FW_version_APK: %s\n", clientInfo.verFW_APK);
|
|
|
+ DEBUG_INFO("FW_version_UI: %s\n", clientInfo.verFW_UI);
|
|
|
+ DEBUG_INFO("MAC_addr: %s\n", clientInfo.macAddr);
|
|
|
+ DEBUG_INFO("Orientation: %s\n", clientInfo.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;
|
|
|
+ case 6:
|
|
|
+ DEBUG_INFO("Status sleep.\n");
|
|
|
+ break;
|
|
|
+ case 255:
|
|
|
+ DEBUG_INFO("Status fault.\n");
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ DEBUG_INFO("Unknown status.\n");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(json_object_object_get(payload, "temperature") != NULL)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Temperature: %s.\n", json_object_get_string(json_object_object_get(payload, "temperature")));
|
|
|
+ }
|
|
|
+
|
|
|
+ if(json_object_object_get(payload, "cpu_temperatue") != NULL)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("CPU temperature: %s.\n", json_object_get_string(json_object_object_get(payload, "cpu_temperatue")));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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[300];
|
|
|
+ char chkCrc32[16];
|
|
|
+
|
|
|
+ sprintf(url, "ftp://ftpuser:ftppasswd@%s/mnt/img.zip", BROKER_ADDRESS);
|
|
|
+ sprintf(chkCrc32, "0x%08X", getFileCrc32("/mnt/img.zip"));
|
|
|
+ DEBUG_INFO("image file crc32: %s\n", chkCrc32);
|
|
|
+ DEBUG_INFO("url : %s\n", url);
|
|
|
+ return publish_upgrade(mosq, OTA_TYPE_APK, url, chkCrc32, "V0.01");
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @param mosq
|
|
|
+ */
|
|
|
+int publish_restart_sample(struct mosquitto *mosq)
|
|
|
+{
|
|
|
+ return publish_restart(mosq, FALSE);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @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)
|
|
|
+{
|
|
|
+ int i;
|
|
|
+ for (i = 0; i <= BRIGHTNESS_LEVEL_AUTO; i++) {
|
|
|
+ publish_back_dimming(mosq, i);
|
|
|
+ sleep(3);
|
|
|
+ }
|
|
|
+ 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++)
|
|
|
+ {
|
|
|
+ if (idx == 0) {
|
|
|
+ textList[idx].layout_x = 10;//(rand()%800+100);
|
|
|
+ textList[idx].layout_y = 10;//(rand()%800+100);
|
|
|
+ } else {
|
|
|
+ textList[idx].layout_x = (rand() % 800 + 100);;//(rand()%800+100);
|
|
|
+ textList[idx].layout_y = (rand() % 800 + 100);;//(rand()%800+100);
|
|
|
+ }
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ return publish_textview_add(mosq, textList, ARRAY_SIZE(textList));
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @param mosq
|
|
|
+ */
|
|
|
+int publish_imageview_add_sample(struct mosquitto *mosq)
|
|
|
+{
|
|
|
+ Image_List imageList[15] = {0};
|
|
|
+
|
|
|
+ for(int idx=0;idx<ARRAY_SIZE(imageList);idx++)
|
|
|
+ {
|
|
|
+ imageList[idx].imageviewIndex = idx;
|
|
|
+ imageList[idx].imgsrc_addr = idx;
|
|
|
+ imageList[idx].layout_x = (rand()%800+100);
|
|
|
+ imageList[idx].layout_y = (rand()%800+100);
|
|
|
+ imageList[idx].width = (rand()%100+150);
|
|
|
+ imageList[idx].height = (rand()%100+150);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 = 11;//(rand()%10+0);
|
|
|
+ videoList[idx].layout_x = 100;//(rand()%800+100);
|
|
|
+ videoList[idx].layout_y = 100;//(rand()%800+100);
|
|
|
+ videoList[idx].width = 900;//(rand()%800+100);
|
|
|
+ videoList[idx].height = 600;//(rand()%800+100);
|
|
|
+ }
|
|
|
+
|
|
|
+ return publish_videoview_add(mosq, videoList, ARRAY_SIZE(videoList));
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @param mosq
|
|
|
+ */
|
|
|
+int publish_qr_code_image(struct mosquitto *mosq)
|
|
|
+{
|
|
|
+ QrCode_List qrCodeList[2] = {0};
|
|
|
+
|
|
|
+ for(int idx=0;idx<ARRAY_SIZE(qrCodeList);idx++)
|
|
|
+ {
|
|
|
+ qrCodeList[idx].qrCodeIndex = idx;
|
|
|
+ sprintf((char*)qrCodeList[idx].qrCodeContent, "djsalkdjskjslkdjsalkdjslkdjsalkdjsal");
|
|
|
+ sprintf((char*)qrCodeList[idx].errorCorrection, "M");
|
|
|
+ qrCodeList[idx].layout_x = 100;//(rand()%800+100);
|
|
|
+ qrCodeList[idx].layout_y = 100;//(rand()%800+100);
|
|
|
+ qrCodeList[idx].width = (rand()%800+100);
|
|
|
+ qrCodeList[idx].height = (rand()%800+100);
|
|
|
+ }
|
|
|
+
|
|
|
+ return publish_qrcodeimage_add(mosq, qrCodeList, ARRAY_SIZE(qrCodeList));
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @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};
|
|
|
+ QrCode_List qrCodeList[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;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Remove qrCode view
|
|
|
+ for(int idx=0;idx<ARRAY_SIZE(qrCodeList);idx++)
|
|
|
+ {
|
|
|
+ qrCodeList[idx].qrCodeIndex = idx;
|
|
|
+ }
|
|
|
+
|
|
|
+ return publish_view_remove(mosq, textList, ARRAY_SIZE(textList), imageList, ARRAY_SIZE(imageList), videoList, ARRAY_SIZE(videoList), qrCodeList, ARRAY_SIZE(qrCodeList));
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @param mosq
|
|
|
+ */
|
|
|
+int publish_clear_screen_sample(struct mosquitto *mosq)
|
|
|
+{
|
|
|
+ return publish_clear_screen(mosq);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @param mosq
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+int publish_audio_volume_sample(struct mosquitto *mosq)
|
|
|
+{
|
|
|
+ return publish_audio_volume(mosq, 50);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @param mosq
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+int publish_trigger_report_status_sample(struct mosquitto *mosq)
|
|
|
+{
|
|
|
+ return publish_trigger_report_status(mosq);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+int main(void)
|
|
|
+{
|
|
|
+ struct mosquitto *mosq;
|
|
|
+ int result;
|
|
|
+
|
|
|
+ //===========================================
|
|
|
+ // Initial share memory
|
|
|
+ //===========================================
|
|
|
+ if(CreateAllCsuShareMemory() == FAIL)
|
|
|
+ {
|
|
|
+ DEBUG_ERROR("CreateAllCsuShareMemory NG\n");
|
|
|
+
|
|
|
+ sleep(5);
|
|
|
+ return FAIL;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_INFO("Share memory initial OK.\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ MappingGunChargingInfo("LCM Wistron Control Task");
|
|
|
+
|
|
|
+ //===========================================
|
|
|
+ // 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");
|
|
|
+ system("ifconfig lo up&");
|
|
|
+ //===========================================
|
|
|
+ // 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 12: publish_audio_volume.");
|
|
|
+ printf("\n 13: publish_trigger_report_status.");
|
|
|
+ printf("\n 14: publish_qr_code_image.");
|
|
|
+ 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;
|
|
|
+ case 12:
|
|
|
+ publish_audio_volume_sample(mosq);
|
|
|
+ break;
|
|
|
+ case 13:
|
|
|
+ publish_trigger_report_status_sample(mosq);
|
|
|
+ break;
|
|
|
+ case 14:
|
|
|
+ publish_qr_code_image(mosq);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+#endif
|
|
|
+
|
|
|
+ usleep(500000);
|
|
|
+ }
|
|
|
+
|
|
|
+ mosquitto_lib_cleanup();
|
|
|
+
|
|
|
+ return -1;
|
|
|
+}
|