/******************************************************************************
Online C Compiler.
Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <stdio.h>
#include <signal.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <pthread.h>
#include <time.h>
#include <math.h>
#define MAX_BUFFER_SIZE 2048
#define CLOUD_HOST "https://w...content-available-to-author-only...s.net/AVPHofa"
#define CLOUD_BLOG "https://w...content-available-to-author-only...s.net/whetroncontainer01/"
#define CLOUD_BLOG_HEADER "-H 'content-type: application/json' -H 'x-ms-blob-type: BlockBlob'"
#define CLOUD_SIGN_START "2024-01-10T07:12:41Z"
#define CLOUD_SIGN_END "2026-02-01T15:12:41Z"
#define CLOUD_SIGN_SV "2022-11-02"
#define CLOUD_SIGN_KEY "eUnkaH%2FlOFMEt90utNrxH7tjEf0CuduheZGHi%2FRnWcY%3D"
volatile int isLoop = 0;
int isCurlCmdBusy = 0;
char msg[100] = "getSwInfo";
int timeInitial = 0;
int getConnectionResult(char *sendbuffer)
{
int i, j;
char respBuffer[5];
int result = 0;
for (i = 0; i < MAX_BUFFER_SIZE - 5; i++)
{
if (strncmp(sendbuffer
+ i
, "HTTP/1.1", 8) == 0) {
if (sendbuffer[i + 9] == '2' || sendbuffer[i + 9] == '3' || sendbuffer[i + 9] == '4')
{
for (j = i + 9; j < i + 12; j++)
{
respBuffer[0] = sendbuffer[j];
respBuffer[1] = sendbuffer[i + 1];
respBuffer[2] = sendbuffer[j + 2];
respBuffer[3] = '\0';
}
break;
}
}
}
sscanf(respBuffer
, "%d", &result
); return result;
}
int split(char *sendbuffer)
{
int i, j;
char respBuffer[MAX_BUFFER_SIZE] = "";
char param[20][50];
char title[20][50];
int dataLen = 0;
int dataInd = 0;
int paramLen = 0;
int titleLen = 0;
int typeLen = 0;
int isTitle = 0;
int isType = 0;
int isFound = 0;
for (i = 0; i < MAX_BUFFER_SIZE - 5; i++)
{
if (strncmp(sendbuffer
+ i
, "<m:pr", 5) == 0) {
for (j = i; j < MAX_BUFFER_SIZE - 5; j++)
{
if (strncmp(sendbuffer
+ j
, "</m:pr", 6) == 0) {
respBuffer[dataLen] = '\0';
break;
}
else
{
respBuffer[dataLen] = sendbuffer[j];
dataLen++;
}
}
break;
}
}
return dataLen;
}
void *connectToCloud(void *arg)
{
FILE *fp;
char *sendbuffer = (char *)arg;
char respBuffer[MAX_BUFFER_SIZE] = "";
int i;
int isConnected = 0;
while (isConnected == 0)
{
if (isCurlCmdBusy == 0)
{
isCurlCmdBusy = 1;
fp = popen(sendbuffer, "r");
if (fp
== NULL
) printf("Failed to run command\n"); else
{
/* Read the output a line at a time - output it. */
if (fgets(respBuffer
, sizeof(respBuffer
), fp
) != NULL
) {
printf("respBuffer : %s, connection result : %d\n", respBuffer
, getConnectionResult
(&respBuffer
[0])); split(&respBuffer[0]);
}
}
pclose(fp);
isCurlCmdBusy = 0;
isConnected = 1;
}
else usleep(100);
}
// if (isDebug == 2)
// {
// for (i = 0; i < strlen(sendbuffer); i++) printf("sendbuffer[%d] : %c\n", i, sendbuffer[i]);
// }
// if (strstr(sendbuffer, "software"))
// {
// sprintf(sendbuffer, "echo svc_touch conn respSwInfo %s %s %s %s %s %s %s > /sys/module/rpmsg_echo/parameters/example_printk\n", infoParamTableSet1[1], infoParamTableSet1[2], infoParamTableSet1[4], infoParamTableSet1[5], infoParamTableSet1[0], infoParamTableSet1[7], infoParamTableSet1[6]);
// if (isDebug >= 1) printf("sendbuffer : %s\n", sendbuffer);
// }
// else if (strstr(sendbuffer, "status01"))
// {
// sprintf(sendbuffer, "echo svc_touch conn respCarStatus01 %s %s %s %s > /sys/module/rpmsg_echo/parameters/example_printk\n", infoParamTableSet2[0], infoParamTableSet2[3], infoParamTableSet2[2], infoParamTableSet2[4]);
// if (isDebug >= 1) printf("sendbuffer : %s\n", sendbuffer);
// }
// else if (strstr(sendbuffer, "status02"))
// {
// if (isInitialed == 0)
// {
// isInitialed = 1;
// strcpy(infoParamTableSet3[0], "0");
// strcpy(infoParamTableSet3[4], "0.0");
// strcpy(infoParamTableSet3[5], "0");
// strcpy(infoParamTableSet3[6], "0");
// strcpy(infoParamTableSet3[10], "0");
// genUpdateCarStatusCommand(2);
// }
// sprintf(sendbuffer, "echo svc_touch conn respCarStatus02 %s %s %s %s > /sys/module/rpmsg_echo/parameters/example_printk\n", infoParamTableSet3[2], infoParamTableSet3[1], infoParamTableSet3[3], infoParamTableSet3[5]);
// if (isDebug >= 1) printf("sendbuffer : %s\n", sendbuffer);
// }
// else if (strstr(sendbuffer, "status03"))
// {
// sprintf(sendbuffer, "echo svc_touch conn respCarStatus03 > /sys/module/rpmsg_echo/parameters/example_printk\n");
// if (isDebug >= 1) printf("sendbuffer : %s\n", sendbuffer);
// }
// else if (strstr(sendbuffer, "status04"))
// {
// sprintf(sendbuffer, "echo svc_touch conn respCarStatus04 > /sys/module/rpmsg_echo/parameters/example_printk\n");
// if (isDebug >= 1) printf("sendbuffer : %s\n", sendbuffer);
// strcpy(lastSetRemoteChgeIdx, infoParamTableSet5[5]);
// strcpy(lastTargetViewIdx, infoParamTableSet5[6]);
// }
// system(sendbuffer);
printf("connectToCloud EXIT!\n"); pthread_exit(NULL);
}
// void *getMsgFromCloudLoop(void *arg)
// {
// FILE *fp;
// char *sendbuffer = (char *)arg;
// char systembuffer[MAX_BUFFER_SIZE] = "";
// char respBuffer[MAX_BUFFER_SIZE] = "";
// int i = 0;
// char *cmdString[5] = {"curl -X PUT", "%28PartitionKey=%27", "%27,RowKey=%27", "%27%29"};
// int typeCommand = 0;
// char dataParking[3][5];
// int isConnected = 0;
// char lastRemoteCommand[6];
// int lastRemoteCommandDate = 0;
// int lastRemoteCommandTime = 0;
// int currRemoteCommandDate = 0;
// int currRemoteCommandTime = 0;
// struct tm *currTime = {0};
// time_t t;
// int currSyncDate = 0;
// int currSyncTime = 0;
// int needUpdate = 0;
// struct timeval now;
// printf("getMsgFromCloudLoop isLoop[%d]\n", isLoop);
// while (isLoop == 1)
// {
// if (strncmp(infoParamTableSet2[3], "-1", strlen(infoParamTableSet2[3])) != 0)
// {
// sprintf(sendbuffer, "curl -k -v --connect-timeout 10 --max-time 2.0 \'%s%s%s%sstatus04%s?sv=%s&ss=bfqt&srt=sco&sp=rwdlacupiytfx&se=%s&st=%s&spr=https,http&sig=%s\'", CLOUD_HOST, cmdString[1], carKey, cmdString[2], cmdString[3], CLOUD_SIGN_SV, CLOUD_SIGN_END, CLOUD_SIGN_START, CLOUD_SIGN_KEY);
// if (isDebug >= 1) printf("connectToCloudLoop sendbuffer : [%s]\n", sendbuffer);
// needUpdate = 0;
// isConnected = 0;
// i = 0;
// while (isConnected == 0)
// {
// if (isCurlCmdBusy == 0)
// {
// isCurlCmdBusy = 1;
// fp = popen(sendbuffer, "r");
// if (fp == NULL) printf("Failed to run command\n");
// else
// {
// /* Read the output a line at a time - output it. */
// if (fgets(respBuffer, sizeof(respBuffer), fp) != NULL)
// {
// if (isDebug >= 1) printf("respBuffer : %s\n", respBuffer);
// i = split(&respBuffer[0]);
// if (isLoop == 0) break;
// }
// }
// /* close */
// pclose(fp);
// isCurlCmdBusy = 0;
// isConnected = 1;
// }
// else usleep(200);
// }
// if (i == 0)
// {
// if (disconnectCount < 30)
// {
// disconnectCount++;
// usleep(1000);
// }
// else
// {
// disconnectCount = 0;
// sprintf(sendbuffer, "ifconfig usb0 down\n");
// if (isDebug >= 1) printf("ifconfig usb0 down\n");
// system(sendbuffer);
// usleep(1000);
// sprintf(sendbuffer, "ifconfig usb0 up\n");
// if (isDebug >= 1) printf("ifconfig usb0 up\n");
// system(sendbuffer);
// usleep(1000);
// sprintf(sendbuffer, "/usr/local/share/script/wifi_start.sh\n");
// system(sendbuffer);
// }
// continue;
// }
// else disconnectCount = 0;
// lastRemoteCommand[0] = infoParamTableSet5[8][2];
// lastRemoteCommand[1] = infoParamTableSet5[8][3];
// lastRemoteCommand[2] = infoParamTableSet5[8][5];
// lastRemoteCommand[3] = infoParamTableSet5[8][6];
// lastRemoteCommand[4] = infoParamTableSet5[8][8];
// lastRemoteCommand[5] = infoParamTableSet5[8][9];
// currRemoteCommandDate = atoi(lastRemoteCommand);
// lastRemoteCommand[0] = infoParamTableSet5[8][11];
// lastRemoteCommand[1] = infoParamTableSet5[8][12];
// lastRemoteCommand[2] = infoParamTableSet5[8][14];
// lastRemoteCommand[3] = infoParamTableSet5[8][15];
// lastRemoteCommand[4] = infoParamTableSet5[8][17];
// lastRemoteCommand[5] = infoParamTableSet5[8][18];
// currRemoteCommandTime = atoi(lastRemoteCommand) + 80000; // GMT+8
// if (currRemoteCommandTime >= 240000)
// {
// int date = currRemoteCommandDate % 10000;
// int day = currRemoteCommandDate % 100;
// currRemoteCommandTime -= 240000;
// if (date == 131 || date == 228 || date == 331 || date == 430 || date == 531 || date == 630 ||
// date == 731 || date == 831 || date == 930 || date == 1031 || date == 1130)
// currRemoteCommandDate = currRemoteCommandDate + 100 - day + 1;
// else if (date == 1231) currRemoteCommandDate = currRemoteCommandDate + 10000 - date + 101;
// else currRemoteCommandDate++;
// }
// t = time(NULL);
// currTime = localtime(&t);
// currSyncDate = currTime->tm_year % 100 * 10000 + (currTime->tm_mon + 1) * 100 + currTime->tm_mday;
// currSyncTime = currTime->tm_hour * 10000 + currTime->tm_min * 100 + currTime->tm_sec;
// if (isDebug >= 1) printf("currSyncDate[%d], currSyncTime[%d]\n", currSyncDate, currSyncTime);
// // remote command changed
// if (lastRemoteCommandDate == 0 || lastRemoteCommandDate < currRemoteCommandDate ||
// (lastRemoteCommandDate == currRemoteCommandDate && lastRemoteCommandTime < currRemoteCommandTime))
// {
// // remote command is later than cv22 touch command within 5 sec
// if (currSyncDate == currRemoteCommandDate && currSyncTime - currRemoteCommandTime < 20) needUpdate = 1;
// }
// if (isDebug >= 1) printf("needUpdate[%d], lastRemoteCommandDate[%d], currRemoteCommandDate[%d]\n", needUpdate, lastRemoteCommandDate, currRemoteCommandDate);
// if (isDebug >= 1) printf("lastRemoteCommandTime[%d], currRemoteCommandTime[%d]\n", lastRemoteCommandTime, currRemoteCommandTime);
// lastRemoteCommandDate = currRemoteCommandDate;
// lastRemoteCommandTime = currRemoteCommandTime;
// gettimeofday(&now, NULL);
// lastGetCommandTime = (double)now.tv_sec;
// if (needUpdate == 1)
// {
// for (i = 0; i < NUM_INFO_SET5; i++)
// {
// switch (i)
// {
// case 0:
// if (infoParamTableSet5[i][0] == '1')
// // if (!strncmp(infoParamTableSet5[i], "1", sizeof(infoParamTableSet5[i])))
// {
// if (isDebug >= 1) printf("[cCtrlReq] User request command : startParking [%s]\n", infoParamTableSet5[i]);
// if (infoParamTableSet3[0][0] != '4') typeCommand = CMD_START_AUTOPARK;
// }
// else if (infoParamTableSet5[i][0] == '2')
// {
// if (isDebug >= 1) printf("[cCtrlReq] User request command : startPicking [%s]\n", infoParamTableSet5[i]);
// if (infoParamTableSet3[0][0] != '5') typeCommand = CMD_START_AUTOPICK;
// }
// else if (infoParamTableSet5[i][0] == '3')
// {
// if (isDebug >= 1) printf("[cCtrlReq] User request command : stopParking [%s]\n", infoParamTableSet5[i]);
// if (infoParamTableSet3[0][0] == '4') typeCommand = CMD_STOP_AUTOPARK;
// }
// else if (infoParamTableSet5[i][0] == '4')
// {
// if (isDebug >= 1) printf("[cCtrlReq] User request command : stopPicking [%s]\n", infoParamTableSet5[i]);
// if (infoParamTableSet3[0][0] == '5') typeCommand = CMD_STOP_AUTOPICK;
// }
// else if (infoParamTableSet5[i][0] == '5')
// {
// if (isDebug >= 1) printf("[cCtrlReq] User request command : resetAutoParam [%s]\n", infoParamTableSet5[i]);
// typeCommand = CMD_RESET_AUTOPARAM;
// }
// break;
// case 1:
// if (strncmp(infoParamTableSet5[i], infoParamTableSet4[3], sizeof(infoParamTableSet5[i])) != 0 &&
// atoi(infoParamTableSet5[i]) > atoi(infoParamTableSet4[3]))
// {
// if (strncmp(infoParamTableSet4[3], vCapImageIdx, sizeof(infoParamTableSet4[3])) != 0)
// {
// if (isDebug >= 1) printf("[vCapReq] User request command : %s\n", infoParamTableSet5[i]);
// if (vCapCmd == 0)
// {
// vCapCmd = 1; // received capture request
// strcpy(vCapImageIdx, infoParamTableSet5[i]);
// }
// else printf("Previous capture is still processing!! \n");
// }
// }
// break;
// case 2:
// if (strncmp(infoParamTableSet5[i], "-1", sizeof(infoParamTableSet5[i])) != 0)
// {
// if (isDebug >= 1) printf("[tMapNo] User request command : %s\n", infoParamTableSet5[i]);
// strcpy(dataParking[0], infoParamTableSet5[i]);
// strcpy(infoParamTableSet5[i], "-1");
// }
// break;
// case 3:
// if (strncmp(infoParamTableSet5[i], "-1", sizeof(infoParamTableSet5[i])) != 0)
// {
// if (isDebug >= 1) printf("[tInitNo] User request command : %s\n", infoParamTableSet5[i]);
// strcpy(dataParking[1], infoParamTableSet5[i]);
// strcpy(infoParamTableSet5[i], "-1");
// }
// break;
// case 4:
// if (strncmp(infoParamTableSet5[i], "-1", sizeof(infoParamTableSet5[i])) != 0)
// {
// if (isDebug >= 1) printf("[tLotNo] User request command : %s\n", infoParamTableSet5[i]);
// strcpy(dataParking[2], infoParamTableSet5[i]);
// strcpy(infoParamTableSet5[i], "-1");
// }
// break;
// case 5:
// if (strncmp(infoParamTableSet5[i], infoParamTableSet3[5], sizeof(infoParamTableSet5[i])) != 0)
// {
// if (infoParamTableSet3[5][0] != '0' && infoParamTableSet3[6][0] != '0')
// {
// // Settints changed becasue CV22 is reset, skip it.
// }
// else if (strncmp(infoParamTableSet5[i], lastSetRemoteChgeIdx, sizeof(infoParamTableSet5[i])) != 0)
// {
// // Settints changed by remote device, CV22 not sync yet, sync it.
// if (isDebug >= 1) printf("[setChge] User request command : Settings changed by remote device [%s]\n", infoParamTableSet5[i]);
// typeCommand = CMD_REMOTE_CHANGE_SETTING;
// strcpy(infoParamTableSet3[5], infoParamTableSet5[i]);
// strcpy(lastSetRemoteChgeIdx, infoParamTableSet5[i]);
// }
// else
// {
// // Settints changed by CV22, remote devices not sync yet, skip it.
// }
// }
// else if (strncmp(infoParamTableSet5[i], lastSetRemoteChgeIdx, sizeof(infoParamTableSet5[i])) != 0)
// {
// // Settints changed by CV22, remote devices has synced, sync the index.
// strcpy(lastSetRemoteChgeIdx, infoParamTableSet5[i]);
// }
// break;
// case 6:
// if (strncmp(infoParamTableSet5[i], infoParamTableSet3[6], sizeof(infoParamTableSet5[i])) != 0)
// {
// if (strncmp(infoParamTableSet5[i], lastTargetViewIdx, sizeof(infoParamTableSet5[i])) != 0)
// {
// if (isDebug >= 1) printf("[tView] User request command : View changed by remote device [%s]\n", infoParamTableSet5[i]);
// typeCommand = CMD_REMOTE_CHANGE_VIEW;
// strcpy(infoParamTableSet3[6], infoParamTableSet5[i]);
// strcpy(lastTargetViewIdx, infoParamTableSet5[i]);
// }
// }
// break;
// default:
// break;
// }
// }
// }
// if (typeCommand == CMD_START_AUTOPARK)
// {
// if (strlen(dataParking[0]) > 0 && strlen(dataParking[1]) > 0 && strlen(dataParking[2]) > 0)
// {
// printf("ask car start parking!! \n");
// sprintf(systembuffer, "echo svc_touch conn startParking %s %s %s > /sys/module/rpmsg_echo/parameters/example_printk\n", dataParking[0], dataParking[1], dataParking[2]);
// system(systembuffer);
// memset(dataParking, 0, sizeof(dataParking));
// strcpy(infoParamTableSet3[0], "1");
// }
// }
// else if (typeCommand == CMD_START_AUTOPICK)
// {
// printf("ask car start picking!! \n");
// sprintf(systembuffer, "echo svc_touch conn startPicking %s %s %s > /sys/module/rpmsg_echo/parameters/example_printk\n", dataParking[0], dataParking[1], dataParking[2]);
// system(systembuffer);
// strcpy(infoParamTableSet3[0], "3");
// }
// else if (typeCommand == CMD_STOP_AUTOPARK)
// {
// if (infoParamTableSet3[0][0] == '1' || infoParamTableSet3[0][0] == '2')
// {
// printf("ask car stop parking!! \n");
// sprintf(systembuffer, "echo svc_touch conn stopParking %s %s > /sys/module/rpmsg_echo/parameters/example_printk\n", dataParking[0], dataParking[1]);
// system(systembuffer);
// memset(dataParking, 0, sizeof(dataParking));
// strcpy(infoParamTableSet3[0], "0");
// strcpy(infoParamTableSet3[10], "0");
// }
// }
// else if (typeCommand == CMD_STOP_AUTOPICK)
// {
// strcpy(infoParamTableSet3[1], "-1");
// strcpy(infoParamTableSet3[2], "-1");
// if (infoParamTableSet3[0][0] == '3' || infoParamTableSet3[0][0] == '4')
// {
// printf("ask car stop picking!! \n");
// sprintf(systembuffer, "echo svc_touch conn stopPicking > /sys/module/rpmsg_echo/parameters/example_printk\n");
// system(systembuffer);
// strcpy(infoParamTableSet3[0], "0");
// strcpy(infoParamTableSet3[10], "0");
// }
// }
// else if (typeCommand == CMD_RESET_AUTOPARAM)
// {
// strcpy(infoParamTableSet3[0], "0");
// strcpy(infoParamTableSet3[1], "-1");
// strcpy(infoParamTableSet3[2], "-1");
// strcpy(infoParamTableSet3[3], "-1");
// strcpy(infoParamTableSet3[6], "0");
// strcpy(infoParamTableSet3[10], "0");
// if (infoParamTableSet3[0][0] == '1' || infoParamTableSet3[0][0] == '2')
// {
// printf("ask car stop parking!! \n");
// sprintf(systembuffer, "echo svc_touch conn stopParking %s %s > /sys/module/rpmsg_echo/parameters/example_printk\n", dataParking[0], dataParking[1]);
// system(systembuffer);
// memset(dataParking, 0, sizeof(dataParking));
// }
// else if (infoParamTableSet3[0][0] == '3' || infoParamTableSet3[0][0] == '4')
// {
// printf("ask car stop picking!! \n");
// sprintf(systembuffer, "echo svc_touch conn stopPicking > /sys/module/rpmsg_echo/parameters/example_printk\n");
// system(systembuffer);
// }
// strcpy(infoParamTableSet5[0], "0");
// strcpy(infoParamTableSet5[2], "-1");
// strcpy(infoParamTableSet5[3], "-1");
// strcpy(infoParamTableSet5[4], "-1");
// strcpy(infoParamTableSet5[6], "0");
// genUpdateCarStatusCommand(4);
// }
// else if (typeCommand == CMD_REMOTE_CHANGE_SETTING)
// {
// sprintf(respBuffer, "curl -k -v \'%s%s%s%sstatus01%s?sv=%s&ss=bfqt&srt=sco&sp=rwdlacupiytfx&se=%s&st=%s&spr=https,http&sig=%s\'", CLOUD_HOST, cmdString[1], carKey, cmdString[2], cmdString[3], CLOUD_SIGN_SV, CLOUD_SIGN_END, CLOUD_SIGN_START, CLOUD_SIGN_KEY);
// isConnected = 0;
// while (isConnected == 0)
// {
// if (isCurlCmdBusy == 0)
// {
// isCurlCmdBusy = 1;
// fp = popen(respBuffer, "r");
// if (fp == NULL) printf("Failed to run command\n");
// else
// {
// /* Read the output a line at a time - output it. */
// if (fgets(respBuffer, sizeof(respBuffer), fp) != NULL)
// {
// if (isDebug == 1) printf("respBuffer : %s\n", respBuffer);
// i = split(&respBuffer[0]);
// if (isDebug == 1) printf("respBuffer dataLen: %d\n", i);
// }
// }
// /* close */
// pclose(fp);
// isCurlCmdBusy = 0;
// isConnected = 1;
// sprintf(sendbuffer, "echo svc_touch conn respCarStatus01 %s %s %s %s > /sys/module/rpmsg_echo/parameters/example_printk\n", infoParamTableSet2[0], infoParamTableSet2[3], infoParamTableSet2[2], infoParamTableSet2[4]);
// if (isDebug >= 1) printf("sendbuffer : %s\n", sendbuffer);
// }
// else usleep(200);
// }
// }
// else if (typeCommand == CMD_REMOTE_CHANGE_VIEW)
// {
// int value = atoi(infoParamTableSet3[6]);
// printf("ask car change view!! \n");
// if (value == 0) sprintf(systembuffer, "echo svc_button avmMV > /sys/module/rpmsg_echo/parameters/example_printk\n");
// else if (value >= 1 && value <= 4) sprintf(systembuffer, "echo svc_button avmMV%d > /sys/module/rpmsg_echo/parameters/example_printk\n", value - 1);
// else if (value == 10) sprintf(systembuffer, "echo svc_button dvronly > /sys/module/rpmsg_echo/parameters/example_printk\n");
// else if (value >= 11 && value <= 14) sprintf(systembuffer, "echo svc_button mvonly > /sys/module/rpmsg_echo/parameters/example_printk\n");
// else if (value == 20) sprintf(systembuffer, "echo svc_button avm3D > /sys/module/rpmsg_echo/parameters/example_printk\n");
// else if (value >= 21 && value <= 28) sprintf(systembuffer, "echo svc_button avm3D%d > /sys/module/rpmsg_echo/parameters/example_printk\n", value - 21);
// system(systembuffer);
// }
// else if (vCapCmd == 1)
// { // received capture request
// vCapCmd = 2;
// sprintf(systembuffer, "echo svc_touch conn startCapture > /sys/module/rpmsg_echo/parameters/example_printk\n");
// system(systembuffer);
// }
// typeCommand = 0;
// memset(dataParking, 0, sizeof(dataParking));
// memset(respBuffer, 0, sizeof(respBuffer));
// }
// usleep(1000);
// }
// printf("getMsgFromCloudLoop EXIT!\n");
// sprintf(systembuffer, "echo svc_touch conn askConnect > /sys/module/rpmsg_echo/parameters/example_printk\n");
// system(systembuffer);
// pthread_exit(NULL);
// }
int main()
{
char sendbuffer[MAX_BUFFER_SIZE] = "";
char *cmdString[5] = {"curl -k -v --connect-timeout 5 --max-time 5.0 \'",
"%28PartitionKey=%27",
"%27,RowKey=%27",
"%27%29?sv=",
"&ss=bfqt&srt=sco&sp=rwdlacupiytfx"};
pthread_t t;
char respBuffer[5];
FILE *fp;
if (!strcmp(msg
, "getSwInfo")) {
printf("get software information from server\n"); sprintf(sendbuffer
, "%s%s%sgeneral%ssoftware%s%s%s&se=%s&st=%s&spr=https,http&sig=%s\'\n", cmdString
[0], CLOUD_HOST
, cmdString
[1], cmdString
[2], cmdString
[3], CLOUD_SIGN_SV
, cmdString
[4], CLOUD_SIGN_END
, CLOUD_SIGN_START
, CLOUD_SIGN_KEY
); printf("cmd : %s\n", sendbuffer
); fp = popen(sendbuffer, "r");
if (fgets(respBuffer
, sizeof(respBuffer
), fp
) != NULL
) {
// printf("respBuffer : %s, connection result : %d\n", respBuffer, getConnectionResult(&respBuffer[0]));
// split(&respBuffer[0]);
}
// pthread_create(&t, NULL, connectToCloud, (void *)&sendbuffer[0]);
}
// else
// {
// printf("startCarStatus isLoop : [%d]\n", isLoop);
// sprintf(sendbuffer, "%s%s%s%s%sstatus04%s%s%s&se=%s&st=%s&spr=https,http&sig=%s\'\n", cmdString[0], CLOUD_HOST, cmdString[1], carKey, cmdString[2], cmdString[3], CLOUD_SIGN_SV, cmdString[4], CLOUD_SIGN_END, CLOUD_SIGN_START, CLOUD_SIGN_KEY);
// if (isLoop == 0U)
// {
// isLoop = 1U;
// pthread_create(&t_Loop, NULL, getMsgFromCloudLoop, (void *)&sendbuffer[0]);
// pthread_create(&t_Command, NULL, sendMsgToCloudLoop, (void *)&sendbuffer[0]);
// }
// if (isUploadLoop == 0U)
// {
// isUploadLoop = 1U;
// pthread_create(&t_Upload, NULL, uploadFileToCloudLoop, (void *)&sendbuffer[0]);
// }
// }
return 0;
}