MessageHandler.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. #ifndef MessageHandler_H
  2. #define MessageHandler_H
  3. struct StructPeriod
  4. {
  5. int StartPeriod;
  6. float Limit;//0.1;
  7. int NumberPhases;
  8. };
  9. struct StructProfile
  10. {
  11. int Duration;
  12. int TotalPeriod;
  13. struct StructPeriod Period[10];
  14. };
  15. //===============================================
  16. // Common routine
  17. //===============================================
  18. int initialConfigurationTable(void);
  19. void StoreConfigurationTable(void);
  20. void GetStartTransactionIdTag(int gun_index);
  21. //==========================================
  22. // send request routine
  23. //==========================================
  24. int sendAuthorizeRequest(int gun_index);
  25. int sendBootNotificationRequest(void);
  26. int sendDataTransferRequest(int gun_index);
  27. int sendFirmwareVersionByDataTransfer(void);
  28. int sendDiagnosticsStatusNotificationRequest(char *status);
  29. int sendFirmwareStatusNotificationRequest(char *status);
  30. int sendHeartbeatRequest(int gun_index);
  31. int sendStartTransactionRequest(int gun_index);
  32. int sendStatusNotificationRequest(int gun_index);
  33. int sendStopTransactionRequest(int gun_index);
  34. int sendMeterValuesRequest(int gun_index);
  35. //==========================================
  36. // send confirm routine
  37. //==========================================
  38. int sendCancelReservationConfirmation(char *uuid,char *payload);
  39. int sendChangeAvailabilityConfirmation(char *uuid,char *payload);
  40. int sendChangeConfigurationConfirmation(char *uuid,char *payload);
  41. int sendClearCacheConfirmation(char *uuid,char *payload);
  42. int sendClearChargingProfileConfirmation(char *uuid,char *payload);
  43. int sendDataTransferConfirmation(char *uuid,char *payload);
  44. int sendGetCompositeScheduleConfirmation(char *uuid,char *payload, int connectorIdInt,int nPeriod);
  45. int sendGetConfigurationConfirmation(char *uuid);
  46. int sendGetDiagnosticsConfirmation(char *uuid,char *payload);
  47. int sendGetLocalListVersionConfirmation(char *uuid,char *payload);
  48. int sendRemoteStartConfirmation(char *uuid,char *payload);
  49. int sendRemoteStopTransactionConfirmation(char *uuid,char *payload);
  50. int sendReserveNowTransactionConfirmation(char *uuid,char *payload);
  51. int sendResetConfirmation(char *uuid,char *payload);
  52. int sendSendLocalListConfirmation(char *uuid,char *payload);
  53. int sendSetChargingProfileConfirmation(char *uuid,char *payload);
  54. int sendTriggerMessageConfirmation(char *uuid,char *payload);
  55. int sendUnlockConnectorConfirmation(char *uuid,char *payload);
  56. int sendUpdateFirmwareConfirmation(char *uuid);
  57. //==========================================
  58. // send CallError routine
  59. //==========================================
  60. void SendCallError(char *uniqueId, char *action, char *errorCode, char *errorDescription);
  61. //==========================================
  62. // Handle server request routine Start
  63. //==========================================
  64. int handleCancelReservationRequest(char *uuid, char *payload);
  65. int handleChangeAvailabilityRequest(char *uuid, char *payload);
  66. int handleChangeConfigurationRequest(char *uuid, char *payload);
  67. int handleClearCacheRequest(char *uuid, char *payload);
  68. int handleClearChargingProfileRequest(char *uuid, char *payload);
  69. int handleDataTransferRequest(char *uuid, char *payload);
  70. int handleGetCompositeScheduleRequest(char *uuid, char *payload);
  71. int handleGetConfigurationRequest(char *uuid, char *payload);
  72. int handleGetDiagnosticsRequest(char *uuid, char *payload);
  73. int handleGetLocalListVersionRequest(char *uuid, char *payload);
  74. int handleRemoteStartRequest(char *uuid, char *payload);
  75. int handleRemoteStopTransactionRequest(char *uuid, char *payload);
  76. int handleReserveNowTransactionRequest(char *uuid, char *payload);
  77. int handleResetRequest(char *uuid, char *payload);
  78. int handleSendLocalListRequest(char *uuid, char *payload);
  79. int handleSetChargingProfileRequest(char *uuid, char *payload);
  80. int handleTriggerMessageRequest(char *uuid, char *payload);
  81. int handleUnlockConnectorRequest(char *uuid, char *payload);
  82. int handleUpdateFirmwareRequest(char *uuid, char *payload);
  83. void handleAuthorizeResponse(char *payload, int gun_index);
  84. void handleBootNotificationResponse(char *payload, int gun_index);
  85. void handleDataTransferResponse(char *payload, int gun_index);
  86. void handleDiagnosticsStatusNotificationResponse(char *payload, int gun_index);
  87. void handleFirmwareStatusNotificationResponse(char *payload, int gun_index);
  88. void handleHeartbeatResponse(char *payload, int gun_index);
  89. void handleMeterValuesResponse(char *payload, int gun_index);
  90. void handleStartTransactionResponse(char *payload, int gun_index);
  91. void handleStatusNotificationResponse(char *payload, int gun_index);
  92. void handleStopTransactionnResponse(char *payload, int gun_index);
  93. //==========================================
  94. // Handle Error routine
  95. //==========================================
  96. void handleError(char *id, char *errorCode, char *errorDescription,char *payload);
  97. //===============================================
  98. // Common routine
  99. //===============================================
  100. void getKeyValue(char *keyReq);
  101. int setKeyValue(char *key, char *value);
  102. int updateSetting(char *key, char *value);
  103. int httpDownLoadFile(char *location, char *path, char *filename,char *url);
  104. int ftpDownLoadFile(char *location, char *user, char *password, int port, char *path, char *filename,char *url);
  105. void *UpdateFirmwareProcess(void* data);
  106. void* GetDiagnosticsProcess(void* data);
  107. int httpUploadFile(char *location, char *path, char *filename,char *url);
  108. int ftpFile(char *location, char *user, char *password, int port, char *path, char *fnamePlusPath,char *filename);
  109. int get_file_contents(const char* filename, char** outbuffer);
  110. void LWS_Send(char * str);
  111. extern int queue_operation(int type, char *frontUUID, char *frontData);
  112. int GetOcppServerURL();
  113. int GetOcppPath();
  114. int GetOcppPort();
  115. int GetTransactionId(int gunindex, unsigned char idTag[]);
  116. void SetTransactionIdZero(int transactionId);
  117. void GetChargingProfileRequest(int gunindex);
  118. void FillStartTransaction(int ConnectorId, unsigned char IdTag[], int MeterStart,int ReservationId,unsigned char Timestamp[]);
  119. void splitstring(char *src,const char *separator,char **dest,int *num);
  120. int GetWebSocketPingInterval(void);
  121. int GetInternetConn(void);
  122. int GetServerSign(void);
  123. void SetServerSign(int value);
  124. int GetBootNotificationInterval(void);
  125. void InitialSystemValue(void);
  126. void checkTempStopTransaction(int gun_index);
  127. void storeTempStopTransaction(int gun_index);
  128. //===============================================
  129. // sqlite related routine
  130. //===============================================
  131. int SettingChargingRecord(int target, int transactionId);
  132. int addBuff(int gun_idx, int user_id, int cmd_sn);
  133. void OCPP_getListVerion();
  134. int OCPP_cleanLocalList();
  135. int OCPP_addLocalList(int version, char *idTag, char *parentTage, char *expiryDate, char *status);
  136. int OCPP_addLocalList_1(int version, char *idTag, char *parentTage, char *expiryDate, char *status);
  137. void OCPP_getIdTag(char idTag[]);
  138. void OCPP_deleteIdTag(char idTag[]);
  139. enum FIRMWARE_NOTIFICATION_STATUS
  140. {
  141. FIRMWARE_STATUS_DOWNLOADED = 0,
  142. FIRMWARE_STATUS_DOWNLOAD_DAILED = 1,
  143. FIRMWARE_STATUS_DOWNLOADING = 2,
  144. FIRMWARE_STATUS_IDLE = 3,
  145. FIRMWARE_STATUS_INSTALLATION_FAILED =4,
  146. FIRMWARE_STATUS_INSTALLING = 5,
  147. FIRMWARE_STATUS_INSTALLED = 6
  148. };
  149. enum DIAGNOSTIC_NOTIFICATION_STATUS
  150. {
  151. DIAGNOSTIC_STATUS_IDLE = 0,
  152. DIAGNOSTIC_STATUS_UPLOADED = 1,
  153. DIAGNOSTIC_STATUS_UPLOAD_FAIL = 2,
  154. DIAGNOSTIC_STATUS_UPLOADING =3
  155. };
  156. #endif