/* * Sample_OCPP_Task.h * * Created on: 2020 * Author: foluswen */ #ifndef HEADER_MODULE_OCPPBACKEND20_H_ #define HEADER_MODULE_OCPPBACKEND20_H_ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "hashmap.h" #include "SystemLogMessage.h" #include "MessageHandler.h" #define ROOTCA_CS "/Storage/OCPP/rootCaCs.pem" // for verify connect wss #define ROOTCA_MF "/Storage/OCPP/rootCaMf.pem" // for verify signedUpdateFirmware #define ROOTCA_V2G "/Storage/rootCaV2g.pem" // for 15118 #define ROOTCA_MO "/Storage/rootCaMo.pem" // for 15118 #define CERTIFICATE_CP "/Storage/OCPP/certCP.pem" // for security profile 3 #define CERTIFICATE_V2G "/Storage/certV2G.pem" // for 15118 #define CERTIFICATE_PnCAuth "/Storage/certPnCAuth.pem" // for PnC authorization #define PRIVATE_KEY_CP "/Storage/OCPP/certCP.key" // for security profile 3 #define PRIVATE_KEY_V2G "/Storage/certV2G.key" // for 15118 #define CSR_CP "/Storage/OCPP/certCP.csr" // for get CERTIFICATE_CP #define CSR_V2G "/Storage/certV2G.csr" // for get CERTIFICATE_V2G #define is_error(ptr) ((unsigned long)ptr > (unsigned long)-4000L) #define PASS 1 #define FAIL -1 typedef enum { NO=0, YES }Logic_Value; typedef enum { OFF=0, ON }Switch_Value; enum GUN_TYPE { GUN_TYPE_UNKNOWN=0, GUN_TYPE_CHAdeMO, GUN_TYPE_CCS, GUN_TYPE_GBT, GUN_TYPE_DO, GUN_TYPE_AC }; #ifndef SPEC_LATEST_SUPPORTED #define SPEC_LATEST_SUPPORTED 13 #endif // Hash map operation constant #define HASH_OP_ADD 0 #define HASH_OP_GET 1 #define HASH_OP_REMOVE 2 // OCPP Message type constant #define MESSAGE_TYPE_CALL 2 #define MESSAGE_TYPE_CALLRESULT 3 #define MESSAGE_TYPE_CALLERROR 4 // Queue operation constant #define QUEUE_OPERATION_SHOWQUEUE 0 #define QUEUE_OPERATION_SHOWFRONT 1 #define QUEUE_OPERATION_DEL 2 #define QUEUE_OPERATION_SENT 3 #define QUEUE_OPERATION_ADD 4 #define QUEUE_OPERATION_STORE 5 #define QUEUE_MESSAGE_LENGTH 1024*495 // Websocket TX/RX buffer size #define WEBSOCKET_BUFFER_SIZE (1024*500) struct QueueOpInfo { int TransactionMessageResend; // the number of retry to submit a transaction-related message when the Central System fails to process it. int PreTransactionMessageResend; int TransactionQueueNum; int IsUsing; int stopTransactionId; }; struct yuarel { char *scheme; /* scheme, without ":" and "//" */ char *username; /* username, default: NULL */ char *password; /* password, default: NULL */ char *host; /* hostname or IP address */ int port; /* port, default: 0 */ char *path; /* path, without leading "/", default: NULL */ char *query; /* query, default: NULL */ char *fragment; /* fragment, default: NULL */ }; /* A struct to hold the query string parameter values. */ struct yuarel_param { char *key; char *val; }; extern int yuarel_parse(struct yuarel *url, char *url_str); extern int yuarel_split_path(char *path, char **parts, int max_parts); extern int yuarel_parse_query(char *query, char delimiter, struct yuarel_param *params, int max_params); extern void CheckSystemValue(void); extern void checkNetworkProfile(void); extern int FirstHeartBeatResponse(void); extern void OCPP_get_TableAuthlocalAllData(void); extern int TransactionMessageAttemptsGet(void); extern int TransactionMessageRetryIntervalGet(void); extern int GetOcppConnStatus(void); extern void SetOcppConnStatus(uint8_t status); extern int GetHeartBeatWithNOResponse(void); extern void SetHeartBeatWithNOResponse(void); extern int DB_Initial(); extern uint8_t GetOcppSecurityProfile(); void MergeCertificates(); extern void GetOcppChargerBoxId(uint8_t *data); extern void GetOcppSecurityPassword(uint8_t *data); extern int InitShareMemory(); extern int ProcessShareMemory(); extern void CheckSystemValue(void); extern int isQueueOverSize(); extern int showfront(char *uuid, char *data); extern int addq(char *uuid, char *data) ; extern int delq(); extern int sentqueue(); extern void CheckTransactionPacket(char *uuid); extern int queue_operation(int type, char *frontUUID, char *frontData); extern char *random_uuid( char buf[37]); extern void work(char s[]); extern char* strchr(const char *p, int ch); extern void splitstring(char *src, const char *separator, char **dest,int *num); extern char* stringtrim( char * s ); extern char* stringtrimspace( char * s ); extern char * strtrim( char * s ); extern void refreshStartTimer(struct timespec *timer); extern int getDiffSecNow(struct timespec timer); extern int getDiffSecBetween(struct timespec start, struct timespec end); extern struct lws *wsi_client; extern struct lws_context *context; extern unsigned char SendBuffer[WEBSOCKET_BUFFER_SIZE]; extern int SendBufLen; extern char OcppPath[384]; extern char OcppProtocol[10]; extern char OcppHost[128]; extern char OcppTempPath[256]; extern int OcppPort; extern unsigned char StartTransactionIdTagTemp[20]; extern pthread_mutex_t lock_send; extern uint8_t isWebsocketSendable; extern uint8_t isQueueSendable; extern uint8_t counterLwsRestart; extern uint8_t counterQueueSent; #endif /* HEADER_MODULE_OCPPBACKEND20_H_ */