main.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770
  1. /*
  2. * Config.h
  3. *
  4. * Created on: 2020/01/15
  5. * Author: Eason Yang
  6. */
  7. #ifndef CONFIG_MAIN_H_
  8. #define CONFIG_MAIN_H_
  9. #include <sys/types.h>
  10. #include <sys/stat.h>
  11. #include <sys/time.h>
  12. #include <sys/timeb.h>
  13. #include <sys/types.h>
  14. #include <sys/ioctl.h>
  15. #include <sys/socket.h>
  16. #include <sys/ipc.h>
  17. #include <sys/shm.h>
  18. #include <sys/mman.h>
  19. #include <linux/wireless.h>
  20. #include <arpa/inet.h>
  21. #include <netinet/in.h>
  22. #include <dirent.h>
  23. #include <unistd.h>
  24. #include <stdarg.h>
  25. #include <stdio.h>
  26. #include <stdlib.h>
  27. #include <unistd.h>
  28. #include <fcntl.h>
  29. #include <termios.h>
  30. #include <errno.h>
  31. #include <errno.h>
  32. #include <string.h>
  33. #include <time.h>
  34. #include <ctype.h>
  35. #include <ifaddrs.h>
  36. #include <stdbool.h>
  37. #include <stddef.h>
  38. #include <stdint.h>
  39. #include <sqlite3.h>
  40. //===================================
  41. // Define Alarm code constant
  42. //===================================
  43. #define ALARM_L1_OVER_VOLTAGE 0x00000001
  44. #define ALARM_L1_UNDER_VOLTAGE 0x00000002
  45. #define ALARM_L1_OVER_CURRENT 0x00000004
  46. #define ALARM_OVER_TEMPERATURE 0x00000008
  47. #define ALARM_GROUND_FAIL 0x00000010
  48. #define ALARM_CP_ERROR 0x00000020
  49. #define ALARM_CURRENT_LEAK_AC 0x00000040
  50. #define ALARM_CURRENT_LEAK_DC 0x00000080
  51. #define ALARM_MCU_TESTFAIL 0x00000100
  52. #define ALARM_HANDSHAKE_TIMEOUT 0x00000200
  53. #define ALARM_EMERGENCY_STOP 0x00000400
  54. #define ALARM_RELAY_WELDING 0x00000800
  55. #define ALARM_LEAK_MODULE_FAIL 0x00001000
  56. #define ALARM_SHUTTER_FAULT 0x00002000
  57. #define ALARM_LOCKER_FAULT 0x00004000
  58. #define ALARM_POWER_DROP 0x00008000
  59. #define ALARM_L1_CIRCUIT_SHORT 0x00010000
  60. #define ALARM_ROTATORY_SWITCH_FAULT 0x00020000
  61. #define ALARM_RELAY_DRIVE_FAULT 0x00040000
  62. #define ALARM_BLE_MODULE_BROKEN 0x00080000
  63. #define ALARM_L2_OVER_VOLTAGE 0x00100000
  64. #define ALARM_L3_OVER_VOLTAGE 0x00200000
  65. #define ALARM_L2_UNDER_VOLTAGE 0x00400000
  66. #define ALARM_L3_UNDER_VOLTAGE 0x00800000
  67. #define ALARM_L2_OVER_CURRENT 0x01000000
  68. #define ALARM_L3_OVER_CURRENT 0x02000000
  69. #define ALARM_L2_CIRCUIT_SHORT 0x04000000
  70. #define ALARM_L3_CIRCUIT_SHORT 0x08000000
  71. #define ALARM_METER_TIMEOUT 0x10000000
  72. #define ALARM_METER_IC_TIMEOUT 0x20000000
  73. //=================================
  74. //CCS related define
  75. //=================================
  76. #define CCS_PWM_DUTY_CP_STATE_F 0
  77. #define CCS_PWM_DUTY_CP_STATE_E 1
  78. #define CCS_PWM_DUTY_5 5
  79. #define CCS_PWM_DUTY_100 100
  80. //===================================
  81. // Define CP State constant
  82. //===================================
  83. enum CP_STATE
  84. {
  85. CP_STATE_UNKNOWN=0,
  86. CP_STATE_A,
  87. CP_STATE_B,
  88. CP_STATE_C,
  89. CP_STATE_D,
  90. CP_STATE_E,
  91. CP_STATE_F
  92. };
  93. //===================================
  94. // Define CCS CP State constant
  95. //===================================
  96. enum CCS_CP_STATE
  97. {
  98. CCS_CP_STATE_UNKNOWN=0,
  99. CCS_CP_STATE_A, //A (12V, no PWM)
  100. CCS_CP_STATE_B1, //B1 (9V, no PWM)
  101. CCS_CP_STATE_B2, //B2 (9V, with PWM)
  102. CCS_CP_STATE_C, //C (6V, with PWM)
  103. CCS_CP_STATE_D, //D (3V, with PWM)
  104. CCS_CP_STATE_E, //E (0V, no PWM)
  105. CCS_CP_STATE_F, //F (-12V, no PWM)
  106. CCS_CP_STATE_G, //G (>12V)
  107. CCS_CP_STATE_H //H (<12V)
  108. };
  109. //===================================
  110. // Define Speaker type constant
  111. //===================================
  112. enum SPEAKER_ACTION
  113. {
  114. SPEAKER_STOP=0,
  115. SPEAKER_ALWAYS_ON,
  116. SPEAKER_SHORT,
  117. SPEAKER_LONG,
  118. SPEAKER_INTERVAL_SHORT,
  119. SPEAKER_INTERVAL_LONG,
  120. SPEAKER_INTERVAL_3COUNT
  121. };
  122. //===================================
  123. // Define Led constant
  124. //===================================
  125. enum LED_ACTION
  126. {
  127. LED_ACTION_INIT=0,
  128. LED_ACTION_IDLE,
  129. LED_ACTION_AUTHED,
  130. LED_ACTION_CONNECTED,
  131. LED_ACTION_CHARGING,
  132. LED_ACTION_STOP,
  133. LED_ACTION_ALARM,
  134. LED_ACTION_MAINTAIN,
  135. LED_ACTION_RFID_PASS,
  136. LED_ACTION_RFID_FAIL,
  137. LED_ACTION_BLE_CONNECT,
  138. LED_ACTION_BLE_DISABLE,
  139. LED_ACTION_DEBUG,
  140. LED_ACTION_ALL_OFF,
  141. LED_RELAY_ON,
  142. LED_RELAY_OFF,
  143. LED_ACTION_HANDSHAKE_FAIL,
  144. LED_ACTION_INTERNET_DISCONNECT
  145. };
  146. //===================================
  147. // Define start mode constant
  148. //===================================
  149. enum START_METHOD
  150. {
  151. START_METHOD_FREE=0,
  152. START_METHOD_RFID,
  153. START_METHOD_BACKEND,
  154. START_METHOD_BLE
  155. };
  156. enum HANDSHAKE_STATE
  157. {
  158. HANDSHAKE_IDLE=0,
  159. HANDSHAKE_DUTY_5,
  160. HANDSHAKE_DUTY_5_CHECK,
  161. HANDSHAKE_CCS,
  162. HANDSHAKE_CP_STATE_E,
  163. HANDSHAKE_SET_MAX_CURRENT,
  164. HANDSHAKE_BS_MODE,
  165. HANDSHAKE_HLC_MODE
  166. };
  167. enum EV_READY_STATE
  168. {
  169. EV_READY_STAT_E=1,
  170. EV_READY_STAT_C,
  171. EV_READY_SET_MAX_CURRENT
  172. };
  173. enum CHARGING_MODE
  174. {
  175. CHARGING_MODE_BS=0,
  176. CHARGING_MODE_HLC,
  177. CHARGING_MODE_SOCKETE
  178. };
  179. enum HLC_MODE
  180. {
  181. HLC_STOP_MODE=0,
  182. HLC_START_MODE,
  183. HLC_RENEGOTIATE_MODE,
  184. HLC_STANDBY_MODE
  185. };
  186. enum EVSE_NOTIFICATION
  187. {
  188. NOTIFICATION_NONE=0,
  189. NOTIFICATION_STOP,
  190. NOTIFICATION_RENEGOTIATION
  191. };
  192. enum TIMER_IDX
  193. {
  194. TMR_IDX_HANDSHAKING=0,
  195. TMR_IDX_AUTH,
  196. TMR_IDX_LOGPPRINTOUT,
  197. TMR_IDX_PROFILE_PREPARE,
  198. TMR_IDX_BS_HLC_HANDSHAKE,
  199. TMR_IDX_CCS_HEARTBEAT_COUNT_RESET,
  200. TMR_IDX_PWN_CHANGE,
  201. TMR_IDX_POWERSAVING_LCD,
  202. TMR_IDX_POWERSAVING_RFID,
  203. TMR_IDX_POWERSAVING_METER,
  204. TMR_IDX_POWERSAVING_STATE_B,
  205. TMR_IDX_CHECK_TASK,
  206. TMR_IDX_12,
  207. TMR_IDX_13,
  208. TMR_IDX_14,
  209. TMR_IDX_15,
  210. TMR_IDX_16,
  211. TMR_IDX_17,
  212. TMR_IDX_18,
  213. TMR_IDX_19,
  214. TMR_IDX_GUN_DETECT,
  215. TMR_IDX_CNT
  216. };
  217. //===================================
  218. // Define Authorization State constant
  219. //===================================
  220. enum RFID_AUTHORIZATION_STATUS
  221. {
  222. DEFAULT_RFID = 0,
  223. VALIDATED_RFID,
  224. UNVALIDATED_RFID,
  225. UNKNOW_RFID
  226. };
  227. #define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
  228. #define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
  229. #define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
  230. extern int StoreLogMsg(const char *fmt, ...);
  231. //============================================================
  232. // Private shared memory key define
  233. //============================================================
  234. #define ShmChargerKey 2001
  235. typedef struct Verion
  236. {
  237. char Version_FW[32];
  238. char Version_HW[32];
  239. }Ver;
  240. typedef struct PRESENTINPUTVOLTAGE
  241. {
  242. unsigned char inputType; // 0x00: Line to Line 0x01: Line to Neutral
  243. double L1N_L12;
  244. double L2N_L23;
  245. double L3N_L31;
  246. }PresentInputVoltage;
  247. typedef struct PRESENTOUTPUTVOLTAGE
  248. {
  249. double behindFuse_Voltage_C1;
  250. double behindRelay_Voltage_C1;
  251. double behindFuse_Voltage_C2;
  252. double behindRelay_Voltage_C2;
  253. }PresentOutputVoltage;
  254. typedef struct FANSPEED
  255. {
  256. unsigned short int speed[4];
  257. }FanSpeed;
  258. typedef struct TEMPERATURE
  259. {
  260. unsigned char point[8];
  261. }Temperature;
  262. typedef struct AUXPOWER
  263. {
  264. unsigned char voltage[8];
  265. }AuxPower;
  266. typedef struct RELAY
  267. {
  268. unsigned char relay_status[2][8];
  269. }Relay;
  270. typedef struct GFD
  271. {
  272. unsigned short int adc_value_positive[2];
  273. unsigned short int adc_value_negative[2];
  274. }Gfd;
  275. typedef struct GPIO_IN
  276. {
  277. unsigned char AC_Connector;
  278. unsigned char AC_MainBreaker;
  279. unsigned char SPD;
  280. unsigned char Door_Open;
  281. unsigned char GFD[2];
  282. unsigned char Button[2];
  283. unsigned char Button_Emergency;
  284. unsigned char Button_Mode_Switch;
  285. }Gpio_in;
  286. typedef struct GPIO_OUT
  287. {
  288. unsigned char AC_Connector;
  289. unsigned char Button_LED[2];
  290. unsigned char System_LED[4];
  291. }Gpio_out;
  292. typedef struct ALARM_LOG
  293. {
  294. unsigned char logArea;
  295. unsigned int alarmIndex;
  296. unsigned char log[8];
  297. }Alarm_Log;
  298. typedef struct BLE_CONFIG_DATA
  299. {
  300. unsigned char isLogin:1;
  301. unsigned char isRequestStart:1;
  302. unsigned char isRequestStop:1;
  303. }Ble_Config_Data;
  304. typedef struct BLE_LONGIN_CENTRAL_ID
  305. {
  306. unsigned char id[32];
  307. }Ble_Login_Central_Id;
  308. typedef struct RTC
  309. {
  310. unsigned short int year;
  311. unsigned char month;
  312. unsigned char day;
  313. unsigned char hour;
  314. unsigned char min;
  315. unsigned char sec;
  316. }Rtc;
  317. typedef struct PRESENTOUTPUTCURRENT
  318. {
  319. double L1N_L12[2];
  320. double L2N_L23[2];
  321. double L3N_L31[2];
  322. }Presentoutputcurrent;
  323. typedef struct SOCKET_E
  324. {
  325. unsigned char isSocketEMode:1;
  326. unsigned char isSocketEPinOn:1;
  327. }Socket_E;
  328. typedef struct AC_PRIMARY_MCU
  329. {
  330. unsigned char cp_state;
  331. unsigned int current_limit;
  332. float cp_voltage_positive;
  333. float cp_voltage_negtive;
  334. unsigned char locker_state;
  335. unsigned char relay_state;
  336. unsigned char shutter_state;
  337. unsigned char meter_state;
  338. unsigned char pp_state;
  339. unsigned char rating_current;
  340. unsigned char rotatory_switch;
  341. Relay relayState;
  342. Socket_E socket_e;
  343. }Ac_Primary_Mcu;
  344. typedef struct AC_PRIMARY_MCU_ALARM
  345. {
  346. union
  347. {
  348. unsigned long InputAlarmCode;
  349. struct
  350. {
  351. unsigned long OVP_L1:1;
  352. unsigned long UVP_L1:1;
  353. unsigned long OCP_L1:1;
  354. unsigned long OTP:1;
  355. unsigned long gmi_fault:1;
  356. unsigned long cp_fault:1;
  357. unsigned long ac_leak:1;
  358. unsigned long dc_leak:1;
  359. unsigned long mcu_selftest_fail:1;
  360. unsigned long handshaking_timeout:1;
  361. unsigned long emergency_stop:1;
  362. unsigned long relay_welding:1;
  363. unsigned long leak_module_fail:1;
  364. unsigned long shutter_fault:1;
  365. unsigned long locker_fault:1;
  366. unsigned long power_drop:1;
  367. unsigned long rotate_switch_fault:1;
  368. unsigned long short_circuit_L1:1;
  369. unsigned long relay_drive_fault:1;
  370. unsigned long comm_timeout:1;
  371. unsigned long OVP_L2:1;
  372. unsigned long UVP_L2:1;
  373. unsigned long OCP_L2:1;
  374. unsigned long OVP_L3:1;
  375. unsigned long UVP_L3:1;
  376. unsigned long OCP_L3:1;
  377. unsigned long short_circuit_L2:1;
  378. unsigned long short_circuit_L3:1;
  379. unsigned long meter_comm_timeout:1;
  380. unsigned long meter_ic_comm_timeout:1;
  381. }bits;
  382. };
  383. }Ac_Primary_Mcu_Alarm;
  384. typedef struct AC_PRIMARY_MCU_LED
  385. {
  386. unsigned char mode;
  387. unsigned long alarm_code;
  388. }Ac_Primary_Mcu_Led;
  389. typedef struct EVSE_ID
  390. {
  391. unsigned char model_name[14];
  392. unsigned char serial_number[12];
  393. }Evse_Id;
  394. typedef struct AC_PRIMARY_MCU_CP_PWM_DUTY
  395. {
  396. unsigned int max_current;
  397. }Ac_Primary_Mcu_Cp_Pwm_Duty;
  398. typedef struct LEGACY_REQUEST
  399. {
  400. unsigned char isLegacyRequest:1;
  401. uint8_t isRelayOn:1;
  402. }Legacy_Request;
  403. typedef struct POWER_CONSUMPTION
  404. {
  405. uint64_t power_consumption;
  406. uint64_t power_consumption_at_start;
  407. }Power_Consumption;
  408. typedef struct MCU_OP_FLAG
  409. {
  410. unsigned char isSetModePass:1;
  411. unsigned char isSetSerialNumberPass:1;
  412. unsigned char isSetModelNamePass:1;
  413. unsigned char isReadFwVerPass:1;
  414. unsigned char isMcuUpgradeReq:1;
  415. unsigned char isSetCpPwmDuty:1;
  416. unsigned char isReadMeterIcCorrectionStatus:1;
  417. }Mcu_Op_Flag;
  418. typedef struct SYSTEM_ALARM_CODE
  419. {
  420. unsigned long SystemAlarmCode;
  421. }System_Alarm_Code;
  422. typedef struct OTHER_ALARM_CODE
  423. {
  424. unsigned long isHandshakingTimeOut:1;
  425. unsigned long isDcLeakage:1;
  426. unsigned long isACLeakage:1;
  427. }Other_Alarm_Code;
  428. typedef struct PILOT_VOLTAGE
  429. {
  430. float PilotVoltagePositive;
  431. float PilotVoltageNegative;
  432. }Pilot_Voltage;
  433. typedef struct FW_UPGRADE_INFO
  434. {
  435. int fwType;
  436. char modelName[17];
  437. char location[384];
  438. }Fw_Upgrade_Info;
  439. typedef struct GUN_PLUGIN_TIMES
  440. {
  441. uint32_t GunPluginTimes;
  442. }Gun_Plugin_Times;
  443. typedef struct MCU_RESET_REQUEST
  444. {
  445. unsigned char isMcuResetRequest:1;
  446. }Mcu_Reset_Request;
  447. typedef struct TIMEOUT_SPEC
  448. {
  449. int Setting_Timeout_Spec;
  450. int Present_Timeout_Spec;
  451. }Timeout_Spec;
  452. typedef struct SET_BREATHE_LED_TIMING
  453. {
  454. uint16_t set_Led_Action_Connected_Fade_In;
  455. uint16_t set_Led_Action_Connected_Fade_Out;
  456. uint16_t set_Led_Action_Authed_Fade_In;
  457. uint16_t set_Led_Action_Authed_Fade_Out;
  458. uint16_t Set_Led_Action_Chaging_Fade_In;
  459. uint16_t set_Led_Action_Chaging_Fade_Out;
  460. }Set_Breathe_Led_Timing;
  461. typedef struct SET_LED_BRIGHTNESS
  462. {
  463. uint8_t sector_1; // 0~1 AM and 1~2 AM
  464. uint8_t sector_2; // 2~3 AM and 3~4 AM
  465. uint8_t sector_3; // 4~5 AM and 5~6 AM
  466. uint8_t sector_4; // 6~7 AM and 7~8 AM
  467. uint8_t sector_5; // 8~9 AM and 9~10 AM
  468. uint8_t sector_6; // 10~11 AM and 11~12 AM
  469. uint8_t sector_7; // 12~13 PM and 13~14 PM
  470. uint8_t sector_8; // 14~15 PM and 15~16 PM
  471. uint8_t sector_9; // 16~17 PM and 17~18 PM
  472. uint8_t sector_10; // 18~19 PM and 19~20 PM
  473. uint8_t sector_11; // 20~21 PM and 21~22 PM
  474. uint8_t sector_12; // 22~23 PM and 23~24 PM
  475. }Set_Led_Brightness;
  476. typedef struct SET_AUX_POWER_SWITCH
  477. {
  478. uint8_t power_type; // 0xff: All 0x01: Meter
  479. uint8_t power_switch; // 0: OFF 1: ON
  480. }Set_Aux_Power_Switch;
  481. typedef union
  482. {
  483. unsigned int value;
  484. struct
  485. {
  486. unsigned int isCalibratedVaGain:1; // Voltage phase a gain is calibrated, 0: default 1: Calibrated
  487. unsigned int isCalibratedVbGain:1; // Voltage phase b gain is calibrated, 0: default 1: Calibrated
  488. unsigned int isCalibratedVcGain:1; // Voltage phase c gain is calibrated, 0: default 1: Calibrated
  489. unsigned int isCalibratedVaOffset:1; // Voltage phase a offset is calibrated, 0: default 1: Calibrated
  490. unsigned int isCalibratedVbOffset:1; // Voltage phase b offset is calibrated, 0: default 1: Calibrated
  491. unsigned int isCalibratedVcOffset:1; // Voltage phase c offset is calibrated, 0: default 1: Calibrated
  492. unsigned int isCalibratedCaGain:1; // Current phase a gain is calibrated, 0: default 1: Calibrated
  493. unsigned int isCalibratedCbGain:1; // Current phase b gain is calibrated, 0: default 1: Calibrated
  494. unsigned int isCalibratedCcGain:1; // Current phase c gain is calibrated, 0: default 1: Calibrated
  495. unsigned int isCalibratedCaOffset:1; // Current phase a offset is calibrated, 0: default 1: Calibrated
  496. unsigned int isCalibratedCbOffset:1; // Current phase b offset is calibrated, 0: default 1: Calibrated
  497. unsigned int isCalibratedCcOffset:1; // Current phase c offset is calibrated, 0: default 1: Calibrated
  498. unsigned int isCalibratedPa:1; // Phase angle a is calibrated, 0: default 1: Calibrated
  499. unsigned int isCalibratedPb:1; // Phase angle b gain is calibrated, 0: default 1: Calibrated
  500. unsigned int isCalibratedPc:1; // Phase angle c gain is calibrated, 0: default 1: Calibrated
  501. unsigned int :17;
  502. }bits;
  503. }MeterIcCorrection;
  504. typedef struct CCS_INFO
  505. {
  506. uint8_t BatteryChargeType; /*0x00: AC charging, 0x01: DC charging*/
  507. uint8_t PresentMsgFlowStatus;
  508. /* ISO15118_2018
  509. 0: Idle(wait B2 state),
  510. 1: CM_SLAC_PARM.REQ,
  511. 2: CM_SLAC_PARM.CNF,
  512. 3: CM_START_ATTEN_CHAR.IND
  513. 4: CM_MNBC_SOUND.IND,
  514. 5: CM_ATTEN_CHAR.IND,
  515. 6: CM_ATTEN_CHAR.RSP,
  516. 7: CM_VALIDATE.REQ
  517. 8: CM_VALIDATE.CNF,
  518. 9: CM_SLAC_MATCH.REQ,
  519. 10: CM_SLAC_MATCH.CNF,
  520. 11: CM_AMP_MAP.REQ
  521. 12: CM_AMP_MAP.CNF,
  522. 13: SLACC/SDP/TCP connection,
  523. 16: SupportedAppProtocolRequest,
  524. 17: SupportedAppProtocolResponse,
  525. 18: SessionSetupRequest
  526. 19: SessionSetupResponse,
  527. 20: ServiceDiscoveryRequest,
  528. 21: ServiceDiscoveryResponse
  529. 22: ServiceDetailRequest,
  530. 23: ServiceDetailResponse
  531. 24:ServiceAndPaymentSelectionRequest/ServiceSelectionRequest,
  532. 25: ServiceAndPaymentSelectionResponse/ServiceSelectionResponse
  533. 26: PaymentDetailsRequest/IdentificationDetailsRequest;,
  534. 27: PaymentDetailsResponse/IdentificationDetailsResponse,
  535. 28: AuthorizationRequest,
  536. 29: AuthorizationResponse,
  537. 30: CertificateUpdateRequest,
  538. 31: CertificateUpdateResponse,
  539. 32:CertificateInstallationRequest,
  540. 33: CertificateInstallationResponse
  541. 34: ChargeParameterDiscoveryRequest,
  542. 35: ChargeParameterDiscoveryResponse
  543. 36: CableCheckRequest,
  544. 37: CableCheckResponse,
  545. 38: PreChargeRequest,
  546. 39: PreChargeResponse
  547. 40: PowerDeliveryRequest start,
  548. 41: PowerDeliveryResponse start,
  549. 42: ChargingStatusRequest,
  550. 43: ChargingStatusResponse
  551. 44:CurrentDemandRequest,
  552. 45:CurrentDemandResponse,
  553. 46:MeteringReceiptRequest,
  554. 47: MeteringReceiptResponse
  555. 48: PowerDeliveryRequest end,
  556. 49: PowerDeliveryRequest end,
  557. 50: WeldingDetectionRequest,
  558. 51: WeldingDetectionResponse,
  559. 52: SessionStopRequest,
  560. 53: SessionStopResponse
  561. 253: Performance Timeout,
  562. 254: Sequence Timeout,
  563. 255: Fault
  564. */
  565. float ConnectorTemperature1; /*unit: 1°C*/
  566. float ConnectorTemperature2; /*unit: 1°C*/
  567. uint16_t ChargingRemainTime; /*0x0000: 0 sec ~ 0xFFFF: 65535 sec, unit: 1 second*/
  568. float TotalBatteryCapacity; /*unit: Wh*/
  569. float BatteryMaximumVoltage; /*unit: 1 volt*/
  570. float BatteryMaximumCurrent; /*unit: 1 amp*/
  571. uint8_t EVCCID[8];
  572. uint8_t EVSEID[40];
  573. uint8_t CCSLibRev[32];
  574. uint8_t EVSEModelName[32];
  575. uint32_t CSUAlarmStatusCode;
  576. uint16_t CCSAlarmStatusCode;
  577. uint8_t PaymentOption; /* 0x00 EIM, 0x01 Pnc */
  578. float EVSEMaxCurrent; /*unit: 1 amp*/
  579. float EVSEMinCurrent; /*unit: 1 amp*/
  580. float GridVoltage[3]; /*unit: 1 volt*/
  581. uint8_t MeterID[32]; /*unit: 1 amp*/
  582. float MeterReadingValue; /*unit: 1Wh*/
  583. uint8_t EVOperation; /*0:Charge, 1:Discharge*/
  584. uint8_t EVChargeProgress; /*0: Stop
  585. 1: Start
  586. 2: Renegotiate
  587. 3: Standby */
  588. uint8_t CpSetPWMDuty; /*unit: 1%
  589. 0: 0%
  590. 5: 5%
  591. 100: 100%*/
  592. uint8_t CpSetStateE; /*0:disable, 1:enable*/
  593. uint8_t CpPresentPWMDuty; /*unit:1%*/
  594. uint8_t CpPresentState; /*1: A (12V, no PWM)
  595. 2: B1 (9V, no PWM)
  596. 3: B2 (9V, with PWM)
  597. 4: C (6V, with PWM)
  598. 5: D (3V, with PWM)
  599. 6: E (0V, no PWM)
  600. 7: F (-12V, no PWM)
  601. 8: G (>12V)
  602. 9: H (<12V)*/
  603. float CpPositiveVoltage; /*uint: 1V*/
  604. float CpNegativeVoltage; /*uint: 1V*/
  605. uint32_t CcsHeartBeat; /*unit: 1*/
  606. float EVSEPresentCurrent[3]; //unit: 1A
  607. float AvailableChargingPower; //1KW
  608. uint8_t EVSENotification; /*0: None
  609. 1: StopCharging
  610. 2: ReNegotiation*/
  611. uint16_t ChargingPermission:1; /*0x00: Not ready yet, stay in idle mode or go into terminating process.
  612. 0x01: start charging process*/
  613. uint16_t ConnectorLockerStatus:1; /*0x00: released
  614. 0x01: locked*/
  615. uint16_t RcdStatus:1; /* 0x00 no error
  616. 0x01 an error */
  617. uint16_t OutputRelayStatus:1; /*0: OFF
  618. 1: ON*/
  619. uint16_t TempFlag4:1;
  620. uint16_t TempFlag5:1;
  621. uint16_t TempFlag6:1;
  622. uint16_t TempFlag7:1;
  623. uint16_t TempFlag8:1;
  624. uint16_t TempFlag9:1;
  625. uint16_t TempFlag10:1;
  626. uint16_t TempFlag11:1;
  627. uint16_t TempFlag12:1;
  628. uint16_t TempFlag13:1;
  629. uint16_t TempFlag14:1;
  630. uint16_t TempFlag15:1;
  631. }Ac_Ccs_Info;
  632. typedef struct GUN_INFO
  633. {
  634. Ver ver;
  635. PresentInputVoltage inputVoltage;
  636. Presentoutputcurrent outputCurrent;
  637. Temperature temperature;
  638. Ble_Config_Data bleConfigData;
  639. Ble_Login_Central_Id bleLoginCentralId;
  640. Rtc rtc;
  641. Ac_Primary_Mcu primaryMcuState;
  642. Ac_Primary_Mcu_Alarm primaryMcuAlarm;
  643. Ac_Primary_Mcu_Led primaryMcuLed;
  644. Mcu_Op_Flag mcuFlag;
  645. Power_Consumption powerConsumptionTotal;
  646. Power_Consumption powerConsumption[3];
  647. Legacy_Request legacyRequest;
  648. System_Alarm_Code systemAlarmCode;
  649. Ac_Primary_Mcu_Cp_Pwm_Duty primaryMcuCp_Pwn_Duty;
  650. Other_Alarm_Code otherAlarmCode;
  651. Pilot_Voltage PilotVoltage;
  652. Gun_Plugin_Times gunPluginTimes;
  653. Mcu_Reset_Request mcuResetRequest;
  654. Set_Breathe_Led_Timing setBreatheLedTiming;
  655. Set_Led_Brightness setLedBrightness;
  656. Set_Aux_Power_Switch setAuxPowerSwitch;
  657. Gpio_in GPIO_Input;
  658. Ac_Ccs_Info acCcsInfo;
  659. float presentChargedEnergyPeriod[24]; // Session present charged energy at each period, resolution: 0.01 KWH
  660. uint8_t ccsHandshakeState;
  661. uint8_t PreviousEVChargeProgress;
  662. uint8_t chargingMode;
  663. uint16_t targetCurrent;
  664. uint8_t evReadyState;
  665. uint8_t resultAuthorization;
  666. MeterIcCorrection meterIcCorrectionStatus;
  667. uint16_t isAuthPassEnd:1;
  668. uint16_t rfidReq:1;
  669. uint16_t isGunPlugged:1;
  670. uint16_t isSetBreatheLedTiming:1;
  671. uint16_t isSetLedBrightness:1;
  672. uint16_t isUnlockerConnetor:1;
  673. uint16_t isOperactive:1;
  674. uint16_t isCCSWaitChangeDuty:1;
  675. uint16_t isCCSStartTransation:1;
  676. uint16_t isEvReady2StateE:1;
  677. uint16_t isDoEvReadyOnce:1;
  678. uint16_t isChargerStopByCondition:1;
  679. uint16_t isMeterOn:1;
  680. uint16_t :3;
  681. }Gun_Info;
  682. struct Charger
  683. {
  684. Ver ver;
  685. Evse_Id evseId;
  686. Gun_Info gun_info[2];
  687. Fw_Upgrade_Info fwUpgradeInfo;
  688. Timeout_Spec timeoutSpec;
  689. uint8_t gun_selectd;
  690. uint8_t speaker_type;
  691. uint8_t isSpeakerOn:1;
  692. uint8_t isUpdateSuccess:1;
  693. uint8_t isCcsEnable:1;
  694. uint8_t isLcdOn:1;
  695. uint8_t isAuthrizing:1;
  696. uint8_t isGetAuthResult:1;
  697. };
  698. #endif /* CONFIG_MAIN_H_ */