WebService.c 73 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242
  1. #include <sys/time.h>
  2. #include <sys/timeb.h>
  3. #include <sys/types.h>
  4. #include <sys/stat.h>
  5. #include <sys/types.h>
  6. #include <sys/ioctl.h>
  7. #include <sys/socket.h>
  8. #include <sys/ipc.h>
  9. #include <sys/shm.h>
  10. #include <sys/shm.h>
  11. #include <sys/mman.h>
  12. #include <linux/wireless.h>
  13. #include <arpa/inet.h>
  14. #include <netinet/in.h>
  15. #include <unistd.h>
  16. #include <stdarg.h>
  17. #include <stdio.h> /*標準輸入輸出定義*/
  18. #include <stdlib.h> /*標準函數庫定義*/
  19. #include <unistd.h> /*Unix 標準函數定義*/
  20. #include <fcntl.h> /*檔控制定義*/
  21. #include <termios.h> /*PPSIX 終端控制定義*/
  22. #include <errno.h> /*錯誤號定義*/
  23. #include <errno.h>
  24. #include <string.h>
  25. #include <time.h>
  26. #include <ctype.h>
  27. #include <ifaddrs.h>
  28. #include "../Projects/define.h"
  29. #include "json.h"
  30. //#include <json-c/json.h>
  31. #include <math.h>
  32. #define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
  33. #define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
  34. #define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
  35. #define Debug
  36. #define SystemLogMessage
  37. #define ARRAY_SIZE(A) (sizeof(A) / sizeof(A[0]))
  38. #define PASS 1
  39. #define FAIL -1
  40. struct SysConfigAndInfo *ShmSysConfigAndInfo;
  41. struct StatusCodeData *ShmStatusCodeData;
  42. void trim(char *s);
  43. int mystrcmp(char *p1, char *p2);
  44. void substr(char *dest, const char* src, unsigned int start, unsigned int cnt);
  45. void split(char **arr, char *str, const char *del);
  46. #ifdef SystemLogMessage
  47. int StoreLogMsg(const char *fmt, ...) {
  48. char Buf[4096 + 256];
  49. char buffer[4096];
  50. time_t CurrentTime;
  51. struct tm *tm;
  52. va_list args;
  53. va_start(args, fmt);
  54. int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
  55. va_end(args);
  56. memset(Buf, 0, sizeof(Buf));
  57. CurrentTime = time(NULL);
  58. tm = localtime(&CurrentTime);
  59. sprintf(Buf,
  60. "echo \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
  61. tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour,
  62. tm->tm_min, tm->tm_sec, buffer, tm->tm_year + 1900, tm->tm_mon + 1);
  63. system(Buf);
  64. #ifdef Debug
  65. printf("[%04d.%02d.%02d %02d:%02d:%02d] - %s", tm->tm_year + 1900,
  66. tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec,
  67. buffer);
  68. #endif
  69. return rc;
  70. }
  71. #endif
  72. int DiffTimeb(struct timeb ST, struct timeb ET) {
  73. //return milli-second
  74. unsigned int StartTime, StopTime;
  75. StartTime = (unsigned int) ST.time;
  76. StopTime = (unsigned int) ET.time;
  77. return (StopTime - StartTime) * 1000 + ET.millitm - ST.millitm;
  78. }
  79. //=================================
  80. // Common routine
  81. //=================================
  82. void trim(char *s) {
  83. int i = 0, j, k, l = 0;
  84. while ((s[i] == ' ') || (s[i] == '\t') || (s[i] == '\n'))
  85. i++;
  86. j = strlen(s) - 1;
  87. while ((s[j] == ' ') || (s[j] == '\t') || (s[j] == '\n'))
  88. j--;
  89. if (i == 0 && j == strlen(s) - 1) {
  90. } else if (i == 0)
  91. s[j + 1] = '\0';
  92. else {
  93. for (k = i; k <= j; k++)
  94. s[l++] = s[k];
  95. s[l] = '\0';
  96. }
  97. }
  98. int mystrcmp(char *p1, char *p2) {
  99. while (*p1 == *p2) {
  100. if (*p1 == '\0' || *p2 == '\0')
  101. break;
  102. p1++;
  103. p2++;
  104. }
  105. if (*p1 == '\0' && *p2 == '\0')
  106. return (PASS);
  107. else
  108. return (FAIL);
  109. }
  110. void substr(char *dest, const char* src, unsigned int start, unsigned int cnt) {
  111. strncpy(dest, src + start, cnt);
  112. dest[cnt] = 0;
  113. }
  114. void split(char **arr, char *str, const char *del) {
  115. char *s = strtok(str, del);
  116. while (s != NULL) {
  117. *arr++ = s;
  118. s = strtok(NULL, del);
  119. }
  120. }
  121. int ConnectorType(char* connector){
  122. int* result;
  123. if(strcmp(connector, "0") == 0){
  124. result= 0;
  125. }
  126. else if(strcmp(connector, "1") == 0 || strcmp(connector, "2") == 0 || strcmp(connector, "3") == 0 || strcmp(connector, "4") == 0 || strcmp(connector, "U") == 0 || strcmp(connector, "E") == 0){
  127. result= 1;//CCS
  128. }
  129. else if(strcmp(connector, "5") == 0 || strcmp(connector, "6") == 0 || strcmp(connector, "G") == 0){
  130. result= 2;//GB
  131. }
  132. else if(strcmp(connector, "J") == 0){
  133. result= 3;//CHAdeMO
  134. }
  135. else{
  136. }
  137. return result;
  138. }
  139. int ModelType(char* type,char* network){
  140. int result=0;
  141. if(strcmp(type, "A") == 0){
  142. if(strcmp(network, "0") == 0 || strcmp(network, "R") == 0 || strcmp(network, "B") == 0){
  143. result=0;
  144. }
  145. else if(strcmp(network, "E") == 0 || strcmp(network, "W") == 0 || strcmp(network, "T") == 0 || strcmp(network, "U") == 0){
  146. result=1;
  147. }
  148. }
  149. else if(strcmp(type, "D") == 0){
  150. result=2;
  151. }
  152. return result;
  153. }
  154. //==========================================
  155. // Init all share memory
  156. //==========================================
  157. int InitShareMemory() {
  158. int result = PASS;
  159. int MeterSMId;
  160. //creat ShmSysConfigAndInfo
  161. if ((MeterSMId = shmget(ShmSysConfigAndInfoKey,
  162. sizeof(struct SysConfigAndInfo), 0777)) < 0) {
  163. #ifdef SystemLogMessage
  164. DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
  165. #endif
  166. result = FAIL;
  167. } else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0))
  168. == (void *) -1) {
  169. #ifdef SystemLogMessage
  170. DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
  171. #endif
  172. result = FAIL;
  173. } else {
  174. }
  175. //creat ShmStatusCodeData
  176. if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData),
  177. 0777)) < 0) {
  178. #ifdef SystemLogMessage
  179. DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
  180. #endif
  181. result = FAIL;
  182. } else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1) {
  183. #ifdef SystemLogMessage
  184. DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
  185. #endif
  186. result = FAIL;
  187. } else {
  188. }
  189. return result;
  190. }
  191. int StoreUsrConfigData(struct SysConfigData *UsrData)
  192. {
  193. int fd,wrd;
  194. unsigned int i,Chk;
  195. unsigned char *ptr;
  196. Chk=0;
  197. ptr=(unsigned char *)UsrData;
  198. for(i=0;i<sizeof(struct SysConfigData)-4;i++)
  199. {
  200. Chk+=*(ptr+i);
  201. }
  202. UsrData->Checksum=Chk;
  203. fd = open("/dev/mtdblock10", O_RDWR);
  204. if (fd < 0)
  205. {
  206. #ifdef SystemLogMessage
  207. StoreLogMsg("[main]StoreUsrConfigData: open /dev/mtdblock10 NG");
  208. #endif
  209. return 0;
  210. }
  211. wrd=write(fd, UsrData, sizeof(struct SysConfigData));
  212. close(fd);
  213. if(wrd!=(sizeof(struct SysConfigData)))
  214. {
  215. #ifdef SystemLogMessage
  216. StoreLogMsg("[main]StoreUsrConfigData: write /dev/mtdblock10 NG");
  217. #endif
  218. return 0;
  219. }
  220. fd = open("/dev/mtdblock11", O_RDWR);
  221. if (fd < 0)
  222. {
  223. #ifdef SystemLogMessage
  224. StoreLogMsg("[main]StoreUsrConfigData: open /dev/mtdblock11(backup) NG");
  225. #endif
  226. return 0;
  227. }
  228. wrd=write(fd, UsrData, sizeof(struct SysConfigData));
  229. close(fd);
  230. if(wrd!=(sizeof(struct SysConfigData)))
  231. {
  232. #ifdef SystemLogMessage
  233. StoreLogMsg("[main]StoreUsrConfigData: write /dev/mtdblock11(backup) NG");
  234. #endif
  235. return 0;
  236. }
  237. InitShareMemory();
  238. return 1;
  239. }
  240. //================================================
  241. // Main process
  242. //================================================
  243. int main(int argc, char *argv[]) {
  244. if (InitShareMemory() == FAIL) {
  245. #ifdef SystemLogMessage
  246. DEBUG_ERROR("InitShareMemory NG\n");
  247. #endif
  248. if (ShmStatusCodeData != NULL) {
  249. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory = 1;
  250. }
  251. sleep(5);
  252. return 0;
  253. }
  254. if (argc == 3 & isdigit(*argv[1])) {
  255. struct SysConfigData SysConfig;
  256. int fd, wrd;
  257. unsigned int Chk;
  258. unsigned char *ptr;
  259. ptr=malloc(sizeof(struct SysConfigData));
  260. if(ptr==NULL)
  261. {
  262. #ifdef SystemLogMessage
  263. DEBUG_ERROR("malloc for SysConfigData NG");
  264. #endif
  265. return 0;
  266. }
  267. memset(ptr,0,sizeof(struct SysConfigData));
  268. memset(&SysConfig,0,sizeof(struct SysConfigData));
  269. if (strcmp(argv[1], "1") == 0) {
  270. struct json_object *jobj = json_tokener_parse(argv[2]);
  271. struct json_object *SystemId = json_object_object_get(jobj, "SystemId");
  272. struct json_object *SystemDateTime = json_object_object_get(jobj,"SystemDateTime");
  273. struct json_object *FactoryConfiguration = json_object_object_get(jobj, "FactoryConfiguration");
  274. struct json_object *AuthorisationMode = json_object_object_get(jobj,"AuthorisationMode");
  275. struct json_object *DefaultLanguage = json_object_object_get(jobj,"DefaultLanguage");
  276. struct json_object *RfidCardNumEndian = json_object_object_get(jobj,"RfidCardNumEndian");
  277. sprintf(ShmSysConfigAndInfo->SysConfig.SystemId,json_object_get_string(SystemId));
  278. sprintf(ShmSysConfigAndInfo->SysConfig.SystemDateTime,json_object_get_string(SystemDateTime));
  279. sprintf(&ShmSysConfigAndInfo->SysInfo.FactoryConfiguration,json_object_get_string(FactoryConfiguration));
  280. sprintf(&ShmSysConfigAndInfo->SysConfig.AuthorisationMode,json_object_get_string(AuthorisationMode));
  281. sprintf(&ShmSysConfigAndInfo->SysConfig.DefaultLanguage,json_object_get_string(DefaultLanguage));
  282. sprintf(&ShmSysConfigAndInfo->SysConfig.RfidCardNumEndian,json_object_get_string(RfidCardNumEndian));
  283. //Set default configuration
  284. //strcpy(SysConfig.SystemId, "11111111111111");
  285. //strcpy(SysConfig.SystemDateTime, "2020-01-01 00:00:00");
  286. strcpy(SysConfig.SystemId, json_object_get_string(SystemId));
  287. //strcpy(SysConfig.SystemDateTime, json_object_get_string(SystemDateTime));
  288. strcpy(&SysConfig.AuthorisationMode, json_object_get_string(AuthorisationMode));
  289. strcpy(&SysConfig.DefaultLanguage, json_object_get_string(DefaultLanguage));
  290. strcpy(&SysConfig.RfidCardNumEndian,json_object_get_string(RfidCardNumEndian));
  291. if(SystemDateTime!=""){
  292. if(system(sprintf("date -s %",SystemDateTime))==0){
  293. system("hwclock -w");
  294. }
  295. }
  296. }
  297. if (strcmp(argv[1], "2") == 0) {
  298. struct json_object *jobj = json_tokener_parse(argv[2]);
  299. struct json_object *MaxChargingEnergy = json_object_object_get(jobj,"MaxChargingEnergy");
  300. struct json_object *MaxChargingPower = json_object_object_get(jobj,"MaxChargingPower");
  301. struct json_object *MaxChargingCurrent = json_object_object_get(jobj, "MaxChargingCurrent");
  302. struct json_object *MaxChargingDuration = json_object_object_get(jobj,"MaxChargingDuration");
  303. struct json_object *PhaseLossPolicy = json_object_object_get(jobj,"PhaseLossPolicy");
  304. struct json_object *LocalWhiteCard0 = json_object_object_get(jobj,"LocalWhiteCard0");
  305. struct json_object *LocalWhiteCard1 = json_object_object_get(jobj,"LocalWhiteCard1");
  306. struct json_object *LocalWhiteCard2 = json_object_object_get(jobj,"LocalWhiteCard2");
  307. struct json_object *LocalWhiteCard3 = json_object_object_get(jobj,"LocalWhiteCard3");
  308. struct json_object *LocalWhiteCard4 = json_object_object_get(jobj,"LocalWhiteCard4");
  309. struct json_object *LocalWhiteCard5 = json_object_object_get(jobj,"LocalWhiteCard5");
  310. struct json_object *LocalWhiteCard6 = json_object_object_get(jobj,"LocalWhiteCard6");
  311. struct json_object *LocalWhiteCard7 = json_object_object_get(jobj,"LocalWhiteCard7");
  312. struct json_object *LocalWhiteCard8 = json_object_object_get(jobj,"LocalWhiteCard8");
  313. struct json_object *LocalWhiteCard9 = json_object_object_get(jobj,"LocalWhiteCard9");
  314. struct json_object *UserId = json_object_object_get(jobj,"UserId");
  315. ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy=json_object_get_int(MaxChargingEnergy);
  316. ShmSysConfigAndInfo->SysConfig.MaxChargingPower=json_object_get_int(MaxChargingPower);
  317. ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent=json_object_get_int(MaxChargingCurrent);
  318. ShmSysConfigAndInfo->SysConfig.MaxChargingDuration=json_object_get_int(MaxChargingDuration);
  319. sprintf(&ShmSysConfigAndInfo->SysConfig.PhaseLossPolicy,json_object_get_string(PhaseLossPolicy));
  320. sprintf(&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[0],json_object_get_string(LocalWhiteCard0));
  321. sprintf(&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[1],json_object_get_string(LocalWhiteCard1));
  322. sprintf(&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[2],json_object_get_string(LocalWhiteCard2));
  323. sprintf(&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[3],json_object_get_string(LocalWhiteCard3));
  324. sprintf(&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[4],json_object_get_string(LocalWhiteCard4));
  325. sprintf(&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[5],json_object_get_string(LocalWhiteCard5));
  326. sprintf(&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[6],json_object_get_string(LocalWhiteCard6));
  327. sprintf(&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[7],json_object_get_string(LocalWhiteCard7));
  328. sprintf(&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[8],json_object_get_string(LocalWhiteCard8));
  329. sprintf(&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[9],json_object_get_string(LocalWhiteCard9));
  330. sprintf(&ShmSysConfigAndInfo->SysConfig.UserId,json_object_get_string(UserId));
  331. //Set default configuration
  332. SysConfig.MaxChargingEnergy=json_object_get_int(MaxChargingEnergy);
  333. SysConfig.MaxChargingPower=json_object_get_int(MaxChargingPower);
  334. SysConfig.MaxChargingCurrent=json_object_get_int(MaxChargingCurrent);
  335. SysConfig.MaxChargingDuration=json_object_get_int(MaxChargingDuration);
  336. strcpy(&SysConfig.PhaseLossPolicy, json_object_get_string(PhaseLossPolicy));
  337. strcpy(SysConfig.LocalWhiteCard[0],json_object_get_string(LocalWhiteCard0));
  338. strcpy(SysConfig.LocalWhiteCard[1],json_object_get_string(LocalWhiteCard1));
  339. strcpy(SysConfig.LocalWhiteCard[2],json_object_get_string(LocalWhiteCard2));
  340. strcpy(SysConfig.LocalWhiteCard[3],json_object_get_string(LocalWhiteCard3));
  341. strcpy(SysConfig.LocalWhiteCard[4],json_object_get_string(LocalWhiteCard4));
  342. strcpy(SysConfig.LocalWhiteCard[5],json_object_get_string(LocalWhiteCard5));
  343. strcpy(SysConfig.LocalWhiteCard[6],json_object_get_string(LocalWhiteCard6));
  344. strcpy(SysConfig.LocalWhiteCard[7],json_object_get_string(LocalWhiteCard7));
  345. strcpy(SysConfig.LocalWhiteCard[8],json_object_get_string(LocalWhiteCard8));
  346. strcpy(SysConfig.LocalWhiteCard[9],json_object_get_string(LocalWhiteCard9));
  347. strcpy(SysConfig.UserId,json_object_get_string(UserId));
  348. }
  349. if (strcmp(argv[1], "3") == 0) {
  350. struct json_object *jobj = json_tokener_parse(argv[2]);
  351. struct json_object *FtpServer = json_object_object_get(jobj,"FtpServer");
  352. struct json_object *Eth0DhcpClient = json_object_object_get(jobj,"Eth0DhcpClient");
  353. struct json_object *Eth0IpAddress = json_object_object_get(jobj, "Eth0IpAddress");
  354. struct json_object *Eth0SubmaskAddress = json_object_object_get(jobj,"Eth0SubmaskAddress");
  355. struct json_object *Eth0GatewayAddress = json_object_object_get(jobj,"Eth0GatewayAddress");
  356. struct json_object *Eth1DhcpClient = json_object_object_get(jobj,"Eth1DhcpClient");
  357. struct json_object *Eth1IpAddress = json_object_object_get(jobj, "Eth1IpAddress");
  358. struct json_object *Eth1SubmaskAddress = json_object_object_get(jobj,"Eth1SubmaskAddress");
  359. struct json_object *Eth1GatewayAddress = json_object_object_get(jobj,"Eth1GatewayAddress");
  360. struct json_object *WifiMode = json_object_object_get(jobj,"WifiMode");
  361. struct json_object *WifiSsid = json_object_object_get(jobj,"WifiSsid");
  362. struct json_object *WifiPassword = json_object_object_get(jobj,"WifiPassword");
  363. struct json_object *WifiDhcpServer = json_object_object_get(jobj,"WifiDhcpServer");
  364. struct json_object *WifiDhcpClient = json_object_object_get(jobj,"WifiDhcpClient");
  365. struct json_object *WifiIpAddress = json_object_object_get(jobj,"WifiIpAddress");
  366. struct json_object *WifiSubmaskAddress = json_object_object_get(jobj,"WifiSubmaskAddress");
  367. struct json_object *WifiGatewayAddress = json_object_object_get(jobj,"WifiGatewayAddress");
  368. struct json_object *TelcomApn = json_object_object_get(jobj,"TelcomApn");
  369. struct json_object *TelcomChapPapId = json_object_object_get(jobj,"TelcomChapPapId");
  370. struct json_object *TelcomChapPapPwd = json_object_object_get(jobj,"TelcomChapPapPwd");
  371. struct json_object *TelcomIpAddress = json_object_object_get(jobj,"TelcomIpAddress");
  372. sprintf(&ShmSysConfigAndInfo->SysConfig.FtpServer,json_object_get_string(FtpServer));
  373. sprintf(&ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient,json_object_get_string(Eth0DhcpClient));
  374. sprintf(&ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress,json_object_get_string(Eth0IpAddress));
  375. sprintf(&ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthSubmaskAddress,json_object_get_string(Eth0SubmaskAddress));
  376. sprintf(&ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthGatewayAddress,json_object_get_string(Eth0GatewayAddress));
  377. sprintf(&ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthDhcpClient,json_object_get_string(Eth1DhcpClient));
  378. sprintf(&ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthIpAddress,json_object_get_string(Eth1IpAddress));
  379. sprintf(&ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthSubmaskAddress,json_object_get_string(Eth1SubmaskAddress));
  380. sprintf(&ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthGatewayAddress,json_object_get_string(Eth1GatewayAddress));
  381. sprintf(&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiDhcpClient,json_object_get_string(WifiDhcpClient));
  382. sprintf(&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiSsid,json_object_get_string(WifiSsid));
  383. sprintf(&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiPassword,json_object_get_string(WifiPassword));
  384. sprintf(&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiDhcpServer,json_object_get_string(WifiDhcpServer));
  385. sprintf(&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiIpAddress,json_object_get_string(WifiIpAddress));
  386. sprintf(&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiSubmaskAddress,json_object_get_string(WifiSubmaskAddress));
  387. sprintf(&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiGatewayAddress,json_object_get_string(WifiGatewayAddress));
  388. sprintf(&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn,json_object_get_string(TelcomApn));
  389. sprintf(&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId,json_object_get_string(TelcomChapPapId));
  390. sprintf(&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd,json_object_get_string(TelcomChapPapPwd));
  391. sprintf(&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomIpAddress,json_object_get_string(TelcomIpAddress));
  392. //Set default configuration
  393. strcpy(SysConfig.FtpServer, json_object_get_string(FtpServer));
  394. strcpy(&SysConfig.Eth0Interface.EthDhcpClient, json_object_get_string(Eth0DhcpClient));
  395. strcpy(SysConfig.Eth0Interface.EthIpAddress, json_object_get_string(Eth0IpAddress));
  396. strcpy(SysConfig.Eth0Interface.EthSubmaskAddress, json_object_get_string(Eth0SubmaskAddress));
  397. strcpy(SysConfig.Eth0Interface.EthGatewayAddress, json_object_get_string(Eth0GatewayAddress));
  398. strcpy(&SysConfig.Eth1Interface.EthDhcpClient, json_object_get_string(Eth1DhcpClient));
  399. strcpy(SysConfig.Eth1Interface.EthIpAddress, json_object_get_string(Eth1IpAddress));
  400. strcpy(SysConfig.Eth1Interface.EthSubmaskAddress, json_object_get_string(Eth1SubmaskAddress));
  401. strcpy(SysConfig.Eth1Interface.EthGatewayAddress, json_object_get_string(Eth1GatewayAddress));
  402. strcpy(&SysConfig.AthInterface.WifiDhcpClient, json_object_get_string(WifiDhcpClient));
  403. strcpy(SysConfig.AthInterface.WifiSsid, json_object_get_string(WifiSsid));
  404. strcpy(SysConfig.AthInterface.WifiPassword, json_object_get_string(WifiPassword));
  405. strcpy(&SysConfig.AthInterface.WifiDhcpServer, json_object_get_string(WifiDhcpServer));
  406. strcpy(SysConfig.AthInterface.WifiIpAddress, json_object_get_string(WifiIpAddress));
  407. strcpy(SysConfig.AthInterface.WifiSubmaskAddress, json_object_get_string(WifiSubmaskAddress));
  408. strcpy(SysConfig.AthInterface.WifiGatewayAddress, json_object_get_string(WifiGatewayAddress));
  409. strcpy(SysConfig.TelecomInterface.TelcomApn, json_object_get_string(TelcomApn));
  410. strcpy(SysConfig.TelecomInterface.TelcomChapPapId, json_object_get_string(TelcomChapPapId));
  411. strcpy(SysConfig.TelecomInterface.TelcomChapPapPwd, json_object_get_string(TelcomChapPapPwd));
  412. strcpy(SysConfig.TelecomInterface.TelcomIpAddress, json_object_get_string(TelcomIpAddress));
  413. }
  414. if (strcmp(argv[1], "4") == 0) {
  415. struct json_object *jobj = json_tokener_parse(argv[2]);
  416. struct json_object *BackendConnTimeout = json_object_object_get(jobj,"BackendConnTimeout");
  417. struct json_object *OfflinePolicy = json_object_object_get(jobj,"OfflinePolicy");
  418. struct json_object *OfflineMaxChargeEnergy = json_object_object_get(jobj, "OfflineMaxChargeEnergy");
  419. struct json_object *OfflineMaxChargeDuration = json_object_object_get(jobj,"OfflineMaxChargeDuration");
  420. struct json_object *OcppServerURL = json_object_object_get(jobj,"OcppServerURL");
  421. struct json_object *ChargeBoxId = json_object_object_get(jobj,"ChargeBoxId");
  422. ShmSysConfigAndInfo->SysConfig.BackendConnTimeout=json_object_get_int(BackendConnTimeout);
  423. sprintf(&ShmSysConfigAndInfo->SysConfig.OfflinePolicy,json_object_get_string(OfflinePolicy));
  424. ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy=json_object_get_int(OfflineMaxChargeEnergy);
  425. ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeDuration=json_object_get_int(OfflineMaxChargeDuration);
  426. sprintf(&ShmSysConfigAndInfo->SysConfig.OcppServerURL,json_object_get_string(OcppServerURL));
  427. sprintf(&ShmSysConfigAndInfo->SysConfig.ChargeBoxId,json_object_get_string(ChargeBoxId));
  428. //Set default configuration
  429. SysConfig.BackendConnTimeout=json_object_get_int(BackendConnTimeout);
  430. strcpy(&SysConfig.OfflinePolicy,json_object_get_string(OfflinePolicy));
  431. SysConfig.OfflineMaxChargeEnergy=json_object_get_int(OfflineMaxChargeEnergy);
  432. SysConfig.OfflineMaxChargeDuration=json_object_get_int(OfflineMaxChargeDuration);
  433. strcpy(SysConfig.OcppServerURL,json_object_get_string(OcppServerURL));
  434. strcpy(SysConfig.ChargeBoxId,json_object_get_string(ChargeBoxId));
  435. }
  436. StoreUsrConfigData(&SysConfig);
  437. #ifdef SystemLogMessage
  438. DEBUG_INFO("WebServiceConfig update OK");
  439. #endif
  440. }
  441. if (argc == 2) { //init share memory
  442. if (strcmp(argv[1], "aaa") == 0) {
  443. struct SysConfigData SysConfig;
  444. //system
  445. sprintf(ShmSysConfigAndInfo->SysConfig.ModelName, "DWLU700111W1PH");
  446. sprintf(ShmSysConfigAndInfo->SysConfig.SerialNumber, "SerialNumber");
  447. sprintf(ShmSysConfigAndInfo->SysConfig.SystemId, "1234567890");
  448. sprintf(ShmSysConfigAndInfo->SysConfig.SystemDateTime, "SystemDateTime");
  449. sprintf(&ShmSysConfigAndInfo->SysInfo.FactoryConfiguration, "1");
  450. sprintf(&ShmSysConfigAndInfo->SysConfig.AuthorisationMode, "1");
  451. sprintf(&ShmSysConfigAndInfo->SysConfig.DefaultLanguage, "a");
  452. ShmSysConfigAndInfo->SysInfo.InputVoltageR=0;
  453. ShmSysConfigAndInfo->SysInfo.InputVoltageS=0;
  454. ShmSysConfigAndInfo->SysInfo.InputVoltageT=0;
  455. ShmSysConfigAndInfo->SysInfo.SystemFanRotaSpeed=0;
  456. ShmSysConfigAndInfo->SysInfo.PsuFanRotaSpeed=0;
  457. sprintf(&ShmSysConfigAndInfo->SysConfig.RfidCardNumEndian, "0");
  458. sprintf(&ShmSysConfigAndInfo->SysInfo.AuxPower5V, "0");
  459. sprintf(&ShmSysConfigAndInfo->SysInfo.AuxPower12V, "0");
  460. sprintf(&ShmSysConfigAndInfo->SysInfo.AuxPower24V, "0");
  461. sprintf(&ShmSysConfigAndInfo->SysInfo.AuxPower48V, "0");
  462. sprintf(ShmSysConfigAndInfo->SysInfo.CsuHwRev, "CsuHwRev");
  463. sprintf(ShmSysConfigAndInfo->SysInfo.CsuBootLoadFwRev, "CsuBootLoadFwRev");
  464. sprintf(ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev, "CsuKernelFwRev");
  465. sprintf(ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "CsuRootFsFwRev");
  466. sprintf(ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev, "CsuPrimFwRev");
  467. sprintf(ShmSysConfigAndInfo->SysInfo.LcmHwRev, "LcmHwRev");
  468. sprintf(ShmSysConfigAndInfo->SysInfo.LcmFwRev, "LcmFwRev");
  469. sprintf(ShmSysConfigAndInfo->SysInfo.PsuHwRev, "PsuHwRev");
  470. sprintf(ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev, "PsuPrimFwRev");
  471. sprintf(ShmSysConfigAndInfo->SysInfo.PsuSecFwRev, "PsuSecFwRev");
  472. sprintf(ShmSysConfigAndInfo->SysInfo.AuxPwrHwRev, "AuxPwrHwRev");
  473. sprintf(ShmSysConfigAndInfo->SysInfo.AuxPwrFwRev, "AuxPwrFwRev");
  474. sprintf(ShmSysConfigAndInfo->SysInfo.FanModuleHwRev, "FanModuleHwRev");
  475. sprintf(ShmSysConfigAndInfo->SysInfo.FanModuleFwRev, "FanModuleFwRev");
  476. sprintf(ShmSysConfigAndInfo->SysInfo.RelayModuleHwRev, "RelayModuleHwRev");
  477. sprintf(ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev, "RelayModuleFwRev");
  478. sprintf(ShmSysConfigAndInfo->SysInfo.TelcomModemFwRev, "TelcomModemFwRev");
  479. ShmSysConfigAndInfo->SysInfo.SystemAmbientTemp=0;
  480. ShmSysConfigAndInfo->SysInfo.SystemCriticalTemp=0;
  481. ShmSysConfigAndInfo->SysInfo.CcsConnectorTemp=0;
  482. ShmSysConfigAndInfo->SysInfo.PsuAmbientTemp=0;
  483. ShmSysConfigAndInfo->SysConfig.AcPlugInTimes=0;
  484. ShmSysConfigAndInfo->SysConfig.GbPlugInTimes=0;
  485. ShmSysConfigAndInfo->SysConfig.Ccs1PlugInTime=0;
  486. ShmSysConfigAndInfo->SysConfig.Ccs2PlugInTimes=0;
  487. ShmSysConfigAndInfo->SysConfig.ChademoPlugInTimes=0;
  488. //Set default configuration
  489. //strcpy(SysConfig->ModelName)
  490. // strcpy(SysConfig->SystemId, ShmSysConfigAndInfo->SysConfig.SystemId);
  491. // strcpy(SysConfig->SystemDateTime, ShmSysConfigAndInfo->SysConfig.SystemDateTime);
  492. strcpy(SysConfig.SystemId, "0987654321");
  493. strcpy(SysConfig.SystemDateTime, "2019-08-12 00:00:00");
  494. //charging
  495. ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy=0;
  496. ShmSysConfigAndInfo->SysConfig.MaxChargingPower=0;
  497. ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent= 0;
  498. ShmSysConfigAndInfo->SysConfig.MaxChargingDuration=0;
  499. sprintf(&ShmSysConfigAndInfo->SysConfig.PhaseLossPolicy, "1");
  500. sprintf(&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[0], "111");
  501. sprintf(&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[1], "222");
  502. sprintf(&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[2], "333");
  503. sprintf(&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[3], "444");
  504. sprintf(&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[4], "555");
  505. sprintf(&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[5], "666");
  506. sprintf(&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[6], "777");
  507. sprintf(&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[7], "888");
  508. sprintf(&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[8], "999");
  509. sprintf(&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[9], "aaa");
  510. sprintf(ShmSysConfigAndInfo->SysConfig.UserId, "UserId");
  511. ShmSysConfigAndInfo->SysInfo.CcsChargingData[0].PresentChargingVoltage=(float) 64;
  512. ShmSysConfigAndInfo->SysInfo.CcsChargingData[0].PresentChargingCurrent=(double) 6553.5;
  513. ShmSysConfigAndInfo->SysInfo.CcsChargingData[0].PresentChargingPower=0;
  514. ShmSysConfigAndInfo->SysInfo.CcsChargingData[0].PresentChargedEnergy=0;
  515. ShmSysConfigAndInfo->SysInfo.CcsChargingData[0].PresentChargedDuration=0;
  516. ShmSysConfigAndInfo->SysInfo.CcsChargingData[0].RemainChargingDuration=0;
  517. ShmSysConfigAndInfo->SysInfo.CcsChargingData[0].EvBatteryMaxVoltage=0;
  518. ShmSysConfigAndInfo->SysInfo.CcsChargingData[0].EvBatterytargetVoltage=0;
  519. ShmSysConfigAndInfo->SysInfo.CcsChargingData[0].EvBatterySoc=0;
  520. sprintf(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[0].SystemStatus, "1");
  521. sprintf(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[0].Index, "1");
  522. sprintf(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[0].Type, "0");
  523. sprintf(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[0].type_index, "1");
  524. sprintf(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[0].EvBatterytargetCurrent, "1");
  525. //network
  526. sprintf(&ShmSysConfigAndInfo->SysInfo.InternetConn,"1");
  527. sprintf(ShmSysConfigAndInfo->SysConfig.FtpServer,"FtpServer");
  528. sprintf(&ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient,"1");
  529. sprintf(ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthMacAddress,"EthMacAddress");
  530. sprintf(ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress,"EthIpAddress");
  531. sprintf(ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthSubmaskAddress,"EthIpAddress");
  532. sprintf(ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthGatewayAddress,"EthGatewayAddress");
  533. sprintf(&ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthDhcpClient,"1");
  534. sprintf(ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthMacAddress,"EthMacAddress");
  535. sprintf(ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthIpAddress,"EthIpAddress");
  536. sprintf(ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthSubmaskAddress,"EthSubmaskAddress");
  537. sprintf(ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthGatewayAddress,"EthGatewayAddress");
  538. sprintf(&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode,"1");
  539. sprintf(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiSsid,"WifiSsid");
  540. sprintf(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiPassword,"WifiSsid");
  541. ShmSysConfigAndInfo->SysConfig.AthInterface.WifiRssi=0;
  542. sprintf(&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiDhcpServer,"1");
  543. sprintf(&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiDhcpClient,"1");
  544. sprintf(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMacAddress,"WifiMacAddress");
  545. sprintf(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiIpAddress,"WifiIpAddress");
  546. sprintf(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiSubmaskAddress,"WifiSubmaskAddress");
  547. sprintf(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiGatewayAddress,"WifiGatewayAddress");
  548. sprintf(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn,"TelcomApn");
  549. ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomRssi=0;
  550. sprintf(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId,"TelcomChapPapId");
  551. sprintf(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd,"TelcomChapPapPwd");
  552. sprintf(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemImei,"TelcomModemImei");
  553. sprintf(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimImsi,"TelcomSimImsi");
  554. //sprintf(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimIccid,"TelcomSimIccid");
  555. sprintf(&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimStatus,"1");
  556. sprintf(&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemMode,"1");
  557. sprintf(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomIpAddress,"TelcomIpAddress");
  558. //backend
  559. ShmSysConfigAndInfo->SysConfig.BackendConnTimeout=0;
  560. sprintf(&ShmSysConfigAndInfo->SysConfig.OfflinePolicy,"1");
  561. ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy=0;
  562. ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeDuration=0;
  563. sprintf(&ShmSysConfigAndInfo->SysInfo.OcppConnStatus,"1");
  564. sprintf(ShmSysConfigAndInfo->SysConfig.OcppServerURL,"OcppServerURL");
  565. sprintf(ShmSysConfigAndInfo->SysConfig.ChargeBoxId,"ChargeBoxId");
  566. sprintf(&ShmSysConfigAndInfo->SysInfo.FirmwareUpdate,"0");
  567. StoreUsrConfigData(&SysConfig);
  568. #ifdef SystemLogMessage
  569. DEBUG_INFO("WebService initial OK");
  570. #endif
  571. }
  572. if (strcmp(argv[1], "log") == 0) {
  573. time_t tt = time(0); //獲取當前時間
  574. int year,month;
  575. char cmd[100];
  576. struct tm *pst = localtime(&tt); //把time_t類型轉換為struct tm類型
  577. year = pst->tm_year + 1900;
  578. month = pst->tm_mon + 1;
  579. sprintf(cmd,"cp /mnt/%04d-%02d.zip /var/www/log.zip",year,month);
  580. if(system("exec /root/tool 'log'")==0){
  581. system(cmd);
  582. }
  583. }
  584. }
  585. //upgrade firmware
  586. if (argc == 3 & strcmp(argv[1], "upgrade") == 0) {
  587. struct json_object *jobj;
  588. struct json_object *Result;
  589. struct json_object *Message;
  590. char cmd[100];
  591. jobj=json_object_new_object();
  592. //system
  593. if(&ShmSysConfigAndInfo->SysInfo.FirmwareUpdate == "0"){
  594. strcpy(&ShmSysConfigAndInfo->SysInfo.FirmwareUpdate, "1");
  595. Result = json_object_new_string("success");
  596. Message = json_object_new_string("file is uploaded");
  597. }
  598. else{
  599. sprintf(cmd,"rm /mnt/%s",argv[2]);
  600. system(cmd);
  601. Result = json_object_new_string("error");
  602. Message = json_object_new_string("machine is busy");
  603. }
  604. json_object_object_add(jobj,"Result",Result);
  605. json_object_object_add(jobj,"Message",Message);
  606. printf("%s\n", json_object_to_json_string(jobj));
  607. }
  608. //web page query all
  609. if (argc == 2 & strcmp(argv[1], "query") == 0) {
  610. char *IsAcDc[2];
  611. char *Connector1[2];
  612. char *Connector2[2];
  613. char *Connector3[2];
  614. char *Network[2];
  615. substr(IsAcDc,ShmSysConfigAndInfo->SysConfig.ModelName,0,1);
  616. substr(Connector1,ShmSysConfigAndInfo->SysConfig.ModelName,7,1);
  617. substr(Connector2,ShmSysConfigAndInfo->SysConfig.ModelName,8,1);
  618. substr(Connector3,ShmSysConfigAndInfo->SysConfig.ModelName,9,1);
  619. substr(Network,ShmSysConfigAndInfo->SysConfig.ModelName,10,1);
  620. int connectorType1,connectorType2,connectorType3,modelType;
  621. connectorType1=ConnectorType(Connector1);
  622. connectorType2=ConnectorType(Connector2);
  623. connectorType3=ConnectorType(Connector3);
  624. modelType=ModelType(IsAcDc,Network);
  625. // printf("connectorType1:%d\n",connectorType1);
  626. // printf("connectorType2:%d\n",connectorType2);
  627. // printf("connectorType3:%d\n",connectorType3);
  628. // printf("modelType:%d\n",modelType);
  629. struct json_object *jobj1;
  630. struct json_object *jobj2;
  631. struct json_object *jobj3;
  632. struct json_object *jobj4;
  633. struct json_object *array_obj;
  634. //system
  635. struct json_object *ModelName;
  636. struct json_object *SerialNumber;
  637. struct json_object *SystemId;
  638. struct json_object *SystemDateTime;
  639. struct json_object *FactoryConfiguration;
  640. struct json_object *AuthorisationMode;
  641. struct json_object *DefaultLanguage;
  642. struct json_object *InputVoltageR;
  643. struct json_object *InputVoltageS;
  644. struct json_object *InputVoltageT;
  645. struct json_object *SystemFanRotaSpeed;
  646. struct json_object *PsuFanRotaSpeed;
  647. struct json_object *RfidCardNumEndian;
  648. struct json_object *AuxPower5V;
  649. struct json_object *AuxPower12V;
  650. struct json_object *AuxPower24V;
  651. struct json_object *AuxPower48V;
  652. struct json_object *CsuHwRev;
  653. struct json_object *CsuBootLoadFwRev;
  654. struct json_object *CsuKernelFwRev;
  655. struct json_object *CsuRootFsFwRev;
  656. struct json_object *CsuPrimFwRev;
  657. struct json_object *LcmHwRev;
  658. struct json_object *LcmFwRev;
  659. struct json_object *PsuHwRev;
  660. struct json_object *PsuPrimFwRev;
  661. struct json_object *PsuSecFwRev;
  662. struct json_object *AuxPwrHwRev;
  663. struct json_object *AuxPwrFwRev;
  664. struct json_object *FanModuleHwRev;
  665. struct json_object *FanModuleFwRev;
  666. struct json_object *RelayModuleHwRev;
  667. struct json_object *RelayModuleFwRev;
  668. struct json_object *TelcomModemFwRev;
  669. struct json_object *SystemAmbientTemp;
  670. struct json_object *SystemCriticalTemp;
  671. struct json_object *CcsConnectorTemp;
  672. struct json_object *PsuAmbientTemp;
  673. struct json_object *AcPlugInTimes;
  674. struct json_object *GbPlugInTimes;
  675. struct json_object *Ccs1PlugInTime;
  676. struct json_object *Ccs2PlugInTimes;
  677. struct json_object *ChademoPlugInTimes;
  678. struct json_object *FirmwareUpdate;
  679. //charging
  680. struct json_object *MaxChargingEnergy;
  681. struct json_object *MaxChargingPower;
  682. struct json_object *MaxChargingCurrent;
  683. struct json_object *MaxChargingDuration;
  684. struct json_object *PhaseLossPolicy;
  685. struct json_object *LocalWhiteCard[10];
  686. struct json_object *LocalWhiteCardArr= json_object_new_array();
  687. struct json_object *CcsAuthentication;
  688. struct json_object *AcCcsChargingMode;
  689. struct json_object *UserId;
  690. struct json_object *ChargingInfo1;
  691. struct json_object *ChargingInfo2;
  692. struct json_object *ChargingInfo3;
  693. struct json_object *PresentChargingVoltage[3];
  694. struct json_object *PresentChargingCurrent[3];
  695. struct json_object *PresentChargingPower[3];
  696. struct json_object *PresentChargedEnergy[3];
  697. struct json_object *PresentChargedDuration[3];
  698. struct json_object *RemainChargingDuration[3];
  699. struct json_object *EvBatteryMaxVoltage[3];
  700. struct json_object *EvBatterytargetVoltage[3];
  701. struct json_object *EvBatterySoc[3];
  702. struct json_object *SystemStatus[3];
  703. struct json_object *Index[3];
  704. struct json_object *Type[3];
  705. struct json_object *type_index[3];
  706. struct json_object *EvBatterytargetCurrent[3];
  707. //network
  708. struct json_object *InternetConn;
  709. struct json_object *FtpServer;
  710. struct json_object *Eth0DhcpClient;
  711. struct json_object *Eth0MacAddress;
  712. struct json_object *Eth0IpAddress;
  713. struct json_object *Eth0SubmaskAddress;
  714. struct json_object *Eth0GatewayAddress;
  715. struct json_object *Eth1DhcpClient;
  716. struct json_object *Eth1MacAddress;
  717. struct json_object *Eth1IpAddress;
  718. struct json_object *Eth1SubmaskAddress;
  719. struct json_object *Eth1GatewayAddress;
  720. struct json_object *WifiMode;
  721. struct json_object *WifiSsid;
  722. struct json_object *WifiPassword;
  723. struct json_object *WifiRssi;
  724. struct json_object *WifiDhcpServer;
  725. struct json_object *WifiDhcpClient;
  726. struct json_object *WifiMacAddress;
  727. struct json_object *WifiIpAddress;
  728. struct json_object *WifiSubmaskAddress;
  729. struct json_object *WifiGatewayAddress;
  730. struct json_object *TelcomApn;
  731. struct json_object *TelcomRssi;
  732. struct json_object *TelcomChapPapId;
  733. struct json_object *TelcomChapPapPwd;
  734. struct json_object *TelcomModemImei;
  735. struct json_object *TelcomSimImsi;
  736. struct json_object *TelcomSimIccid;
  737. struct json_object *TelcomSimStatus;
  738. struct json_object *TelcomModemMode;
  739. struct json_object *TelcomIpAddress;
  740. //backend
  741. struct json_object *BackendConnTimeout;
  742. struct json_object *OfflinePolicy;
  743. struct json_object *OfflineMaxChargeEnergy;
  744. struct json_object *OfflineMaxChargeDuration;
  745. struct json_object *OcppConnStatus;
  746. struct json_object *OcppServerURL;
  747. struct json_object *ChargeBoxId;
  748. array_obj = json_object_new_array();
  749. jobj1=json_object_new_object();
  750. jobj2=json_object_new_object();
  751. jobj3=json_object_new_object();
  752. jobj4=json_object_new_object();
  753. //system
  754. ModelName = json_object_new_string(&ShmSysConfigAndInfo->SysConfig.ModelName);
  755. SerialNumber = json_object_new_string(&ShmSysConfigAndInfo->SysConfig.SerialNumber);
  756. SystemId = json_object_new_string(&ShmSysConfigAndInfo->SysConfig.SystemId);
  757. // SystemDateTime = json_object_new_string(ShmSysConfigAndInfo->SysConfig.SystemDateTime);
  758. FactoryConfiguration = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.FactoryConfiguration,1);
  759. AuthorisationMode = json_object_new_string_len(&ShmSysConfigAndInfo->SysConfig.AuthorisationMode,1);
  760. DefaultLanguage = json_object_new_string_len(&ShmSysConfigAndInfo->SysConfig.DefaultLanguage,1);
  761. InputVoltageR = json_object_new_double(ShmSysConfigAndInfo->SysInfo.InputVoltageR);
  762. InputVoltageS = json_object_new_double(ShmSysConfigAndInfo->SysInfo.InputVoltageS);
  763. InputVoltageT = json_object_new_double(ShmSysConfigAndInfo->SysInfo.InputVoltageT);
  764. SystemFanRotaSpeed = json_object_new_int((int)ShmSysConfigAndInfo->SysInfo.SystemFanRotaSpeed);
  765. PsuFanRotaSpeed = json_object_new_int((int)ShmSysConfigAndInfo->SysInfo.PsuFanRotaSpeed);
  766. RfidCardNumEndian = json_object_new_string_len(&ShmSysConfigAndInfo->SysConfig.RfidCardNumEndian,1);
  767. AuxPower5V = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.AuxPower5V,1);
  768. AuxPower12V = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.AuxPower12V,1);
  769. AuxPower24V = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.AuxPower24V,1);
  770. AuxPower48V = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.AuxPower48V,1);
  771. CsuHwRev = json_object_new_string(&ShmSysConfigAndInfo->SysInfo.CsuHwRev);
  772. CsuBootLoadFwRev = json_object_new_string(&ShmSysConfigAndInfo->SysInfo.CsuBootLoadFwRev);
  773. CsuKernelFwRev = json_object_new_string(&ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev);
  774. CsuRootFsFwRev = json_object_new_string(&ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev);
  775. CsuPrimFwRev = json_object_new_string(&ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev);
  776. LcmHwRev = json_object_new_string(&ShmSysConfigAndInfo->SysInfo.LcmHwRev);
  777. LcmFwRev = json_object_new_string(&ShmSysConfigAndInfo->SysInfo.LcmFwRev);
  778. PsuHwRev = json_object_new_string(&ShmSysConfigAndInfo->SysInfo.PsuHwRev);
  779. PsuPrimFwRev = json_object_new_string(&ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev);
  780. PsuSecFwRev = json_object_new_string(&ShmSysConfigAndInfo->SysInfo.PsuSecFwRev);
  781. AuxPwrHwRev = json_object_new_string(&ShmSysConfigAndInfo->SysInfo.AuxPwrHwRev);
  782. AuxPwrFwRev = json_object_new_string(&ShmSysConfigAndInfo->SysInfo.AuxPwrFwRev);
  783. FanModuleHwRev = json_object_new_string(&ShmSysConfigAndInfo->SysInfo.FanModuleHwRev);
  784. FanModuleFwRev = json_object_new_string(&ShmSysConfigAndInfo->SysInfo.FanModuleFwRev);
  785. RelayModuleHwRev = json_object_new_string(&ShmSysConfigAndInfo->SysInfo.RelayModuleHwRev);
  786. RelayModuleFwRev = json_object_new_string(&ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev);
  787. TelcomModemFwRev = json_object_new_string(&ShmSysConfigAndInfo->SysInfo.TelcomModemFwRev);
  788. SystemAmbientTemp = json_object_new_int((int)ShmSysConfigAndInfo->SysInfo.SystemAmbientTemp);
  789. SystemCriticalTemp = json_object_new_int((int)ShmSysConfigAndInfo->SysInfo.SystemCriticalTemp);
  790. CcsConnectorTemp = json_object_new_int((int)ShmSysConfigAndInfo->SysInfo.CcsConnectorTemp);
  791. PsuAmbientTemp = json_object_new_int((int)ShmSysConfigAndInfo->SysInfo.PsuAmbientTemp);
  792. AcPlugInTimes = json_object_new_int((int)ShmSysConfigAndInfo->SysConfig.AcPlugInTimes);
  793. GbPlugInTimes = json_object_new_int((int)ShmSysConfigAndInfo->SysConfig.GbPlugInTimes);
  794. Ccs1PlugInTime = json_object_new_int((int)ShmSysConfigAndInfo->SysConfig.Ccs1PlugInTime);
  795. Ccs2PlugInTimes = json_object_new_int((int)ShmSysConfigAndInfo->SysConfig.Ccs2PlugInTimes);
  796. ChademoPlugInTimes = json_object_new_int((int)ShmSysConfigAndInfo->SysConfig.ChademoPlugInTimes);
  797. FirmwareUpdate = json_object_new_string(&ShmSysConfigAndInfo->SysInfo.FirmwareUpdate);
  798. //charging
  799. int CcsGunQty=0;
  800. int GbGunQty=0;
  801. int CHAdeMOGunQty=0;
  802. ChargingInfo1=json_object_new_object();
  803. ChargingInfo2=json_object_new_object();
  804. ChargingInfo3=json_object_new_object();
  805. MaxChargingEnergy = json_object_new_int((int)ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy);
  806. MaxChargingPower = json_object_new_int((int)ShmSysConfigAndInfo->SysConfig.MaxChargingPower);
  807. MaxChargingCurrent = json_object_new_int((int)ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent);
  808. MaxChargingDuration = json_object_new_int((int)ShmSysConfigAndInfo->SysConfig.MaxChargingDuration);
  809. PhaseLossPolicy = json_object_new_string_len(&ShmSysConfigAndInfo->SysConfig.PhaseLossPolicy,1);
  810. LocalWhiteCard[0] = json_object_new_string(ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[0]);
  811. LocalWhiteCard[1] = json_object_new_string(ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[1]);
  812. LocalWhiteCard[2] = json_object_new_string(ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[2]);
  813. LocalWhiteCard[3] = json_object_new_string(ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[3]);
  814. LocalWhiteCard[4] = json_object_new_string(ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[4]);
  815. LocalWhiteCard[5] = json_object_new_string(ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[5]);
  816. LocalWhiteCard[6] = json_object_new_string(ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[6]);
  817. LocalWhiteCard[7] = json_object_new_string(ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[7]);
  818. LocalWhiteCard[8] = json_object_new_string(ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[8]);
  819. LocalWhiteCard[9] = json_object_new_string(ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[9]);
  820. UserId = json_object_new_string(&ShmSysConfigAndInfo->SysConfig.UserId);
  821. if(connectorType1 != 0){
  822. if(connectorType1 == 1){//CCS
  823. PresentChargingVoltage[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].PresentChargingVoltage);
  824. PresentChargingCurrent[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].PresentChargingCurrent);
  825. PresentChargingPower[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].PresentChargingPower);
  826. PresentChargedEnergy[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].PresentChargedEnergy);
  827. PresentChargedDuration[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].PresentChargedDuration);
  828. RemainChargingDuration[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].RemainChargingDuration);
  829. EvBatteryMaxVoltage[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].EvBatteryMaxVoltage);
  830. EvBatterytargetVoltage[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].EvBatterytargetVoltage);
  831. EvBatterySoc[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].EvBatterySoc);
  832. SystemStatus[0] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].SystemStatus,1);
  833. Index[0] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].Index,1);
  834. Type[0] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].Type,1);
  835. type_index[0] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].type_index,1);
  836. EvBatterytargetCurrent[0] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].EvBatterytargetCurrent,1);
  837. CcsGunQty++;
  838. }
  839. else if(connectorType1 == 2){//GB
  840. PresentChargingVoltage[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].PresentChargingVoltage);
  841. PresentChargingCurrent[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].PresentChargingCurrent);
  842. PresentChargingPower[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].PresentChargingPower);
  843. PresentChargedEnergy[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].PresentChargedEnergy);
  844. PresentChargedDuration[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].PresentChargedDuration);
  845. RemainChargingDuration[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].RemainChargingDuration);
  846. EvBatteryMaxVoltage[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].EvBatteryMaxVoltage);
  847. EvBatterytargetVoltage[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].EvBatterytargetVoltage);
  848. EvBatterySoc[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].EvBatterySoc);
  849. SystemStatus[0] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[GbGunQty].SystemStatus,1);
  850. Index[0] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[GbGunQty].Index,1);
  851. Type[0] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[GbGunQty].Type,1);
  852. type_index[0] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[GbGunQty].type_index,1);
  853. EvBatterytargetCurrent[0] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[GbGunQty].EvBatterytargetCurrent,1);
  854. GbGunQty++;
  855. }
  856. else if(connectorType1 == 3){//CHAdeMO
  857. PresentChargingVoltage[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].PresentChargingVoltage);
  858. PresentChargingCurrent[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].PresentChargingCurrent);
  859. PresentChargingPower[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].PresentChargingPower);
  860. PresentChargedEnergy[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].PresentChargedEnergy);
  861. PresentChargedDuration[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].PresentChargedDuration);
  862. RemainChargingDuration[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].RemainChargingDuration);
  863. EvBatteryMaxVoltage[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].EvBatteryMaxVoltage);
  864. EvBatterytargetVoltage[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].EvBatterytargetVoltage);
  865. EvBatterySoc[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].EvBatterySoc);
  866. SystemStatus[0] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CHAdeMOGunQty].SystemStatus,1);
  867. Index[0] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CHAdeMOGunQty].Index,1);
  868. Type[0] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CHAdeMOGunQty].Type,1);
  869. type_index[0] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CHAdeMOGunQty].type_index,1);
  870. EvBatterytargetCurrent[0] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CHAdeMOGunQty].EvBatterytargetCurrent,1);
  871. CHAdeMOGunQty++;
  872. }
  873. }
  874. if(connectorType2 != 0){
  875. if(connectorType2 == 1){//CCS
  876. PresentChargingVoltage[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].PresentChargingVoltage);
  877. PresentChargingCurrent[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].PresentChargingCurrent);
  878. PresentChargingPower[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].PresentChargingPower);
  879. PresentChargedEnergy[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].PresentChargedEnergy);
  880. PresentChargedDuration[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].PresentChargedDuration);
  881. RemainChargingDuration[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].RemainChargingDuration);
  882. EvBatteryMaxVoltage[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].EvBatteryMaxVoltage);
  883. EvBatterytargetVoltage[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].EvBatterytargetVoltage);
  884. EvBatterySoc[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].EvBatterySoc);
  885. SystemStatus[1] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].SystemStatus,1);
  886. Index[1] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].Index,1);
  887. Type[1] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].Type,1);
  888. type_index[1] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].type_index,1);
  889. EvBatterytargetCurrent[1] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].EvBatterytargetCurrent,1);
  890. CcsGunQty++;
  891. }
  892. else if(connectorType2 == 2){//GB
  893. PresentChargingVoltage[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].PresentChargingVoltage);
  894. PresentChargingCurrent[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].PresentChargingCurrent);
  895. PresentChargingPower[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].PresentChargingPower);
  896. PresentChargedEnergy[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].PresentChargedEnergy);
  897. PresentChargedDuration[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].PresentChargedDuration);
  898. RemainChargingDuration[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].RemainChargingDuration);
  899. EvBatteryMaxVoltage[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].EvBatteryMaxVoltage);
  900. EvBatterytargetVoltage[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].EvBatterytargetVoltage);
  901. EvBatterySoc[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].EvBatterySoc);
  902. SystemStatus[1] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[GbGunQty].SystemStatus,1);
  903. Index[1] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[GbGunQty].Index,1);
  904. Type[1] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[GbGunQty].Type,1);
  905. type_index[1] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[GbGunQty].type_index,1);
  906. EvBatterytargetCurrent[1] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[GbGunQty].EvBatterytargetCurrent,1);
  907. GbGunQty++;
  908. }
  909. else if(connectorType2 == 3){//CHAdeMO
  910. PresentChargingVoltage[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].PresentChargingVoltage);
  911. PresentChargingCurrent[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].PresentChargingCurrent);
  912. PresentChargingPower[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].PresentChargingPower);
  913. PresentChargedEnergy[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].PresentChargedEnergy);
  914. PresentChargedDuration[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].PresentChargedDuration);
  915. RemainChargingDuration[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].RemainChargingDuration);
  916. EvBatteryMaxVoltage[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].EvBatteryMaxVoltage);
  917. EvBatterytargetVoltage[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].EvBatterytargetVoltage);
  918. EvBatterySoc[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].EvBatterySoc);
  919. SystemStatus[1] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CHAdeMOGunQty].SystemStatus,1);
  920. Index[1] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CHAdeMOGunQty].Index,1);
  921. Type[1] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CHAdeMOGunQty].Type,1);
  922. type_index[1] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CHAdeMOGunQty].type_index,1);
  923. EvBatterytargetCurrent[1] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CHAdeMOGunQty].EvBatterytargetCurrent,1);
  924. CHAdeMOGunQty++;
  925. }
  926. }
  927. if(connectorType3 != 0){
  928. if(connectorType3 == 1){//CCS
  929. PresentChargingVoltage[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].PresentChargingVoltage);
  930. PresentChargingCurrent[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].PresentChargingCurrent);
  931. PresentChargingPower[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].PresentChargingPower);
  932. PresentChargedEnergy[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].PresentChargedEnergy);
  933. PresentChargedDuration[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].PresentChargedDuration);
  934. RemainChargingDuration[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].RemainChargingDuration);
  935. EvBatteryMaxVoltage[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].EvBatteryMaxVoltage);
  936. EvBatterytargetVoltage[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].EvBatterytargetVoltage);
  937. EvBatterySoc[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].EvBatterySoc);
  938. SystemStatus[2] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].SystemStatus,1);
  939. Index[2] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].Index,1);
  940. Type[2] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].Type,1);
  941. type_index[2] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].type_index,1);
  942. EvBatterytargetCurrent[2] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].EvBatterytargetCurrent,1);
  943. CcsGunQty++;
  944. }
  945. else if(connectorType3 == 2){//GB
  946. PresentChargingVoltage[2]= json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].PresentChargingVoltage);
  947. PresentChargingCurrent[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].PresentChargingCurrent);
  948. PresentChargingPower[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].PresentChargingPower);
  949. PresentChargedEnergy[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].PresentChargedEnergy);
  950. PresentChargedDuration[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].PresentChargedDuration);
  951. RemainChargingDuration[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].RemainChargingDuration);
  952. EvBatteryMaxVoltage[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].EvBatteryMaxVoltage);
  953. EvBatterytargetVoltage[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].EvBatterytargetVoltage);
  954. EvBatterySoc[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].EvBatterySoc);
  955. SystemStatus[2] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[GbGunQty].SystemStatus,1);
  956. Index[2] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[GbGunQty].Index,1);
  957. Type[2] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[GbGunQty].Type,1);
  958. type_index[2] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[GbGunQty].type_index,1);
  959. EvBatterytargetCurrent[2] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[GbGunQty].EvBatterytargetCurrent,1);
  960. GbGunQty++;
  961. }
  962. else if(connectorType3 == 3){//CHAdeMO
  963. PresentChargingVoltage[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].PresentChargingVoltage);
  964. PresentChargingCurrent[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].PresentChargingCurrent);
  965. PresentChargingPower[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].PresentChargingPower);
  966. PresentChargedEnergy[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].PresentChargedEnergy);
  967. PresentChargedDuration[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].PresentChargedDuration);
  968. RemainChargingDuration[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].RemainChargingDuration);
  969. EvBatteryMaxVoltage[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].EvBatteryMaxVoltage);
  970. EvBatterytargetVoltage[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].EvBatterytargetVoltage);
  971. EvBatterySoc[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].EvBatterySoc);
  972. SystemStatus[2] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CHAdeMOGunQty].SystemStatus,1);
  973. Index[2] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CHAdeMOGunQty].Index,1);
  974. Type[2] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CHAdeMOGunQty].Type,1);
  975. type_index[2] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CHAdeMOGunQty].type_index,1);
  976. EvBatterytargetCurrent[2] = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CHAdeMOGunQty].EvBatterytargetCurrent,1);
  977. CHAdeMOGunQty++;
  978. }
  979. }
  980. //network
  981. InternetConn = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.InternetConn,1);
  982. FtpServer = json_object_new_string(&ShmSysConfigAndInfo->SysConfig.FtpServer);
  983. Eth0DhcpClient = json_object_new_string_len(&ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient,1);
  984. Eth0MacAddress = json_object_new_string(ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthMacAddress);
  985. Eth0IpAddress = json_object_new_string(ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress);
  986. Eth0SubmaskAddress = json_object_new_string(ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthSubmaskAddress);
  987. Eth0GatewayAddress = json_object_new_string(ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthGatewayAddress);
  988. Eth1DhcpClient = json_object_new_string_len(&ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthDhcpClient,1);
  989. Eth1MacAddress = json_object_new_string(ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthMacAddress);
  990. Eth1IpAddress = json_object_new_string(ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthIpAddress);
  991. Eth1SubmaskAddress = json_object_new_string(ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthSubmaskAddress);
  992. Eth1GatewayAddress = json_object_new_string(ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthGatewayAddress);
  993. WifiMode = json_object_new_string_len(&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode,1);
  994. WifiSsid = json_object_new_string(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiSsid);
  995. WifiPassword = json_object_new_string(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiPassword);
  996. WifiRssi = json_object_new_int((int)ShmSysConfigAndInfo->SysConfig.AthInterface.WifiRssi);
  997. WifiDhcpServer = json_object_new_string_len(&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiDhcpServer,1);
  998. WifiDhcpClient = json_object_new_string_len(&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiDhcpClient,1);
  999. WifiMacAddress = json_object_new_string(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMacAddress);
  1000. WifiIpAddress = json_object_new_string(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiIpAddress);
  1001. WifiSubmaskAddress = json_object_new_string(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiSubmaskAddress);
  1002. WifiGatewayAddress = json_object_new_string(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiGatewayAddress);
  1003. TelcomApn = json_object_new_string(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn);
  1004. TelcomRssi = json_object_new_int((int)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomRssi);
  1005. TelcomChapPapId = json_object_new_string(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId);
  1006. TelcomChapPapPwd = json_object_new_string(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd);
  1007. TelcomModemImei = json_object_new_string(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemImei);
  1008. TelcomSimImsi = json_object_new_string(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimImsi);
  1009. //TelcomSimIccid = json_object_new_string(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimIccid);
  1010. TelcomSimStatus = json_object_new_string_len(&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimStatus,1);
  1011. TelcomModemMode = json_object_new_string_len(&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemMode,1);
  1012. TelcomIpAddress = json_object_new_string(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomIpAddress);
  1013. //backend
  1014. BackendConnTimeout = json_object_new_int((int)ShmSysConfigAndInfo->SysConfig.BackendConnTimeout);
  1015. OfflinePolicy = json_object_new_string_len(&ShmSysConfigAndInfo->SysConfig.OfflinePolicy,1);
  1016. OfflineMaxChargeEnergy = json_object_new_int((int)ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy);
  1017. OfflineMaxChargeDuration = json_object_new_int((int)ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeDuration);
  1018. OcppConnStatus = json_object_new_string_len(&ShmSysConfigAndInfo->SysInfo.OcppConnStatus,1);
  1019. OcppServerURL = json_object_new_string(ShmSysConfigAndInfo->SysConfig.OcppServerURL);
  1020. ChargeBoxId = json_object_new_string(ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  1021. //system
  1022. json_object_object_add(jobj1,"ModelName",ModelName);
  1023. json_object_object_add(jobj1,"SerialNumber",SerialNumber);
  1024. json_object_object_add(jobj1,"SystemId",SystemId);
  1025. json_object_object_add(jobj1,"SystemDateTime",SystemDateTime);
  1026. json_object_object_add(jobj1,"FactoryConfiguration",FactoryConfiguration);
  1027. json_object_object_add(jobj1,"AuthorisationMode",AuthorisationMode);
  1028. json_object_object_add(jobj1,"DefaultLanguage",DefaultLanguage);
  1029. json_object_object_add(jobj1,"InputVoltageR",InputVoltageR);
  1030. json_object_object_add(jobj1,"InputVoltageS",InputVoltageS);
  1031. json_object_object_add(jobj1,"InputVoltageT",InputVoltageT);
  1032. json_object_object_add(jobj1,"SystemFanRotaSpeed",SystemFanRotaSpeed);
  1033. json_object_object_add(jobj1,"PsuFanRotaSpeed",PsuFanRotaSpeed);
  1034. json_object_object_add(jobj1,"RfidCardNumEndian",RfidCardNumEndian);
  1035. json_object_object_add(jobj1,"AuxPower5V",AuxPower5V);
  1036. json_object_object_add(jobj1,"AuxPower12V",AuxPower12V);
  1037. json_object_object_add(jobj1,"AuxPower24V",AuxPower24V);
  1038. json_object_object_add(jobj1,"AuxPower48V",AuxPower48V);
  1039. json_object_object_add(jobj1,"CsuHwRev",CsuHwRev);
  1040. json_object_object_add(jobj1,"CsuBootLoadFwRev",CsuBootLoadFwRev);
  1041. json_object_object_add(jobj1,"CsuKernelFwRev",CsuKernelFwRev);
  1042. json_object_object_add(jobj1,"CsuRootFsFwRev",CsuRootFsFwRev);
  1043. json_object_object_add(jobj1,"CsuPrimFwRev",CsuPrimFwRev);
  1044. json_object_object_add(jobj1,"LcmHwRev",LcmHwRev);
  1045. json_object_object_add(jobj1,"LcmFwRev",LcmFwRev);
  1046. json_object_object_add(jobj1,"PsuHwRev",PsuHwRev);
  1047. json_object_object_add(jobj1,"PsuPrimFwRev",PsuPrimFwRev);
  1048. json_object_object_add(jobj1,"PsuSecFwRev",PsuSecFwRev);
  1049. json_object_object_add(jobj1,"AuxPwrHwRev",AuxPwrHwRev);
  1050. json_object_object_add(jobj1,"AuxPwrFwRev",AuxPwrFwRev);
  1051. json_object_object_add(jobj1,"FanModuleHwRev",FanModuleHwRev);
  1052. json_object_object_add(jobj1,"FanModuleFwRev",FanModuleFwRev);
  1053. json_object_object_add(jobj1,"RelayModuleHwRev",RelayModuleHwRev);
  1054. json_object_object_add(jobj1,"RelayModuleFwRev",RelayModuleFwRev);
  1055. json_object_object_add(jobj1,"TelcomModemFwRev",TelcomModemFwRev);
  1056. json_object_object_add(jobj1,"SystemAmbientTemp",SystemAmbientTemp);
  1057. json_object_object_add(jobj1,"SystemCriticalTemp",SystemCriticalTemp);
  1058. json_object_object_add(jobj1,"CcsConnectorTemp",CcsConnectorTemp);
  1059. json_object_object_add(jobj1,"PsuAmbientTemp",PsuAmbientTemp);
  1060. json_object_object_add(jobj1,"AcPlugInTimes",AcPlugInTimes);
  1061. json_object_object_add(jobj1,"GbPlugInTimes",GbPlugInTimes);
  1062. json_object_object_add(jobj1,"Ccs1PlugInTimes",Ccs1PlugInTime);
  1063. json_object_object_add(jobj1,"Ccs2PlugInTimes",Ccs2PlugInTimes);
  1064. json_object_object_add(jobj1,"ChademoPlugInTimes",ChademoPlugInTimes);
  1065. printf("%s\n", json_object_to_json_string(jobj1));
  1066. json_object_put(jobj1);
  1067. //charging
  1068. json_object_object_add(jobj2,"MaxChargingEnergy",MaxChargingEnergy);
  1069. json_object_object_add(jobj2,"MaxChargingPower",MaxChargingPower);
  1070. json_object_object_add(jobj2,"MaxChargingCurrent",MaxChargingCurrent);
  1071. json_object_object_add(jobj2,"MaxChargingDuration",MaxChargingDuration);
  1072. json_object_object_add(jobj2,"PhaseLossPolicy",PhaseLossPolicy);
  1073. json_object_array_add(LocalWhiteCardArr,LocalWhiteCard[0]);
  1074. json_object_array_add(LocalWhiteCardArr,LocalWhiteCard[1]);
  1075. json_object_array_add(LocalWhiteCardArr,LocalWhiteCard[2]);
  1076. json_object_array_add(LocalWhiteCardArr,LocalWhiteCard[3]);
  1077. json_object_array_add(LocalWhiteCardArr,LocalWhiteCard[4]);
  1078. json_object_array_add(LocalWhiteCardArr,LocalWhiteCard[5]);
  1079. json_object_array_add(LocalWhiteCardArr,LocalWhiteCard[6]);
  1080. json_object_array_add(LocalWhiteCardArr,LocalWhiteCard[7]);
  1081. json_object_array_add(LocalWhiteCardArr,LocalWhiteCard[8]);
  1082. json_object_array_add(LocalWhiteCardArr,LocalWhiteCard[9]);
  1083. json_object_object_add(jobj2,"LocalWhiteCard",LocalWhiteCardArr);
  1084. // json_object_object_add(jobj2,"CcsAuthentication",CcsAuthentication);
  1085. // json_object_object_add(jobj2,"AcCcsChargingMode",AcCcsChargingMode);
  1086. json_object_object_add(jobj2,"UserId",UserId);
  1087. if(connectorType1 != 0){
  1088. json_object_object_add(ChargingInfo1,"PresentChargingVoltage",PresentChargingVoltage[0]);
  1089. json_object_object_add(ChargingInfo1,"PresentChargingCurrent",PresentChargingCurrent[0]);
  1090. json_object_object_add(ChargingInfo1,"PresentChargingPower",PresentChargingPower[0]);
  1091. json_object_object_add(ChargingInfo1,"PresentChargedEnergy",PresentChargedEnergy[0]);
  1092. json_object_object_add(ChargingInfo1,"PresentChargedDuration",PresentChargedDuration[0]);
  1093. json_object_object_add(ChargingInfo1,"RemainChargingDuration",RemainChargingDuration[0]);
  1094. json_object_object_add(ChargingInfo1,"EvBatteryMaxVoltage",EvBatteryMaxVoltage[0]);
  1095. json_object_object_add(ChargingInfo1,"EvBatterytargetVoltage",EvBatterytargetVoltage[0]);
  1096. json_object_object_add(ChargingInfo1,"EvBatterySoc",EvBatterySoc[0]);
  1097. json_object_object_add(ChargingInfo1,"SystemStatus",SystemStatus[0]);
  1098. json_object_object_add(ChargingInfo1,"Index",Index[0]);
  1099. json_object_object_add(ChargingInfo1,"Type",Type[0]);
  1100. json_object_object_add(ChargingInfo1,"type_index",type_index[0]);
  1101. json_object_object_add(ChargingInfo1,"EvBatterytargetCurrent",EvBatterytargetCurrent[0]);
  1102. json_object_object_add(jobj2,"ChargingInfo1",ChargingInfo1);
  1103. }
  1104. if(connectorType2 != 0){
  1105. json_object_object_add(ChargingInfo2,"PresentChargingVoltage",PresentChargingVoltage[1]);
  1106. json_object_object_add(ChargingInfo2,"PresentChargingCurrent",PresentChargingCurrent[1]);
  1107. json_object_object_add(ChargingInfo2,"PresentChargingPower",PresentChargingPower[1]);
  1108. json_object_object_add(ChargingInfo2,"PresentChargedEnergy",PresentChargedEnergy[1]);
  1109. json_object_object_add(ChargingInfo2,"PresentChargedDuration",PresentChargedDuration[1]);
  1110. json_object_object_add(ChargingInfo2,"RemainChargingDuration",RemainChargingDuration[1]);
  1111. json_object_object_add(ChargingInfo2,"EvBatteryMaxVoltage",EvBatteryMaxVoltage[1]);
  1112. json_object_object_add(ChargingInfo2,"EvBatterytargetVoltage",EvBatterytargetVoltage[1]);
  1113. json_object_object_add(ChargingInfo2,"EvBatterySoc",EvBatterySoc[1]);
  1114. json_object_object_add(ChargingInfo2,"SystemStatus",SystemStatus[1]);
  1115. json_object_object_add(ChargingInfo2,"Index",Index[1]);
  1116. json_object_object_add(ChargingInfo2,"Type",Type[1]);
  1117. json_object_object_add(ChargingInfo2,"type_index",type_index[1]);
  1118. json_object_object_add(ChargingInfo2,"EvBatterytargetCurrent",EvBatterytargetCurrent[1]);
  1119. json_object_object_add(jobj2,"ChargingInfo2",ChargingInfo2);
  1120. }
  1121. if(connectorType3 != 0){
  1122. json_object_object_add(ChargingInfo3,"PresentChargingVoltage",PresentChargingVoltage[2]);
  1123. json_object_object_add(ChargingInfo3,"PresentChargingCurrent",PresentChargingCurrent[2]);
  1124. json_object_object_add(ChargingInfo3,"PresentChargingPower",PresentChargingPower[2]);
  1125. json_object_object_add(ChargingInfo3,"PresentChargedEnergy",PresentChargedEnergy[2]);
  1126. json_object_object_add(ChargingInfo3,"PresentChargedDuration",PresentChargedDuration[2]);
  1127. json_object_object_add(ChargingInfo3,"RemainChargingDuration",RemainChargingDuration[2]);
  1128. json_object_object_add(ChargingInfo3,"EvBatteryMaxVoltage",EvBatteryMaxVoltage[2]);
  1129. json_object_object_add(ChargingInfo3,"EvBatterytargetVoltage",EvBatterytargetVoltage[2]);
  1130. json_object_object_add(ChargingInfo3,"EvBatterySoc",EvBatterySoc[2]);
  1131. json_object_object_add(ChargingInfo3,"SystemStatus",SystemStatus[2]);
  1132. json_object_object_add(ChargingInfo3,"Index",Index[2]);
  1133. json_object_object_add(ChargingInfo3,"Type",Type[2]);
  1134. json_object_object_add(ChargingInfo3,"type_index",type_index[2]);
  1135. json_object_object_add(ChargingInfo3,"EvBatterytargetCurrent",EvBatterytargetCurrent[2]);
  1136. json_object_object_add(jobj2,"ChargingInfo3",ChargingInfo3);
  1137. }
  1138. printf("%s\n", json_object_to_json_string(jobj2));
  1139. json_object_put(jobj2);
  1140. //network
  1141. json_object_object_add(jobj3,"InternetConn",InternetConn);
  1142. json_object_object_add(jobj3,"FtpServer",FtpServer);
  1143. json_object_object_add(jobj3,"Eth0DhcpClient",Eth0DhcpClient);
  1144. json_object_object_add(jobj3,"Eth0MacAddress",Eth0MacAddress);
  1145. json_object_object_add(jobj3,"Eth0IpAddress",Eth0IpAddress);
  1146. json_object_object_add(jobj3,"Eth0SubmaskAddress",Eth0SubmaskAddress);
  1147. json_object_object_add(jobj3,"Eth0GatewayAddress",Eth0GatewayAddress);
  1148. json_object_object_add(jobj3,"Eth1DhcpClient",Eth1DhcpClient);
  1149. json_object_object_add(jobj3,"Eth1MacAddress",Eth1MacAddress);
  1150. json_object_object_add(jobj3,"Eth1IpAddress",Eth1IpAddress);
  1151. json_object_object_add(jobj3,"Eth1SubmaskAddress",Eth1SubmaskAddress);
  1152. json_object_object_add(jobj3,"Eth1GatewayAddress",Eth1GatewayAddress);
  1153. json_object_object_add(jobj3,"WifiMode",WifiMode);
  1154. json_object_object_add(jobj3,"WifiSsid",WifiSsid);
  1155. json_object_object_add(jobj3,"WifiPassword",WifiPassword);
  1156. json_object_object_add(jobj3,"WifiRssi",WifiRssi);
  1157. json_object_object_add(jobj3,"WifiDhcpServer",WifiDhcpServer);
  1158. json_object_object_add(jobj3,"WifiDhcpClient",WifiDhcpClient);
  1159. json_object_object_add(jobj3,"WifiMacAddress",WifiMacAddress);
  1160. json_object_object_add(jobj3,"WifiIpAddress",WifiIpAddress);
  1161. json_object_object_add(jobj3,"WifiSubmaskAddress",WifiSubmaskAddress);
  1162. json_object_object_add(jobj3,"WifiGatewayAddress",WifiGatewayAddress);
  1163. json_object_object_add(jobj3,"TelcomApn",TelcomApn);
  1164. json_object_object_add(jobj3,"TelcomRssi",TelcomRssi);
  1165. json_object_object_add(jobj3,"TelcomChapPapId",TelcomChapPapId);
  1166. json_object_object_add(jobj3,"TelcomChapPapPwd",TelcomChapPapPwd);
  1167. json_object_object_add(jobj3,"TelcomModemImei",TelcomModemImei);
  1168. json_object_object_add(jobj3,"TelcomSimImsi",TelcomSimImsi);
  1169. json_object_object_add(jobj3,"TelcomSimStatus",TelcomSimStatus);
  1170. json_object_object_add(jobj3,"TelcomModemMode",TelcomModemMode);
  1171. json_object_object_add(jobj3,"TelcomIpAddress",TelcomIpAddress);
  1172. printf("%s\n", json_object_to_json_string(jobj3));
  1173. json_object_put(jobj3);
  1174. //backend
  1175. json_object_object_add(jobj4,"BackendConnTimeout",BackendConnTimeout);
  1176. json_object_object_add(jobj4,"OfflinePolicy",OfflinePolicy);
  1177. json_object_object_add(jobj4,"OfflineMaxChargeEnergy",OfflineMaxChargeEnergy);
  1178. json_object_object_add(jobj4,"OfflineMaxChargeDuration",OfflineMaxChargeDuration);
  1179. json_object_object_add(jobj4,"OcppConnStatus",OcppConnStatus);
  1180. json_object_object_add(jobj4,"OcppServerURL",OcppServerURL);
  1181. json_object_object_add(jobj4,"ChargeBoxId",ChargeBoxId);
  1182. printf("%s\n", json_object_to_json_string(jobj4));
  1183. json_object_put(jobj4);
  1184. }
  1185. // for(;;)
  1186. // {
  1187. // }
  1188. return FAIL;
  1189. }