|
@@ -15424,9 +15424,9 @@ void *UpdateFirmwareProcess(void *data)
|
|
|
int retriesInt =0, retryIntervalInt=0;
|
|
|
char protocol[10], user[50],password[50],host[50], path[50], ftppath[60],host1[50],path1[20];
|
|
|
int port=0;
|
|
|
- char locationstr[160]={0}, retrieveDatestr[30]={0};
|
|
|
+ char locationstr[512]={0}, retrieveDatestr[36]={0};
|
|
|
int isSuccess = 0;
|
|
|
- char ftpbuf[200];
|
|
|
+ char ftpbuf[512];
|
|
|
char temp[100];
|
|
|
char * pch;
|
|
|
|
|
@@ -15465,8 +15465,6 @@ void *UpdateFirmwareProcess(void *data)
|
|
|
{
|
|
|
sscanf(locationstr,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
|
|
|
|
|
|
- //sscanf(locationstr,"%[^:]:%*2[/]%[^:]:%[^@]@%[^/]%199[^\n]",
|
|
|
- // protocol, user, password, host, path);
|
|
|
sprintf(ftppath,"/%s", path);
|
|
|
DEBUG_INFO("locationstr: %s\n", locationstr);
|
|
|
DEBUG_INFO("protocol: %s\n",protocol);
|
|
@@ -15503,21 +15501,24 @@ void *UpdateFirmwareProcess(void *data)
|
|
|
{
|
|
|
sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
|
|
|
ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
|
|
|
- sleep(retryIntervalInt);
|
|
|
+ if(retriesInt>0)sleep(retryIntervalInt);else sleep(1);
|
|
|
+ sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s",FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle]);
|
|
|
+ ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
|
|
|
ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
|
|
|
}
|
|
|
- }while((isSuccess == 0)&&(retriesInt > 0 && retriesInt --));
|
|
|
+ retriesInt--;
|
|
|
+ }while((isSuccess == 0)&&(retriesInt >= 0));
|
|
|
}
|
|
|
else if(strncmp(locationstr,"ftp", 3) == 0) // ftp
|
|
|
{
|
|
|
memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
|
|
|
memset(temp, 0, ARRAY_SIZE(temp));
|
|
|
- //DEBUG_INFO("locationstr=%s\n",locationstr);
|
|
|
- strcpy(ftpbuf, locationstr/*"ftp://ipc_ui:pht2016@ftp.phihong.com.tw/DC/log/DemoDC1_2018-07-13_185011_PSULog.zip"*/ );
|
|
|
+
|
|
|
+ strcpy(ftpbuf, locationstr);
|
|
|
int ftppathlen=strlen(ftpbuf);
|
|
|
int i=1;
|
|
|
char filenametemp[50];
|
|
@@ -15555,16 +15556,6 @@ void *UpdateFirmwareProcess(void *data)
|
|
|
sscanf(host,"%[^/]%s",host1, path1);
|
|
|
sprintf(ftppath,"%s", path1);
|
|
|
|
|
|
- //DEBUG_INFO("protocol =%s\n",protocol);
|
|
|
- //DEBUG_INFO("user =%s\n",user);
|
|
|
- //DEBUG_INFO("password =%s\n",password);
|
|
|
- //DEBUG_INFO("host1 =%s\n",host1);
|
|
|
- //DEBUG_INFO("port =%d\n",port);
|
|
|
- //DEBUG_INFO("path1 =%s\n",path1);
|
|
|
- //DEBUG_INFO("ftppath=%s\n",ftppath);
|
|
|
-
|
|
|
- //ftpFile(host, user, password, port, ftppath, fname);
|
|
|
- //download firmware pthred
|
|
|
if(port == 0)
|
|
|
{
|
|
|
port = 21;
|
|
@@ -15583,7 +15574,9 @@ void *UpdateFirmwareProcess(void *data)
|
|
|
DEBUG_INFO("Update firmware request and download file fail.\n");
|
|
|
sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
|
|
|
ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
|
|
|
- sleep(retryIntervalInt);
|
|
|
+ if(retriesInt>0)sleep(retryIntervalInt);else sleep(1);
|
|
|
+ sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s",FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle]);
|
|
|
+ ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -15591,15 +15584,19 @@ void *UpdateFirmwareProcess(void *data)
|
|
|
ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
|
|
|
|
|
|
}
|
|
|
- }while((!isSuccess)&&(retriesInt > 0 && retriesInt --));
|
|
|
+ retriesInt--;
|
|
|
+ }while((!isSuccess)&&(retriesInt >= 0));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
|
|
|
ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
|
|
|
+ sleep(1);
|
|
|
+ sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s",FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle]);
|
|
|
+ ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
|
|
|
}
|
|
|
|
|
|
- ShmOCPP20Data->MsMsg.bits.UpdateFirmwareReq = ON;
|
|
|
+ if(strstr((char*)ShmOCPP20Data->FirmwareStatusNotification.status, FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]) != NULL)ShmOCPP20Data->MsMsg.bits.UpdateFirmwareReq = ON;
|
|
|
pthread_exit(NULL);
|
|
|
|
|
|
}
|