MessageHandler.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. #ifndef MessageHandler_H
  2. #define MessageHandler_H
  3. #if 0
  4. typedef enum _DiagnosticsStatus
  5. {
  6. Idle,
  7. Uploaded,
  8. UploadFailed,
  9. Uploading
  10. }DiagnosticsStatus;
  11. typedef enum _FirmwareStatus
  12. {
  13. Downloaded,
  14. DownloadFailed,
  15. Downloading,
  16. FirmwareStatusIdle,
  17. InstallationFailed,
  18. Installing,
  19. Installed
  20. }FirmwareStatus;
  21. #endif
  22. //===============================================
  23. // Common routine
  24. //===============================================
  25. int initialConfigurationTable(void);
  26. //==========================================
  27. // send request routine
  28. //==========================================
  29. int sendAuthorizeRequest(int gun_index);
  30. int sendBootNotificationRequest(void);
  31. int sendDataTransferRequest(int gun_index);
  32. int sendDiagnosticsStatusNotificationRequest(char *status);
  33. int sendFirmwareStatusNotificationRequest(char *status);
  34. int sendHeartbeatRequest(int gun_index);
  35. int sendStartTransactionRequest(int gun_index);
  36. int sendStatusNotificationRequest(int gun_index);
  37. int sendStopTransactionRequest(int gun_index);
  38. int sendMeterValuesRequest(int gun_index);
  39. //==========================================
  40. // send confirm routine
  41. //==========================================
  42. int sendCancelReservationConfirmation(char *uuid,char *payload);
  43. int sendChangeAvailabilityConfirmation(char *uuid,char *payload);
  44. int sendChangeConfigurationConfirmation(char *uuid,char *payload);
  45. int sendClearCacheConfirmation(char *uuid,char *payload);
  46. int sendClearChargingProfileConfirmation(char *uuid,char *payload);
  47. int sendDataTransferConfirmation(char *uuid,char *payload);
  48. int sendGetCompositeScheduleConfirmation(char *uuid,char *payload, int connectorIdInt,int nPeriod);
  49. int sendGetConfigurationConfirmation(char *uuid);
  50. int sendGetDiagnosticsConfirmation(char *uuid,char *payload);
  51. int sendGetLocalListVersionConfirmation(char *uuid,char *payload);
  52. int sendRemoteStartConfirmation(char *uuid,char *payload);
  53. int sendRemoteStopTransactionConfirmation(char *uuid,char *payload);
  54. int sendReserveNowTransactionConfirmation(char *uuid,char *payload);
  55. int sendResetConfirmation(char *uuid,char *payload);
  56. int sendSendLocalListConfirmation(char *uuid,char *payload);
  57. int sendSetChargingProfileConfirmation(char *uuid,char *payload);
  58. int sendTriggerMessageConfirmation(char *uuid,char *payload);
  59. int sendUnlockConnectorConfirmation(char *uuid,char *payload);
  60. int sendUpdateFirmwareConfirmation(char *uuid);
  61. //==========================================
  62. // send CallError routine
  63. //==========================================
  64. void SendCallError(char *uniqueId, char *action, char *errorCode, char *errorDescription);
  65. //==========================================
  66. // Handle server request routine Start
  67. //==========================================
  68. int handleCancelReservationRequest(char *uuid, char *payload);
  69. int handleChangeAvailabilityRequest(char *uuid, char *payload);
  70. int handleChangeConfigurationRequest(char *uuid, char *payload);
  71. int handleClearCacheRequest(char *uuid, char *payload);
  72. int handleClearChargingProfileRequest(char *uuid, char *payload);
  73. int handleDataTransferRequest(char *uuid, char *payload);
  74. long long diff_tm(struct tm *a, struct tm *b);
  75. int handleGetCompositeScheduleRequest(char *uuid, char *payload);
  76. int handleGetConfigurationRequest(char *uuid, char *payload);
  77. int handleGetDiagnosticsRequest(char *uuid, char *payload);
  78. int handleGetLocalListVersionRequest(char *uuid, char *payload);
  79. int handleRemoteStartRequest(char *uuid, char *payload);
  80. int handleRemoteStopTransactionRequest(char *uuid, char *payload);
  81. int handleReserveNowTransactionRequest(char *uuid, char *payload);
  82. int handleResetRequest(char *uuid, char *payload);
  83. int handleSendLocalListRequest(char *uuid, char *payload);
  84. int handleSetChargingProfileRequest(char *uuid, char *payload);
  85. int handleTriggerMessageRequest(char *uuid, char *payload);
  86. int handleUnlockConnectorRequest(char *uuid, char *payload);
  87. int handleUpdateFirmwareRequest(char *uuid, char *payload);
  88. void handleAuthorizeResponse(char *payload, int gun_index);
  89. void handleBootNotificationResponse(char *payload, int gun_index);
  90. void handleDataTransferResponse(char *payload, int gun_index);
  91. void handleDiagnosticsStatusNotificationResponse(char *payload, int gun_index);
  92. void handleFirmwareStatusNotificationResponse(char *payload, int gun_index);
  93. void handleHeartbeatResponse(char *payload, int gun_index);
  94. void handleMeterValuesResponse(char *payload, int gun_index);
  95. void handleStartTransactionResponse(char *payload, int gun_index);
  96. void handleStatusNotificationResponse(char *payload, int gun_index);
  97. void handleStopTransactionnResponse(char *payload, int gun_index);
  98. //==========================================
  99. // Handle Error routine
  100. //==========================================
  101. void handleError(char *id, char *errorCode, char *errorDescription,char *payload);
  102. //===============================================
  103. // Common routine
  104. //===============================================
  105. void getKeyValue(char *keyReq);
  106. int setKeyValue(char *key, char *value);
  107. int updateSetting(char *key, char *value);
  108. json_object * getJSONfromFile(char *filename);
  109. int httpDownLoadFile(char *location, char *path, char *filename,char *url);
  110. int ftpDownLoadFile(char *location, char *user, char *password, int port, char *path, char *filename);
  111. void UpdateFirmwareProcess(void* data);
  112. void* GetDiagnosticsProcess(void* data);
  113. int ftpFile(char *location, char *user, char *password, int port, char *path, char *filename);
  114. int get_file_contents(const char* filename, char** outbuffer);
  115. static int ftp_recv_respond(int m_socket_cmd, char *resp, int len);
  116. void Send(struct json_object *message);
  117. void LWS_Send(char * str);
  118. extern int queue_operation(int type, char *frontUUID, char *frontData);
  119. char *GetOcppServerURL();
  120. char *GetOcppPath();
  121. int GetOcppPort();
  122. //===============================================
  123. // sqlite related routine
  124. //===============================================
  125. int SettingChargingRecord(int target, int transactionId);
  126. int addBuff(int gun_idx, int user_id, int cmd_sn);
  127. void OCPP_getListVerion();
  128. int OCPP_cleanLocalList();
  129. int OCPP_addLocalList(int version, char *idTag, char *parentTage, char *expiryDate, char *status);
  130. int OCPP_addLocalList_1(int version, char *idTag, char *parentTage, char *expiryDate, char *status);
  131. void OCPP_getIdTag(char *idTag);
  132. void OCPP_deleteIdTag(char *idTag);
  133. #endif