|
@@ -10583,95 +10583,34 @@ void *UpdateFirmwareProcess(void *data)
|
|
|
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 fname[50]="00000_2018-09-07 160902_CSULog.zip";
|
|
|
- //char comfirmstr[20];
|
|
|
int isSuccess = 0;
|
|
|
char ftpbuf[200];
|
|
|
char temp[100];
|
|
|
char * pch;
|
|
|
- int retriesISNULL=FALSE;
|
|
|
- int retryInterval=FALSE;
|
|
|
- int c = 0;
|
|
|
- //int i = 0;
|
|
|
- char *loc;
|
|
|
- char sstr[300]={ 0 };
|
|
|
- char str[300]={ 0 };
|
|
|
- //char *str = (char*) data; // ? ?頛詨鞈 ?
|
|
|
+
|
|
|
+
|
|
|
DEBUG_INFO("handleUpdateFirmwareRequest ...\n");
|
|
|
- //DEBUG_INFO("packet=%s\n", (const char*)payloadData);
|
|
|
- strcpy(str,(const char*)UpdateFirmwarepayloadData);
|
|
|
- //***************location **************/
|
|
|
- loc = strstr(str, "location");
|
|
|
- memset(sstr ,0, ARRAY_SIZE(sstr) );
|
|
|
- c = 0;
|
|
|
- while (loc[3+strlen("location")+c] != '\"')
|
|
|
+ json_object *UpdateFirmware;
|
|
|
+ UpdateFirmware = json_tokener_parse(UpdateFirmwarepayloadData);
|
|
|
+ if(!is_error(UpdateFirmware))
|
|
|
{
|
|
|
- sstr[c] = loc[3+strlen("location")+c];
|
|
|
- c++;
|
|
|
- }
|
|
|
- sstr[c] = '\0';
|
|
|
- strcpy(locationstr, sstr);
|
|
|
+ // Required data
|
|
|
+ sprintf((char*)locationstr, "%s", json_object_get_string(json_object_object_get(UpdateFirmware, "location")));
|
|
|
+ sprintf((char*)retrieveDatestr, "%s", json_object_get_string(json_object_object_get(UpdateFirmware, "retrieveDate")));
|
|
|
|
|
|
- //***************retries**************/
|
|
|
- c = 0;
|
|
|
- loc = strstr(str, "retries");
|
|
|
- if(loc == NULL)
|
|
|
- {
|
|
|
- retriesISNULL=TRUE;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- memset(sstr ,0, ARRAY_SIZE(sstr) );
|
|
|
- while (loc[strlen("retries")+2+c] != ',')
|
|
|
+ // Optional data
|
|
|
+ if(json_object_object_get(UpdateFirmware, "retries"))
|
|
|
{
|
|
|
- sstr[c] = loc[strlen("retries")+2+c];
|
|
|
- //printf("i=%d sstr=%c\n",c, sstr[c]);
|
|
|
- c++;
|
|
|
+ retriesInt = json_object_get_int(json_object_object_get(UpdateFirmware, "retries"));
|
|
|
}
|
|
|
- sstr[c] = '\0';
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
- if(retriesISNULL == FALSE)
|
|
|
- {
|
|
|
- retriesInt = atoi(sstr);
|
|
|
- }
|
|
|
-
|
|
|
- //***************retrieveDate **************/
|
|
|
- loc = strstr(str, "retrieveDate");
|
|
|
- memset(sstr ,0, ARRAY_SIZE(sstr) );
|
|
|
- c = 0;
|
|
|
- while (loc[3+strlen("retrieveDate")+c] != '\"')
|
|
|
- {
|
|
|
- sstr[c] = loc[3+strlen("retrieveDate")+c];
|
|
|
- c++;
|
|
|
- }
|
|
|
- sstr[c] = '\0';
|
|
|
- strcpy(retrieveDatestr, sstr);
|
|
|
-
|
|
|
- //***************retryInterval **************/
|
|
|
- c = 0;
|
|
|
- loc = strstr(str, "retryInterval");
|
|
|
- memset(sstr ,0, ARRAY_SIZE(sstr) );
|
|
|
- if(loc == NULL)
|
|
|
- {
|
|
|
- retryInterval=TRUE;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- while ((loc[strlen("retryInterval")+2+c] != ',') && (loc[strlen("retryInterval")+2+c] != '}'))
|
|
|
+ if(json_object_object_get(UpdateFirmware, "retryInterval"))
|
|
|
{
|
|
|
- sstr[c] = loc[strlen("retryInterval")+2+c];
|
|
|
- //DEBUG_INFO("i=%d sstr=%c\n",c, sstr[c]);
|
|
|
- c++;
|
|
|
+ retryIntervalInt = json_object_get_int(json_object_object_get(UpdateFirmware, "retryInterval"));
|
|
|
}
|
|
|
- sstr[c] = '\0';
|
|
|
}
|
|
|
+ json_object_put(UpdateFirmware);
|
|
|
|
|
|
- if(retryInterval==FALSE)
|
|
|
- {
|
|
|
- retryIntervalInt = atoi(sstr);
|
|
|
- }
|
|
|
|
|
|
memset(ftppath, 0, ARRAY_SIZE(ftppath));
|
|
|
memset(path, 0, ARRAY_SIZE(path));
|
|
@@ -10681,19 +10620,17 @@ void *UpdateFirmwareProcess(void *data)
|
|
|
|
|
|
if(strncmp(locationstr,"http", 4) == 0)
|
|
|
{
|
|
|
- sscanf(locationstr,"%[^:]:%*2[/]%[^/]/%199[^\n]",
|
|
|
- protocol, host, path);
|
|
|
+ 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);
|
|
|
+ DEBUG_INFO("host: %s\n",host);
|
|
|
+ DEBUG_INFO("path: %s\n",path);
|
|
|
+ DEBUG_INFO("ftppath: %s\n",ftppath);
|
|
|
|
|
|
- //DEBUG_INFO("protocol =%s\n",protocol);
|
|
|
-
|
|
|
- //DEBUG_INFO("host =%s\n",host);
|
|
|
-
|
|
|
- //DEBUG_INFO("path =%s\n",path);
|
|
|
- //DEBUG_INFO("ftppath=%s\n",ftppath);
|
|
|
int ftppathlen=strlen(ftppath);
|
|
|
int i=1;
|
|
|
char filenametemp[50];
|