main.h 20 KB

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