diff --git a/code/application/source/sf_app/code/include/sf_wifi_svr.h b/code/application/source/sf_app/code/include/sf_wifi_svr.h index 99b91cffd..c61342b64 100755 --- a/code/application/source/sf_app/code/include/sf_wifi_svr.h +++ b/code/application/source/sf_app/code/include/sf_wifi_svr.h @@ -213,6 +213,7 @@ typedef enum WIFI_CONTROL_CAMERA_Debug = 0x3a, //debug模式 WIFI_CONTROL_CAMERA_Network_Scan = 0x3b, //Network scan WIFI_CONTROL_CAMERA_Network_Select = 0x3c,//Network select + WIFI_CONTROL_CAMERA_FormatEmmcCard = 0x3d,//格式化emmc WIFI_CMD_MAX = 0x40, } CAMERA_CFG_CMD; @@ -330,6 +331,7 @@ typedef struct devPara_t typedef struct { UINT8 fileName[32]; /*最后一个文件名取增量,为空取全部*/ + UINT8 diskType; /* 磁盘类型:0:默认,1:eMMC ,2:SD,初次进入预览界面时,如不清楚当前工作磁盘,请发默认类型 */ UINT16 suffix; /* 0xFFEE */ } __attribute__((packed)) MSG_DEV_THUMB_LIST_Get_T; @@ -339,6 +341,7 @@ typedef struct UINT8 cmdRet; /*0 成功,否则返回错误码*/ UINT32 fileNums; /*缩略图文件总数量*/ UINT32 packageSize; /*数据包大小*/ + UINT8 diskType; /* 磁盘类型:0:默认,1:eMMC ,2:SD,初次进入预览界面时,如不清楚当前工作磁盘,请发默认类型 */ UINT16 suffix; /* 0xFFEE */ } __attribute__((packed)) MSG_DEV_THUMB_LIST_Get_Rsp_T; @@ -569,6 +572,18 @@ typedef struct UINT16 suffix; /* 0xFFEE */ } __attribute__((packed)) MSG_DEV_FormatSDCard_Ctrl_RSP_T; +typedef struct +{ +UINT8 format; /* 1:format immediately */ + UINT16 sufix; /* 0xFFEE */ +} __attribute__((packed)) MSG_DEV_FormatEmmcCard_Ctrl_T; + +typedef struct +{ +UINT8 cmdRet; /* 0: mean cmd OK other:mean cmd error */ +UINT16 suffix; /* 0xFFEE */ +} __attribute__((packed)) MSG_DEV_FormatEmmcCard_Ctrl_RSP_T; + typedef struct { UINT8 reboot; /* 1: Reboot */ @@ -882,6 +897,10 @@ typedef struct /*Network select*/ MSG_DEV_NetworkSelect_Ctrl_T ctrlNetworkSelect; MSG_DEV_NetworkSelect_Ctrl_Rsp_T rctrlNetworkSelect; + + /*格式化Emmc*/ + MSG_DEV_FormatEmmcCard_Ctrl_T ctrlFormatEmmc; + MSG_DEV_FormatEmmcCard_Ctrl_RSP_T rctrlFormatEmmc; }; } __attribute__((packed)) APP_MSG_T; diff --git a/code/application/source/sf_app/code/source/wifi/sf_data_transfer.c b/code/application/source/sf_app/code/source/wifi/sf_data_transfer.c index bf7a87db5..ccdf1a949 100755 --- a/code/application/source/sf_app/code/source/wifi/sf_data_transfer.c +++ b/code/application/source/sf_app/code/source/wifi/sf_data_transfer.c @@ -150,6 +150,12 @@ static clientContext_t* DeleteClientContext( clientContext_t **ppClientHead, if (pClient == *ppClientHead) { pTemp = *ppClientHead; + if(pTemp == NULL) + { + MLOGE(" pTemp NULL\n"); + pthread_mutex_unlock(&gAppDataSvrMutex); + return NULL; + } *ppClientHead = (*ppClientHead)->p_next ; close(pTemp->socket); free(pTemp); @@ -166,6 +172,12 @@ static clientContext_t* DeleteClientContext( clientContext_t **ppClientHead, if (pCurr == pClient) { pTemp = pCurr->p_next; + if(pTemp == NULL) + { + MLOGE(" pTemp NULL\n"); + pthread_mutex_unlock(&gAppDataSvrMutex); + return NULL; + } pPrev->p_next = pTemp; close(pCurr->socket); free(pCurr); @@ -299,6 +311,11 @@ void sf_DataMapClear(clientContext_t *pClient) { //pClient->map.key = 0; // printf("pClient.map:%d,socket:%d\n",pClient->map.fd,pClient->socket); + if(pClient == NULL) + { + MLOGE(" pClient NULL\n"); + return; + } if(pClient->map.fd) close(pClient->map.fd); @@ -354,10 +371,11 @@ U8 sf_DataMapSet(U32 key, U8 function, S8 *fileName, U32 FileSize) pClient->map.function = function; if(function) { + memset((char *)&pClient->map.fileName[0],'\0', sizeof(pClient->map.fileName)); memcpy((char *)&pClient->map.fileName[0], (char *)fileName,strlen((char *)fileName)); // pClient->map.fileName[strlen(fileName)+1]=0; pClient->map.fileSize = FileSize; - printf("pClient->map.function:%d map.fileName:%s,filename:%s,len:%d fileSize:%d\n",pClient->map.function, pClient->map.fileName,fileName,strlen((char *)fileName),pClient->map.fileSize); + MLOGI("pClient->map.function:%d map.fileName:%s,filename:%s,len:%d fileSize:%d\n",pClient->map.function, pClient->map.fileName,fileName,strlen((char *)fileName),pClient->map.fileSize); } else @@ -377,6 +395,7 @@ U8 sf_DataMapSet(U32 key, U8 function, S8 *fileName, U32 FileSize) } } pthread_mutex_unlock(&gAppDataSvrMutex); + // MLOGI("SUCCESS\n"); return SUCCESS; } pClient = pClient->p_next; @@ -568,13 +587,14 @@ void *sf_DataSvrTransferThread(void *addr) else if(pClient->map.function == 2) //download { sf_set_auto_off_time(0);/*reset power off count time*/ - // printf("[read],fd:%x,pClient->map.fileName:%s,len:%d\n",pClient->map.fd,pClient->map.fileName,strlen((char*)(pClient->map.fileName))); + // MLOGI("[read],fd:%x,pClient->map.fileName:%s,len:%d\n",pClient->map.fd,pClient->map.fileName,strlen((char*)(pClient->map.fileName))); if(pClient->map.fd <= 0) { if(pClient->map.fileName[0] != '\0') { pClient->map.fd = open((char *)pClient->map.fileName, O_RDWR,0/*borbuild FS_OPEN_RDONLY*/); // printf("pClient->map.fd = %d\n",pClient->map.fd); + // MLOGI("pClient->map.fd = %d\n",pClient->map.fd); if(pClient->map.fd == -1) { //open file failed. @@ -585,6 +605,7 @@ void *sf_DataSvrTransferThread(void *addr) pClient->map.fileSize = sp5kFsFileSizeGet((char *)pClient->map.fileName); pClient->map.transferSize = 0; // printf("filesize=%d\n",pClient->map.fileSize); + // MLOGI("pClient->map.fileSize = %d\n",pClient->map.fileSize); //i = 0; } else @@ -597,7 +618,7 @@ void *sf_DataSvrTransferThread(void *addr) } readSize = read(pClient->map.fd, pClient->szBuffer, PACKET_MAX_LEN); - // printf("[read],fd:%x,readsize:%d,len:%x\n",pClient->map.fd,readSize,PACKET_MAX_LEN); + // MLOGI("[read],fd:%x,readsize:%d,len:%d\n",pClient->map.fd,readSize,PACKET_MAX_LEN); if(readSize > 0) { //printf("data socket send->%d\n",pClient->socket); @@ -641,7 +662,7 @@ void *sf_DataSvrTransferThread(void *addr) if(pClient->map.transferSize >= pClient->map.fileSize) { - // printf("send success!\n"); + // MLOGI("send success!\n"); sf_DataMapClear(pClient); //dataTransErrCodeSet(pClient->map.key, CMD_SUCCESS);//remove,because APP not use } diff --git a/code/application/source/sf_app/code/source/wifi/sf_wifi_svr.c b/code/application/source/sf_app/code/source/wifi/sf_wifi_svr.c index 05ac61b75..9a2a826b3 100755 --- a/code/application/source/sf_app/code/source/wifi/sf_wifi_svr.c +++ b/code/application/source/sf_app/code/source/wifi/sf_wifi_svr.c @@ -601,10 +601,12 @@ void appsvr_getFileList(UINT8 *dirPath, UINT8 *startFileKey) //MLOGI("name:%s.\n", ptr->d_name); if(strstr((char *)ptr->d_name, SF_DCF_EXT_MOV) || strstr((char *)ptr->d_name, SF_DCF_EXT_PHOTO)) { + memset(gDevFileList[nFileNums + gDevFileListNums].fileNameString,'\0', sizeof(gDevFileList[nFileNums + gDevFileListNums].fileNameString)); snprintf((char *)gDevFileList[nFileNums + gDevFileListNums].fileNameString, sizeof(gDevFileList[nFileNums + gDevFileListNums].fileNameString), "%s", (char *)ptr->d_name); //strcpy((char *)gDevFileList[nFileNums + gDevFileListNums].fileNameString, (char *)ptr->d_name); gDevFileList[nFileNums + gDevFileListNums].srcFileType = (ptr->d_name[0] == 'W' ? 0 : (ptr->d_name[0] == 'S' ? 1 : 1));//ptr->d_name[3] - '0'; //printf("%s\n", g3g75DevFileList[nFileNums - idx + gDevFileListNums].fileName); + // MLOGI("fileNameString:%s. srcFileType:%d\n", gDevFileList[nFileNums + gDevFileListNums].fileNameString, gDevFileList[nFileNums + gDevFileListNums].srcFileType); nFileNums ++ ; // MLOGI("fileNameString:%s. srcFileType:%d\n", gDevFileList[nFileNums + gDevFileListNums].fileNameString, gDevFileList[nFileNums + gDevFileListNums].srcFileType); } @@ -728,12 +730,13 @@ UINT8 appCmpFileList(void) } -void appCreatThumbList(S8 *fileName)//start file name example: 10010032.JPG +void appCreatThumbList(S8 *fileName,UINT8 diskType)//start file name example: 10010032.JPG { //UINT16 i = 0; UINT8 dirPath[50] = {0}; UINT8 startDirKey[5] = {0}; UINT8 startFileKey[5] = {0}; + //UINT16 dirKey = 0; //UINT8 temp[5] = {0}; MLOGI("fileName:%s\n",fileName); @@ -747,9 +750,14 @@ void appCreatThumbList(S8 *fileName)//start file name example: 10010032.JPG if(fileName != NULL && fileName[0] != '\0' && fileName[0] != '0' && (strstr((char *)fileName, SF_DCF_EXT_MOV) || strstr((char *)fileName, SF_DCF_EXT_PHOTO))) { - MLOGI("fileName2:%s\n",fileName); + //MLOGI("fileName2:%s\n",fileName); + //strncpy((char *)startDirKey, (char *)fileName+1, 2); + //dirKey = atoi((const char *)startDirKey) + 100; + //snprintf((char *)startDirKey, sizeof(startDirKey), "%03d", dirKey); + //strncpy((char *)startFileKey, (char *)fileName+4, 4); strncpy((char *)startDirKey, (char *)fileName, 3); strncpy((char *)startFileKey, (char *)fileName+4, 4); + //MLOGI("startDirKey:%s startFileKey:%s\n", startDirKey, startFileKey); } else { @@ -764,8 +772,18 @@ void appCreatThumbList(S8 *fileName)//start file name example: 10010032.JPG gDevFileListNums = 0; //printf("get dir s\n"); //sprintf((char *)dirPath, "%s/", THUMB_PATH); - snprintf((char *)dirPath, sizeof(dirPath), "%s%s", strg_path, (char *)THUMB_PATH); - free(strg_path); + if(diskType == 2) + { + snprintf((char *)dirPath, sizeof(dirPath), "%s%s", SF_SD_ROOT, (char *)THUMB_PATH); + } + else if(diskType == 1) + { + snprintf((char *)dirPath, sizeof(dirPath), "%s%s", SF_EMMC_ROOT, (char *)THUMB_PATH); + } + else { + snprintf((char *)dirPath, sizeof(dirPath), "%s%s", strg_path, (char *)THUMB_PATH); + } + free(strg_path); appsvr_getFileList(dirPath, startFileKey); // appsvr_getDirList(dirPath, startDirKey); @@ -1126,9 +1144,10 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen) SF_PARA_TIME_S time; UINT32 curMode = 0; CHAR fileName[SF_FILENAME_MAXLEN]; - UINT16 dirKey, fileKey, fileType; + UINT16 dirKey; UINT32 keyMap = 0; UINT8 function = 0; + static UINT32 Disk = 0; /* 1:emmc 2:sd */ static UINT32 zmFactor[] = {1000,2000,3018,4000}; UIMenuStoreInfo *puiPara = sf_ui_para_get(); @@ -1136,6 +1155,7 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen) UINT8 paramSaveFlag = 0; SF_MESSAGE_BUF_S stMessageBuf = {0}; // HI_MESSAGE_S stMessage; + MLOGI(" s\n"); char *strg_path = sf_get_root_path(); if(strg_path == NULL) @@ -1144,8 +1164,8 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen) return SF_FAILURE; } - UINT32 dcf_handle = (UINT32)System_Get_DCF_Handle(); /* 0:emmc 1:sd */ - char *dcf_file = System_Get_DCF_Disk_Drive(dcf_handle) == SF_EMMC_DCF_HANDLE ? SF_EMMC_DCF_FILE_NAME : SF_SD_DCF_FILE_NAME; + UINT32 dcf_handle = 0; /* 0:emmc 1:sd */ + //char *dcf_file = System_Get_DCF_Disk_Drive(dcf_handle) == SF_EMMC_DCF_HANDLE ? SF_EMMC_DCF_FILE_NAME : SF_SD_DCF_FILE_NAME; //printf("[sf_svr_packet_proc]dataLen: %d\n",dataLen); @@ -1229,7 +1249,7 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen) respFlag = -1; if(msgParse.cmd != WIFI_GET_CAMERA_CONNECT) - printf("cmd: %d\n",msgParse.cmd); + printf("cmd: 0x%x\n",msgParse.cmd); if(msgParse.cmd < WIFI_CMD_MAX) { @@ -1288,10 +1308,14 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen) case WIFI_GET_CAMERA_THUMB_LIST: //o strcpy((char *)fileName, (char *)pMsgStruct->msgBuf.getThumbList.fileName); - MLOGI("[WIFI_GET_CAMERA_THUMB_LIST],fileName:%s\n",fileName); - appCreatThumbList(fileName); - MLOGI("[WIFI_GET_CAMERA_THUMB_LIST],fileName:%s\n",fileName); - + if((pMsgStruct->msgBuf.getThumbList.diskType) && (Disk != pMsgStruct->msgBuf.getThumbList.diskType)) + { + Disk = pMsgStruct->msgBuf.getThumbList.diskType; + memset(fileName,'\0', sizeof(fileName)); + } + MLOGI("[WIFI_GET_CAMERA_THUMB_LIST],fileName:%s diskType:%d\n",fileName,pMsgStruct->msgBuf.getThumbList.diskType); + appCreatThumbList(fileName,pMsgStruct->msgBuf.getThumbList.diskType); + //MLOGI("[WIFI_GET_CAMERA_THUMB_LIST],fileName:%s\n",fileName); memset((void *)&msgParse, 0, sizeof(msgParse)); msgParse.magicNum = htons(MSG_PRE_FIX); msgParse.msglen = htons(sizeof(MSG_DEV_THUMB_LIST_Get_Rsp_T) + 2*sizeof(UINT16)); @@ -1300,7 +1324,11 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen) msgParse.msgBuf.rgetThumbList.cmdRet = 0; msgParse.msgBuf.rgetThumbList.fileNums = htonl(gDevFileListNums); msgParse.msgBuf.rgetThumbList.packageSize = htonl(gDevFileListNums*sizeof(MSG_DEV_THUMB_LIST_Get_Data_Rsp_T)); + //dcf_handle + dcf_handle = (UINT32)System_Get_DCF_Handle(); /* 0:emmc 1:sd */ + msgParse.msgBuf.rgetThumbList.diskType = pMsgStruct->msgBuf.getThumbList.diskType == 0 ? (dcf_handle == 0 ? 1:1):pMsgStruct->msgBuf.getThumbList.diskType; msgParse.msgBuf.rgetThumbList.suffix = htons(MSG_END_FIX); + MLOGI("msgParse.msgBuf.rgetThumbList.diskType:%d\n",msgParse.msgBuf.rgetThumbList.diskType); /* add the magic + len total 2*2 bytes; */ temp = ntohs(msgParse.msglen); send(fd, (void *)(&msgParse), (temp + sizeof(UINT16)*2), 0); @@ -1352,21 +1380,30 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen) if(pMsgStruct->msgBuf.getHdFile.type == 0) //thumbnail { strcpy((char *)tempbuf, (char *)pMsgStruct->msgBuf.getHdFile.dirName); - strncpy((char *)tempbuf2, (char *)pMsgStruct->msgBuf.getHdFile.dirName, 3); - sprintf((char *)gFileName, "%s%s%s/%s", strg_path, THUMB_PATH, tempbuf2, tempbuf); + if(strstr((char*)tempbuf, "E")) + { + snprintf(gFileName, sizeof(gFileName), "%s%s%s", SF_SD_ROOT, THUMB_PATH, tempbuf); + } + else + { + snprintf(gFileName, sizeof(gFileName), "%s%s%s", SF_EMMC_ROOT, THUMB_PATH, tempbuf); + } } else if(pMsgStruct->msgBuf.getHdFile.type == 1) //srouce file { - strcpy((char *)tempbuf, (char *)pMsgStruct->msgBuf.getHdFile.dirName); - strncpy((char *)tempbuf2, (char *)tempbuf, 3); + strcpy((char *)tempbuf, (char *)pMsgStruct->msgBuf.ctrlFileTransfer.fileName); + strncpy((char *)tempbuf2, (char *)pMsgStruct->msgBuf.ctrlFileTransfer.fileName +2, 2); + dirKey = atoi((const char *)tempbuf2) + 100; + tempbuf[8] = '\0'; - sprintf((char *)gFileName, "%sDCIM/%s%s/%s%s%s", - strg_path, - tempbuf2, - DCF_DIR_NAME, - dcf_file, - tempbuf+4, - (tempbuf[3] == '0' ? ".JPG" : (tempbuf[3] == '1' ? ".MP4" : ".MP4"))); + if(strstr((char*)tempbuf, "E")) + { + snprintf(fileName, sizeof(fileName), "%sDCIM/%03d%s/%s%s%s", SF_SD_ROOT, dirKey, DCF_DIR_NAME, SF_SD_DCF_FILE_NAME, tempbuf+4, (tempbuf[0] == 'W' ? ".JPG" : (tempbuf[0] == 'S' ? ".MP4" : ".MP4"))); + } + else// + { + snprintf(fileName, sizeof(fileName), "%sDCIM/%03d%s/%s%s%s", SF_EMMC_ROOT, dirKey, DCF_DIR_NAME, SF_EMMC_DCF_FILE_NAME, tempbuf+4, (tempbuf[0] == 'W' ? ".JPG" : (tempbuf[0] == 'S' ? ".MP4" : ".MP4"))); + } } else { @@ -1484,7 +1521,7 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen) } else if(tmpValue == 1) { - puiPara->ImgSize = PHOTO_SIZE_12M; + //puiPara->ImgSize = PHOTO_SIZE_12M; } else if(tmpValue == 2) { @@ -1626,7 +1663,7 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen) case WIFI_SET_CAMERA_NightMode: //O MLOGI("[WIFI_SET_CAMERA_NightMode],nightMode:%d\n",pMsgStruct->msgBuf.setNightMode.nightMode); - puiPara->NightMode = pMsgStruct->msgBuf.setNightMode.nightMode % 3; + //puiPara->NightMode = pMsgStruct->msgBuf.setNightMode.nightMode % 3; //sf_set_img_size(puiPara->ImgSize); respFlag = 2; paramSaveFlag = 1; @@ -1887,27 +1924,38 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen) if(function) { + memset(tempbuf,'\0', sizeof(tempbuf)); + memset(tempbuf2,'\0', sizeof(tempbuf2)); + memset(fileName,'\0', sizeof(fileName)); if(pMsgStruct->msgBuf.ctrlFileTransfer.type == 0) //thumbnail { //strcpy((char *)tempbuf, (char *)pMsgStruct->msgBuf.ctrlFileTransfer.fileName); - memcpy((char *)tempbuf, (char *)pMsgStruct->msgBuf.ctrlFileTransfer.fileName,strlen((char *)pMsgStruct->msgBuf.ctrlFileTransfer.fileName)); - - sprintf((char *)fileName, "%s%s%s", strg_path, THUMB_PATH, tempbuf); - + snprintf((char *)tempbuf, sizeof(tempbuf), "%s", pMsgStruct->msgBuf.ctrlFileTransfer.fileName); + //memcpy((char *)tempbuf, (char *)pMsgStruct->msgBuf.ctrlFileTransfer.fileName,strlen((char *)pMsgStruct->msgBuf.ctrlFileTransfer.fileName)); + if(strstr((char*)tempbuf, "E")) + { + snprintf(fileName, sizeof(fileName), "%s%s%s", SF_SD_ROOT, THUMB_PATH, tempbuf); + } + else + { + snprintf(fileName, sizeof(fileName), "%s%s%s", SF_EMMC_ROOT, THUMB_PATH, tempbuf); + } } else if(pMsgStruct->msgBuf.ctrlFileTransfer.type == 1) //srouce file { strcpy((char *)tempbuf, (char *)pMsgStruct->msgBuf.ctrlFileTransfer.fileName); - strncpy((char *)tempbuf2, (char *)pMsgStruct->msgBuf.ctrlFileTransfer.fileName +1, 3); + strncpy((char *)tempbuf2, (char *)pMsgStruct->msgBuf.ctrlFileTransfer.fileName +2, 2); + dirKey = atoi((const char *)tempbuf2) + 100; tempbuf[8] = '\0'; - sprintf((char *)fileName, "%sDCIM/%s%s/%s%s%s", - strg_path, - tempbuf2, - DCF_DIR_NAME, - dcf_file, - tempbuf+4, - (tempbuf[0] == 'W' ? ".JPG" : (tempbuf[0] == 'S' ? ".MP4" : ".MP4"))); + if(strstr((char*)tempbuf, "E")) + { + snprintf(fileName, sizeof(fileName), "%sDCIM/%03d%s/%s%s%s", SF_SD_ROOT, dirKey, DCF_DIR_NAME, SF_SD_DCF_FILE_NAME, tempbuf+4, (tempbuf[0] == 'W' ? ".JPG" : (tempbuf[0] == 'S' ? ".MP4" : ".MP4"))); + } + else// + { + snprintf(fileName, sizeof(fileName), "%sDCIM/%03d%s/%s%s%s", SF_EMMC_ROOT, dirKey, DCF_DIR_NAME, SF_EMMC_DCF_FILE_NAME, tempbuf+4, (tempbuf[0] == 'W' ? ".JPG" : (tempbuf[0] == 'S' ? ".MP4" : ".MP4"))); + } } else { @@ -1937,7 +1985,7 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen) // msgParse.msgBuf.rctrlFileTransferInfo.filePath[13]=0; msgParse.msgBuf.rctrlFileTransferInfo.type = (tempbuf[0] == 'W' ? 0 : (tempbuf[0] == 'S' ? 1 : 1)); fileFd = open((char *)fileName, O_RDONLY); - //printf("fileFd = %d rctrlFileTransferInfo.type:%d\n", fileFd,msgParse.msgBuf.rctrlFileTransferInfo.type); + //MLOGI("fileFd = %d rctrlFileTransferInfo.type:%d fileName:%s filePath:%s\n", fileFd,msgParse.msgBuf.rctrlFileTransferInfo.type, msgParse.msgBuf.rctrlFileTransferInfo.fileName, msgParse.msgBuf.rctrlFileTransferInfo.filePath); if(fileFd > 0) { fSize = sp5kFsFileSizeGet((char *)fileName); @@ -1961,6 +2009,7 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen) else { ret = DATA_CMD_OPEN_FILE_FAIL;/*fileOpen fail*/ + MLOGE("fileName:%s ret:0x%x\n", fileName, ret); } } @@ -2000,25 +2049,41 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen) case WIFI_CONTROL_CAMERA_DeleteFile: //O MLOGI("[WIFI_SET_FILE_DeleteFile],fileName:%s\n",pMsgStruct->msgBuf.ctrlDelFile.fileName); - strcpy((char *)fileName, (char *)pMsgStruct->msgBuf.ctrlDelFile.fileName); - if(strlen((char *)fileName) == 12) // only file name - { - appThumbNameToKey((thumbType_t *)&fileType, &dirKey, &fileKey, fileName); - appThumbKeyToName(THUMB_320x240, fileType, dirKey, fileKey, fileName); - ret = remove((char *)fileName); - MLOGI("delete thumb name=%s ret=%d\n",fileName,ret); - if(fileType == STILL_THUMB) - sprintf((char *)fileName,"./%3dMEDIA/%s%04d.JPG", dirKey, dcf_file, fileKey); - else - sprintf((char *)fileName,"./%3dMEDIA/%s%04d.MP4", dirKey, dcf_file, fileKey); - ret = remove((char *)fileName); + memset(tempbuf,'\0', sizeof(tempbuf)); + memset(tempbuf2,'\0', sizeof(tempbuf2)); + memset(fileName,'\0', sizeof(fileName)); + if(strlen((char *)pMsgStruct->msgBuf.ctrlDelFile.fileName) == 12) // only file name + { + strcpy((char *)tempbuf, (char *)pMsgStruct->msgBuf.ctrlDelFile.fileName); + strncpy((char *)tempbuf2, (char *)pMsgStruct->msgBuf.ctrlDelFile.fileName +2, 2); + dirKey = atoi((const char *)tempbuf2) + 100; + if(strstr((char*)pMsgStruct->msgBuf.ctrlDelFile.fileName, "E")) + { + snprintf(fileName, sizeof(fileName), "%s%s%s", SF_SD_ROOT, THUMB_PATH, pMsgStruct->msgBuf.ctrlDelFile.fileName); + ret = remove((char *)fileName); + MLOGI("delete thumb name=%s ret=%d\n",fileName,ret); + + snprintf(fileName, sizeof(fileName), "%sDCIM/%03d%s/%s%s%s", SF_SD_ROOT, dirKey, DCF_DIR_NAME, SF_SD_DCF_FILE_NAME, tempbuf+4, (tempbuf[0] == 'W' ? ".JPG" : (tempbuf[0] == 'S' ? ".MP4" : ".MP4"))); + ret = remove((char *)fileName); + MLOGI("delete src name=%s ret=%d\n",fileName,ret); + } + else + { + snprintf(fileName, sizeof(fileName), "%s%s%s", SF_EMMC_ROOT, THUMB_PATH, pMsgStruct->msgBuf.ctrlDelFile.fileName); + ret = remove((char *)fileName); + MLOGI("delete thumb name=%s ret=%d\n",fileName,ret); + + snprintf(fileName, sizeof(fileName), "%sDCIM/%03d%s/%s%s%s", SF_EMMC_ROOT, dirKey, DCF_DIR_NAME, SF_EMMC_DCF_FILE_NAME, tempbuf+4, (tempbuf[0] == 'W' ? ".JPG" : (tempbuf[0] == 'S' ? ".MP4" : ".MP4"))); + ret = remove((char *)fileName); + MLOGI("delete src name=%s ret=%d\n",fileName,ret); + } } else // path + file name { ret = remove((char *)fileName); } - + system("sync"); msgParse.msgBuf.rctrlDelFile.cmdRet = (ret ? 1 : 0); msgParse.msgBuf.rctrlDelFile.suffix = htons(MSG_END_FIX); /* add the cmd + resp total 2*2 bytes */ @@ -2169,7 +2234,23 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen) respFlag = 0; break; #endif - + case WIFI_CONTROL_CAMERA_FormatEmmcCard: //err + MLOGI("[WIFI_CONTROL_CAMERA_FormatSDCard],format:%d\n",pMsgStruct->msgBuf.ctrlFormatEmmc.format); + if(pMsgStruct->msgBuf.ctrlFormatEmmc.format == 1) + { + sf_set_card_statu(CMD_FORMAT_SD_STA); + BKG_PostEvent(NVTEVT_BKW_FORMAT_EMMC); + while(CMD_FORMAT_SD_STA == sf_get_card_statu()) + { + usleep(10*1000); + } + ret = sf_get_card_statu(); + } + msgParse.msgBuf.camreaSetRsp.cmdRet = ret; + msgParse.msgBuf.camreaSetRsp.suffix = htons(MSG_END_FIX); + msgParse.msglen = htons(sizeof(MSG_DEV_SET_Rsp_T) + 2*sizeof(UINT16) ); + respFlag = 1; + break; default: WIFI_SLOGI("[WIFI_CMD_MAX] default\n"); msgParse.msgBuf.camreaSetRsp.cmdRet = -1; @@ -2551,6 +2632,7 @@ void *sf_server_accept_thread(void *pData) pClient->totalBytes = nbytes; ret = sf_svr_packet_proc(pClient->socket,pClient->szBuffer,nbytes); + MLOGI(" sf_svr_packet_proc e ret:%x\n", ret); /*forbuild if(gFwUpdate == 1) {