|
@@ -38,6 +38,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
#if 0
|
|
#if 0
|
|
#define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
|
|
#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)
|
|
#define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
|
|
@@ -68,6 +69,9 @@ extern int TransactionMessageAttemptsGet(void);
|
|
extern int TransactionMessageRetryIntervalGet(void);
|
|
extern int TransactionMessageRetryIntervalGet(void);
|
|
extern int GetOcppConnStatus(void);
|
|
extern int GetOcppConnStatus(void);
|
|
extern void SetOcppConnStatus(uint8_t status);
|
|
extern void SetOcppConnStatus(uint8_t status);
|
|
|
|
+extern int GetHeartBeatWithNOResponse(void);
|
|
|
|
+extern void SetHeartBeatWithNOResponse(void);
|
|
|
|
+extern int InternetDisconnect(void);
|
|
|
|
|
|
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
|
|
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
|
|
pthread_mutex_t lock_sentData = PTHREAD_MUTEX_INITIALIZER;
|
|
pthread_mutex_t lock_sentData = PTHREAD_MUTEX_INITIALIZER;
|
|
@@ -354,7 +358,7 @@ int SendData(struct lws *wsi)
|
|
|
|
|
|
memcpy (out + LWS_SEND_BUFFER_PRE_PADDING, SendBuffer, len );
|
|
memcpy (out + LWS_SEND_BUFFER_PRE_PADDING, SendBuffer, len );
|
|
|
|
|
|
- DEBUG_OCPPMESSAGE_INFO("out + LWS_SEND_BUFFER_PRE_PADDING = %s\n", out + LWS_SEND_BUFFER_PRE_PADDING);
|
|
|
|
|
|
+ DEBUG_OCPPMESSAGE_INFO(" SendData= %s\n", out + LWS_SEND_BUFFER_PRE_PADDING);
|
|
n = lws_write(wsi, out + LWS_SEND_BUFFER_PRE_PADDING, len, LWS_WRITE_TEXT);
|
|
n = lws_write(wsi, out + LWS_SEND_BUFFER_PRE_PADDING, len, LWS_WRITE_TEXT);
|
|
|
|
|
|
memset(SendBuffer, 0, len);
|
|
memset(SendBuffer, 0, len);
|
|
@@ -461,7 +465,7 @@ static int OCPP16Callback(struct lws *wsi, enum lws_callback_reasons reason, voi
|
|
break;
|
|
break;
|
|
case LWS_CALLBACK_CLIENT_RECEIVE://8
|
|
case LWS_CALLBACK_CLIENT_RECEIVE://8
|
|
((char *)in)[len] = '\0';
|
|
((char *)in)[len] = '\0';
|
|
- DEBUG_OCPPMESSAGE_INFO("%s\n", (char *)in);
|
|
|
|
|
|
+ DEBUG_OCPPMESSAGE_INFO("Original Receive %s\n", (char *)in);
|
|
char tempin[1024*4]={0};
|
|
char tempin[1024*4]={0};
|
|
int c = 0;
|
|
int c = 0;
|
|
char *loc;
|
|
char *loc;
|
|
@@ -495,22 +499,23 @@ static int OCPP16Callback(struct lws *wsi, enum lws_callback_reasons reason, voi
|
|
|
|
|
|
sstr[c] = '\0';
|
|
sstr[c] = '\0';
|
|
strcpy(tempin, sstr);
|
|
strcpy(tempin, sstr);
|
|
- DEBUG_INFO("tempin: %s\n", tempin);
|
|
|
|
|
|
+ DEBUG_INFO("Final Receive: %s\n", tempin);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
strcpy(tempin,(char *)in);
|
|
strcpy(tempin,(char *)in);
|
|
- DEBUG_INFO("tempin: %s\n", tempin);
|
|
|
|
|
|
+ //DEBUG_INFO("tempin: %s\n", tempin);
|
|
}
|
|
}
|
|
|
|
|
|
- #ifdef SystemLogMessage
|
|
|
|
- DEBUG_INFO("LWS_CALLBACK_CLIENT_RECEIVE, RX length: %d\n", (int)len);
|
|
|
|
- #endif
|
|
|
|
|
|
+ //#ifdef SystemLogMessage
|
|
|
|
+ //DEBUG_INFO("LWS_CALLBACK_CLIENT_RECEIVE, RX length: %d\n", (int)len);
|
|
|
|
+ //#endif
|
|
|
|
|
|
//ReceivedMessage(in, len); --- remove temporally
|
|
//ReceivedMessage(in, len); --- remove temporally
|
|
ReceivedMessage((void *)tempin, len);
|
|
ReceivedMessage((void *)tempin, len);
|
|
|
|
|
|
break;
|
|
break;
|
|
|
|
+
|
|
default:
|
|
default:
|
|
#ifdef Debug
|
|
#ifdef Debug
|
|
DEBUG_INFO("OCPP16Callback:reason=%d\n", reason);
|
|
DEBUG_INFO("OCPP16Callback:reason=%d\n", reason);
|
|
@@ -1502,13 +1507,20 @@ int main(void)
|
|
SetOcppConnStatus(TRUE);
|
|
SetOcppConnStatus(TRUE);
|
|
// Check System Value
|
|
// Check System Value
|
|
CheckSystemValue();
|
|
CheckSystemValue();
|
|
|
|
+ if(GetHeartBeatWithNOResponse() >= 3)
|
|
|
|
+ {
|
|
|
|
+ lws_context_destroy(context);
|
|
|
|
+ ConnectionEstablished=0;
|
|
|
|
+ context = NULL;
|
|
|
|
+ SetHeartBeatWithNOResponse();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
lws_service(context, 100);//timeout_ms
|
|
lws_service(context, 100);//timeout_ms
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- pthread_join(t, NULL); // ���ݤl��������槹��
|
|
|
|
|
|
+ pthread_join(t, NULL); //
|
|
//hashmapForMessageFree();
|
|
//hashmapForMessageFree();
|
|
return FAIL;
|
|
return FAIL;
|
|
}
|
|
}
|