|
@@ -8240,7 +8240,7 @@ int handleChangeAvailabilityRequest(char *uuid, char *payload)
|
|
|
{
|
|
|
mtrace();
|
|
|
int result = FAIL;
|
|
|
- int gunIndex = 0;
|
|
|
+ int gunIndex = -1;
|
|
|
char typeStr[16]={0};
|
|
|
char comfirmstr[20];
|
|
|
int specificId = FALSE;
|
|
@@ -8253,7 +8253,7 @@ int handleChangeAvailabilityRequest(char *uuid, char *payload)
|
|
|
if(!is_error(ChangeAvailability))
|
|
|
{
|
|
|
|
|
|
- if(json_object_object_get(ChangeAvailability, "connectorId") != NULL)
|
|
|
+ if((json_object_object_get(ChangeAvailability, "connectorId") != NULL) && (json_object_get_type(json_object_object_get(ChangeAvailability, "connectorId")) == json_type_int))
|
|
|
gunIndex = json_object_get_int(json_object_object_get(ChangeAvailability, "connectorId"));
|
|
|
|
|
|
if(json_object_object_get(ChangeAvailability, "type") != NULL)
|
|
@@ -8262,7 +8262,7 @@ int handleChangeAvailabilityRequest(char *uuid, char *payload)
|
|
|
json_object_put(ChangeAvailability);
|
|
|
|
|
|
|
|
|
- if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
|
|
|
+ if((gunIndex > 0) && (gunIndex <= gunTotalNumber))
|
|
|
{
|
|
|
ShmOCPP16DataPH->ChangeAvailability[gunIndex - 1].ConnectorId= gunIndex;
|
|
|
sprintf((char *)ShmOCPP16DataPH->ChangeAvailability[gunIndex - 1].Type, "%s", typeStr);
|
|
@@ -8279,7 +8279,7 @@ int handleChangeAvailabilityRequest(char *uuid, char *payload)
|
|
|
memset(comfirmstr, 0, ARRAY_SIZE(comfirmstr));
|
|
|
sprintf(comfirmstr, "%s", AvailabilityStatusStr[Rejected] );
|
|
|
|
|
|
- if((gunIndex == 0) || (gunIndex <= gunTotalNumber))
|
|
|
+ if((gunIndex == 0) || ((gunIndex > 0) && (gunIndex <= gunTotalNumber)))
|
|
|
{
|
|
|
specificId = TRUE;
|
|
|
}
|
|
@@ -10470,7 +10470,7 @@ void* GetDiagnosticsProcess(void* data)
|
|
|
ShmOCPP16DataPH->SpMsg.bits.DiagnosticsStatusNotificationReq = 1;
|
|
|
sleep(3);
|
|
|
|
|
|
- isSuccess = ftpFile(host1, user, password, port, ftppath, fnamePlusPath, fnamePWithNoPath);
|
|
|
+ isSuccess = ftpUploadFile(host1, user, password, port, ftppath, fnamePlusPath, fnamePWithNoPath);
|
|
|
if(!isSuccess)
|
|
|
{
|
|
|
DEBUG_INFO("Diagnostics fail.\n");
|
|
@@ -17442,38 +17442,36 @@ int httpUploadFile(char *location, char *path, char *filename,char *url)
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
-int ftpFile(char *location, char *user, char *password, int port, char *path, char *fnamePlusPath,char *filename)
|
|
|
+int ftpUploadFile(char *location, char *user, char *password, int port, char *path, char *fnamePlusPath,char *filename)
|
|
|
{
|
|
|
- struct hostent* server;
|
|
|
- char *IPbuffer;
|
|
|
- char ftpbuf[200];
|
|
|
- int systemresult;
|
|
|
-
|
|
|
-
|
|
|
- server = gethostbyname(location);
|
|
|
-
|
|
|
-
|
|
|
- IPbuffer = inet_ntoa(*((struct in_addr*)
|
|
|
- server->h_addr_list[0]));
|
|
|
+ int result = FALSE;
|
|
|
+ char ftpbuf[200];
|
|
|
+ int systemresult;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ struct hostent* server;
|
|
|
+ char *IPbuffer;
|
|
|
+ server = gethostbyname(location);
|
|
|
+ IPbuffer = inet_ntoa(*((struct in_addr*)server->h_addr_list[0]));*/
|
|
|
|
|
|
memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,port,path,filename,fnamePlusPath);
|
|
|
- DEBUG_INFO("ftpbuf=%s\n",ftpbuf);
|
|
|
-
|
|
|
+ sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s", user, password, location, port, path, filename, fnamePlusPath);
|
|
|
+ DEBUG_INFO("ftp command: %s\n",ftpbuf);
|
|
|
systemresult = system(ftpbuf);
|
|
|
|
|
|
- DEBUG_INFO("systemresult=%d\n",systemresult);
|
|
|
if(systemresult != 0)
|
|
|
{
|
|
|
DEBUG_INFO("ftpput error!\n");
|
|
|
- return FALSE;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ result = TRUE;
|
|
|
+ DEBUG_INFO("ftpput OK!\n");
|
|
|
}
|
|
|
|
|
|
- return TRUE;
|
|
|
-
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
int GetOcppServerURL()
|