MessageHandler.h 7.3 KB

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