Quellcode durchsuchen

2020-03-02 / Kathy Yeh
1. add handshaking raw data: server respoce
2. modify server request optional fields adjustment

Kathy_Yeh vor 5 Jahren
Ursprung
Commit
34c98ef8d8

Datei-Diff unterdrückt, da er zu groß ist
+ 299 - 269
EVSE/Modularization/ocppfiles/MessageHandler.c


+ 48 - 13
EVSE/Modularization/ocppfiles/Module_OcppBackend.c

@@ -37,8 +37,6 @@
 #include	"sqlite3.h"
 
 
-
-
 #if 0
 #define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
 #define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
@@ -386,13 +384,38 @@ static int OCPP16Callback(struct lws *wsi, enum lws_callback_reasons reason, voi
 			#ifdef SystemLogMessage
 			DEBUG_INFO("LWS_CALLBACK_CLIENT_FILTER_PRE_ESTABLISH\n");
 			#endif
-			DEBUG_OCPPMESSAGE_INFO("LWS_CALLBACK_CLIENT_FILTER_PRE_ESTABLISH Receive %s\n", (char *)in);
-			break;
-		case LWS_CALLBACK_CLOSED_CLIENT_HTTP:
-			#ifdef SystemLogMessage
-			DEBUG_INFO("LWS_CALLBACK_CLOSED_CLIENT_HTTP\n");
-			#endif
+			char buf[64];
+
+			DEBUG_OCPPMESSAGE_INFO("------------------Handshake: Server response START----------------\n");
+
+			lws_hdr_copy(wsi, buf, sizeof(buf) - 1, WSI_TOKEN_HTTP);
+			DEBUG_OCPPMESSAGE_INFO("HTTP/1.1 %s\n", buf);
+
+			lws_hdr_copy(wsi, buf, sizeof(buf) - 1, WSI_TOKEN_UPGRADE);
+			DEBUG_OCPPMESSAGE_INFO("Upgrade: %s\n", buf);
+
+
+			lws_hdr_copy(wsi, buf, sizeof(buf) - 1, WSI_TOKEN_CONNECTION);
+			DEBUG_OCPPMESSAGE_INFO("Connection: %s\n", buf);
+
+			lws_hdr_copy(wsi, buf, sizeof(buf) - 1, WSI_TOKEN_ACCEPT);
+			DEBUG_OCPPMESSAGE_INFO("Sec-WebSocket-Accept: %s\n", buf);
+
+			lws_hdr_copy(wsi, buf, sizeof(buf) - 1, WSI_TOKEN_PROTOCOL);
+			DEBUG_OCPPMESSAGE_INFO("Sec-WebSocket-Protocol: %s\n", buf);
+
+			DEBUG_OCPPMESSAGE_INFO("------------------Handshake: Server response END----------------\n");
+
 			break;
+
+		case LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION:
+		#ifdef SystemLogMessage
+		DEBUG_INFO("LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER\n");
+		#endif
+
+
+		break;
+
 		case LWS_CALLBACK_WSI_DESTROY:
 			#ifdef SystemLogMessage
 			DEBUG_INFO("LWS_CALLBACK_WSI_DESTROY\n");
@@ -422,12 +445,25 @@ static int OCPP16Callback(struct lws *wsi, enum lws_callback_reasons reason, voi
 			break;
 		case LWS_CALLBACK_GET_THREAD_ID:
 			break;
+
 		case LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER:
-			#ifdef SystemLogMessage
-			DEBUG_INFO("LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER\n");
-			#endif
+		{
+		#ifdef SystemLogMessage
+		DEBUG_INFO("LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER\n");
+		#endif
+#if 0
+		unsigned char **p, *end;
+		struct lws *parent;
+		char buf[8192];
 
-			DEBUG_OCPPMESSAGE_INFO("LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER Receive %s\n", (char *)in);
+		parent = lws_get_parent(wsi);
+		if (!parent)
+			break;
+
+		p = (unsigned char **)in;
+		end = (*p) + len;
+#endif
+		}
 
 			break;
 		case LWS_CALLBACK_CLIENT_ESTABLISHED://3
@@ -436,7 +472,6 @@ static int OCPP16Callback(struct lws *wsi, enum lws_callback_reasons reason, voi
 			#endif
 			//connected
 			ConnectionEstablished=1;
-			DEBUG_OCPPMESSAGE_INFO("LWS_CALLBACK_CLIENT_ESTABLISHED Receive %s\n", (char *)in);
 			break;
 		case LWS_CALLBACK_CLIENT_CONNECTION_ERROR://1
 			#ifdef Debug

+ 1 - 1
EVSE/Projects/define.h

@@ -294,7 +294,7 @@ struct BillingConfigData
 	unsigned char		isBilling;					//0:not for business	1:for business
 	unsigned char		Currency;					//
 	unsigned short		Fee[24];					//fee for 24 hours
-}
+};
 
 struct SysConfigData
 {

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.