diff --git a/code/application/source/sf_app/code/include/sf_service.h b/code/application/source/sf_app/code/include/sf_service.h index ed930acc1..6ddb3b610 100755 --- a/code/application/source/sf_app/code/include/sf_service.h +++ b/code/application/source/sf_app/code/include/sf_service.h @@ -63,7 +63,8 @@ SINT32 open_gps(const SINT32 utc); int get_gps_location(void); void keep_get_gps_location(const SF_GPS_PARAM param); void keep_seraching_gps_location(const int timeout_ms); - +int sf_check_sd(void); +void sf_save_camera_gps_info(void); #ifdef __cplusplus #if __cplusplus } diff --git a/code/application/source/sf_app/code/source/app/sf_service.c b/code/application/source/sf_app/code/source/app/sf_service.c index 8ae40920f..50c1ed566 100755 --- a/code/application/source/sf_app/code/source/app/sf_service.c +++ b/code/application/source/sf_app/code/source/app/sf_service.c @@ -1129,6 +1129,11 @@ static SINT32 app_file_transfer(SF_FN_PARAM_S *pfnParam) { SINT32 sf_cardv_file_to_app_send_thread(void) { SINT32 s32ret = 0; SF_FN_PARAM_S stpfncallback = {0}; + if(SF_FAILURE == sf_check_sd()) + { + MLOGE("ERROR sf_check_sd\n"); + return SF_FAILURE; + } stpfncallback.pstParam = sf_customer_param_get(); stpfncallback.pstaticParam = sf_app_ui_para_get(); // stpfncallback.pstaticParam = sf_statistics_param_get(); @@ -1165,6 +1170,12 @@ SINT32 sf_cardv_file_to_app_send_thread(void) { SINT32 sf_file_send_auto(void) { SINT32 s32ret = 0; SF_FN_PARAM_S stpfncallback = {0}; + if(SF_FAILURE == sf_check_sd()) + { + MLOGE("ERROR sf_check_sd\n"); + return SF_FAILURE; + } + stpfncallback.pstParam = sf_customer_param_get(); stpfncallback.pstaticParam = sf_app_ui_para_get(); // stpfncallback.pstaticParam = sf_statistics_param_get(); @@ -1433,9 +1444,15 @@ static SINT32 app_Register_Net_startup_mode(SF_FN_PARAM_S *pfnParam) { s32ret = sf_4G_register_net_manual(pfnParam); if (s32ret != SF_SUCCESS) { - sf_set_signal_ready_flag(TRUE); + sf_set_signal_ready_flag(TRUE); } - + + if (1 == pCustomerParam->NeedTimeSyncStartUp) { + printf("[%s:%d]8 between A and B,no reg net again,no reset time sync.\n", + __FUNCTION__, __LINE__); + sf_set_dr_reset_time_sys_flag(1); + } + if (0 != sf_get_cq_signal()) { pCustomerParam->NeedTimeSyncStartUp = 1; } @@ -1456,11 +1473,7 @@ static SINT32 app_Register_Net_startup_mode(SF_FN_PARAM_S *pfnParam) { if ((SF_ON == pCustomerParam->GpsSwitch)) { s32ret = open_gps(s32ret); } - if (1 == pCustomerParam->NeedTimeSyncStartUp) { - printf("[%s:%d]8 between A and B,no reg net again,no reset time sync.\n", - __FUNCTION__, __LINE__); - sf_set_dr_reset_time_sys_flag(1); - } + //sf_dailyReport_set(); //sf_share_mem_customer_down(1); @@ -1821,6 +1834,7 @@ int get_gps_location(void) strcpy(pCustomerParam->Latitude, location.latitude); LogInfo("location.Longitude = %s\n", pCustomerParam->Longitude); LogInfo("location.Latitude = %s\n", pCustomerParam->Latitude); + sf_save_camera_gps_info(); return GPS_GET_SUCCEED; } return GPS_GET_FAILED; @@ -1889,6 +1903,76 @@ void serach_gps_onkey_start(void) pthread_attr_destroy(&attr); } +int sf_check_sd(void) +{ + UINT8 i = 0; + int ret = SF_SUCCESS; + if (sf_sd_status_get() != SF_SD_OK) { + ret = SF_FAILURE; + for (i = 0; i < 20; i++) { + ret = sf_sd_status_get(); + if (SF_SD_OK == ret) { + ret = SF_SUCCESS; + MLOGI("usb net ip up\r\n"); + break; + } else { + sleep(1); + } + } + return ret; + } + return ret; +} +/************************************************* + Function: sf_save_camera_info + Description: save camera info to sd + Input: N/A + Output: N/A + Return: N/A + Others: N/A +*************************************************/ +void sf_save_camera_gps_info(void) +{ + UIMenuStoreInfo *puiPara = sf_app_ui_para_get(); + char *temp = NULL; + int fd = 0; + printf("[%s:%d] s\n", __FUNCTION__, __LINE__); + + //if(fristRun == 0) + // return; + + //fristRun = 0; + temp = malloc(200); + if (temp == NULL) { + MLOGE("temp malloc err\n"); + return; + } + + memset(temp,'\0', 200); + sprintf(temp, "LATITUDE:%s\r\nLONGITUDE:%s\r\n", puiPara->Latitude, puiPara->Longitude); + + printf("[%s:%d] \n%s\n", __FUNCTION__, __LINE__,temp); + + if(access((char*)SF_CAMERA_GPS_INFO_FILENAME, F_OK) == 0) + { + system("rm -rf /mnt/sd/gps.txt"); + system("sync"); + printf("[%s:%d] rm\n", __FUNCTION__, __LINE__); + + //FileSys_DeleteFile(); + } + fd = open(SF_CAMERA_GPS_INFO_FILENAME, O_WRONLY | O_CREAT); + if(fd) + { + lseek(fd, 0, SEEK_END); + write(fd, temp, strlen(temp)); + close(fd); + system("sync"); + } + free(temp); + + printf("[%s:%d] e\n", __FUNCTION__, __LINE__); +} #ifdef __cplusplus #if __cplusplus }