|
@@ -29,9 +29,7 @@
|
|
|
#include <ifaddrs.h>
|
|
|
#include "libwebsockets.h"
|
|
|
#include <lws_config.h>
|
|
|
-
|
|
|
#include "hashmap.h"
|
|
|
-
|
|
|
#include "SystemLogMessage.h"
|
|
|
#include "ShareMemory.h"
|
|
|
#include <pthread.h>
|
|
@@ -39,6 +37,7 @@
|
|
|
#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)
|
|
@@ -56,8 +55,8 @@ struct lws *wsi_client;
|
|
|
struct lws_context *context;
|
|
|
static int sendbuffer = 0;
|
|
|
extern int server_sign;
|
|
|
-extern int TransactionMessageAttemptsValue;
|
|
|
-extern int TransactionMessageRetryIntervalValue;
|
|
|
+//extern int TransactionMessageAttemptsValue;
|
|
|
+//extern int TransactionMessageRetryIntervalValue;
|
|
|
//extern int server_pending;
|
|
|
|
|
|
//extern struct OCPP16Data *ShmOCPP16Data;
|
|
@@ -69,6 +68,7 @@ extern int TransactionMessageAttemptsGet(void);
|
|
|
extern int TransactionMessageRetryIntervalGet(void);
|
|
|
extern int GetOcppConnStatus(void);
|
|
|
|
|
|
+
|
|
|
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
|
|
|
pthread_mutex_t lock_sentData = PTHREAD_MUTEX_INITIALIZER;
|
|
|
|
|
@@ -107,7 +107,7 @@ static int ConnectionEstablished=0;
|
|
|
static int TransactionMessageResend = 1;
|
|
|
static int TransactionQueueInterval = 10;//3; // TransactionMessageAttempts
|
|
|
static int TransactionQueueNum = 0;
|
|
|
-static int OfflineTransaction = 0; // 1:offline 0: online
|
|
|
+static int OfflineTransaction = 0;
|
|
|
int defaultWaitingTime = 10; //10 second
|
|
|
|
|
|
extern int BootNotificationInterval;
|
|
@@ -353,7 +353,7 @@ int SendData(struct lws *wsi)
|
|
|
|
|
|
memcpy (out + LWS_SEND_BUFFER_PRE_PADDING, SendBuffer, len );
|
|
|
|
|
|
- DEBUG_INFO("out + LWS_SEND_BUFFER_PRE_PADDING = %s\n", out + LWS_SEND_BUFFER_PRE_PADDING);
|
|
|
+ DEBUG_OCPPMESSAGE_INFO("out + LWS_SEND_BUFFER_PRE_PADDING = %s\n", out + LWS_SEND_BUFFER_PRE_PADDING);
|
|
|
n = lws_write(wsi, out + LWS_SEND_BUFFER_PRE_PADDING, len, LWS_WRITE_TEXT);
|
|
|
|
|
|
memset(SendBuffer, 0, len);
|
|
@@ -462,9 +462,8 @@ static int OCPP16Callback(struct lws *wsi, enum lws_callback_reasons reason, voi
|
|
|
((char *)in)[len] = '\0';
|
|
|
#ifdef SystemLogMessage
|
|
|
DEBUG_INFO("LWS_CALLBACK_CLIENT_RECEIVE, RX length: %d\n", (int)len);
|
|
|
- //DEBUG_INFO("Message: %s\n", (char *)in);
|
|
|
#endif
|
|
|
-
|
|
|
+ DEBUG_OCPPMESSAGE_INFO("%s\n", (char *)in);
|
|
|
ReceivedMessage(in, len);
|
|
|
|
|
|
break;
|
|
@@ -613,7 +612,7 @@ stat("../Storage/OCPP", &stats);
|
|
|
// Check for directory existence
|
|
|
if (S_ISDIR(stats.st_mode) == 1)
|
|
|
{
|
|
|
- DEBUG_INFO("\n OCPP directory exist \n");
|
|
|
+ //DEBUG_INFO("\n OCPP directory exist \n");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -626,7 +625,7 @@ memset(&rmFileCmd, 0, sizeof rmFileCmd);
|
|
|
|
|
|
if((access("../Storage/OCPP/TransactionRelatedQueue",F_OK))!=-1)
|
|
|
{
|
|
|
- DEBUG_INFO("TransactionRelatedQueue exist.\n");
|
|
|
+ //DEBUG_INFO("TransactionRelatedQueue exist.\n");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -651,7 +650,7 @@ if(fp == NULL) {
|
|
|
DEBUG_INFO("Error opening TransactionRelatedQueue file");
|
|
|
return FALSE;
|
|
|
}
|
|
|
-printf("test\n");
|
|
|
+
|
|
|
if( fgets (str, 1200, fp)!=NULL ) {
|
|
|
/* writing content to stdout */
|
|
|
|
|
@@ -691,7 +690,7 @@ if( fgets (str, 1200, fp)!=NULL ) {
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- DEBUG_INFO("queue is null\n");
|
|
|
+ //DEBUG_INFO("queue is null\n");
|
|
|
strcpy(uuid,"");
|
|
|
strcpy(data,"");
|
|
|
result = FALSE;
|
|
@@ -1323,6 +1322,8 @@ return 0;
|
|
|
//================================================
|
|
|
int main(void)
|
|
|
{
|
|
|
+ char rmFileCmd[100]={0};
|
|
|
+ struct stat stats;
|
|
|
pthread_t t;
|
|
|
#ifdef SystemLogMessage
|
|
|
DEBUG_INFO("Initialization...\n");
|
|
@@ -1333,6 +1334,23 @@ int main(void)
|
|
|
return FAIL;
|
|
|
}
|
|
|
|
|
|
+ //Create OCPP dir
|
|
|
+ stat("../Storage/OCPP", &stats);
|
|
|
+
|
|
|
+ // Check for directory existence
|
|
|
+ if (S_ISDIR(stats.st_mode) == 1)
|
|
|
+ {
|
|
|
+ DEBUG_INFO("\n OCPP directory exist \n");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DEBUG_INFO("\n OCPP directory not exist, create dir \n");
|
|
|
+ sprintf(rmFileCmd,"mkdir -p %s","../Storage/OCPP");
|
|
|
+ system(rmFileCmd);
|
|
|
+ }
|
|
|
+
|
|
|
+ memset(&rmFileCmd, 0, sizeof rmFileCmd);
|
|
|
+
|
|
|
//Create Process: Resend Transaction
|
|
|
pthread_create(&t, NULL, processTransactionQueue, NULL); //
|
|
|
|