1.增加SD卡报警功能
This commit is contained in:
parent
1956c8aef5
commit
f90c8c3d97
|
@ -578,6 +578,7 @@ typedef struct _UIMenuUIMenuStoreInfo {
|
|||
CHAR BluSwitch;/*OFF/ON*/
|
||||
CHAR SimIccidV[21];
|
||||
CHAR SimIccidA[21];
|
||||
UINT32 SdFailCount;
|
||||
UINT32 x1;
|
||||
UINT32 x2;
|
||||
UINT32 x3;
|
||||
|
|
|
@ -44,6 +44,7 @@ BOOL sf_check_auto_thumb_file(VOID);
|
|||
UINT8 sf_get_send_file_total(void);
|
||||
SINT32 sf_mem_upload_file_to_module(UINT32 MemPhotoAddr, UINT32 MemPhotosize);
|
||||
SINT32 sf_usr_mem_photo_ch(void);
|
||||
UINT8 sf_save_sd_log(void);
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
|
|
@ -225,5 +225,6 @@ double sf_sys_s_time_get(time_t end_time);
|
|||
time_t sf_time (time_t *__timer);
|
||||
SINT32 sf_gps_send_ftp(void);
|
||||
SINT32 sf_test_send_file_to_ftp(void);
|
||||
SINT32 sf_card_log_send_ftp(void);
|
||||
#endif /*_SF_FTP_H_*/
|
||||
|
||||
|
|
|
@ -3029,6 +3029,75 @@ SINT32 sf_test_send_file_to_ftp(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
SINT32 sf_card_log_send_ftp(void)
|
||||
{
|
||||
SINT32 ret = SF_SUCCESS;
|
||||
SINT32 ret2 = SF_SUCCESS; //0:success; else:fail;
|
||||
UINT8 uploadFname[64] = { 0 };
|
||||
UINT8 customStr[64] = { 0 };
|
||||
UINT8 filePath[64] = { 0 };
|
||||
int timeout = 120000;
|
||||
UIMenuStoreInfo *pPara = sf_app_ui_para_get();
|
||||
UINT8 ssl = 0;
|
||||
UINT8 gprsMode = 0;
|
||||
ssl = ((2 == pPara->FtpSwitch) ? 1 : 0);
|
||||
gprsMode = 0;//puiPara->GprsMode;
|
||||
|
||||
MLOGD("start\n");
|
||||
if(0 != sf_save_sd_log())
|
||||
{
|
||||
printf("%s:%d err file\n", __FUNCTION__, __LINE__);
|
||||
return SF_FAILURE;
|
||||
}
|
||||
|
||||
ret = sf_ftp_config(ssl, gprsMode, timeout);
|
||||
|
||||
if(SF_SUCCESS == ret)
|
||||
{
|
||||
//sprintf((char *)filePath, "UFS:/%s", SF_LOG_TXT);
|
||||
sprintf((char *)filePath, "%s", SF_SD_LOG_INFO_FILENAME);
|
||||
|
||||
printf("%s:%d filePath:%s\n", __FUNCTION__, __LINE__, filePath);
|
||||
|
||||
sf_custom_str_get(customStr);
|
||||
sprintf((char *)uploadFname, "%s-%s-SD.txt",pPara->ModuleImei, customStr);
|
||||
|
||||
ret = SF_SUCCESS;//sf_quectel_upload_file_to_module((UINT8 *)SF_SD_LOG_INFO_FILENAME, (UINT8 *)SF_LOG_TXT);
|
||||
|
||||
if(SF_SUCCESS != ret)
|
||||
{
|
||||
printf("%s:%d upload err ret: [0x%08X] filePath:%s\n", __FUNCTION__, __LINE__, ret, filePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = sf_ftp_send(uploadFname, filePath, timeout);
|
||||
|
||||
if(SF_SUCCESS != ret)
|
||||
{
|
||||
printf("%s:%d err ret: [0x%08X] filePath:%s\n", __FUNCTION__, __LINE__, ret, filePath);
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if(ret != SF_FTP_ERROR_TERM)
|
||||
{
|
||||
ret2 = sf_ftp_stop(ssl, gprsMode);
|
||||
}
|
||||
|
||||
MLOGD(" end ret:[0x%08X],ret2:[0x%08X]\n", ret, ret2);
|
||||
|
||||
if(ret != SF_SUCCESS)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ret2;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
|
|
@ -2420,13 +2420,13 @@ SINT32 sf_power_off_check_sd(void)
|
|||
SF_STORE_ATTR_S storeattrs = {0};
|
||||
|
||||
/******************** SD cycle *************************/
|
||||
if((sf_in_card_exist() && (sf_is_card())) || (sf_get_mode_flag() == 1))
|
||||
{
|
||||
//sf_ErrorLogCopyToCard();
|
||||
//sf_FlowLogCopyToCard();
|
||||
|
||||
if((puiPara->SdLoopSwitch) && (!sf_get_mode_flag()))
|
||||
{
|
||||
if((sf_in_card_exist() && (sf_is_card())) || (sf_get_mode_flag() == 1))
|
||||
{
|
||||
//sf_ErrorLogCopyToCard();
|
||||
//sf_FlowLogCopyToCard();
|
||||
|
||||
if((puiPara->SdLoopSwitch) && (!sf_get_mode_flag()))
|
||||
{
|
||||
sf_sd_info_get(&storeattrs);
|
||||
if((storeattrs.SDStatus == 0) & (storeattrs.SDFree < SDLOOP_REMAIN_SPACE))
|
||||
{
|
||||
|
@ -2434,28 +2434,46 @@ SINT32 sf_power_off_check_sd(void)
|
|||
sf_app_sd_loop();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(sf_in_card_exist())
|
||||
{
|
||||
if(sf_get_mode_flag() || ((0 == puiPara->SendType)))
|
||||
sf_delete_send_flie_list();
|
||||
}
|
||||
|
||||
/*check disk free size*/
|
||||
if(sf_in_card_exist())
|
||||
{
|
||||
if(sf_get_mode_flag() || ((0 == puiPara->SendType)))
|
||||
sf_delete_send_flie_list();
|
||||
}
|
||||
|
||||
/*check disk free size*/
|
||||
SF_STORE_ATTR_S storeattrs = {0};
|
||||
sf_sd_info_get(&storeattrs);
|
||||
|
||||
printf("SD free=%dM/%dM\n", storeattrs.SDFree, storeattrs.SDTotalSize);
|
||||
|
||||
if(storeattrs.SDFree < 30) /* 30MB */
|
||||
{
|
||||
if(puiPara->SdLoopSwitch == 0)
|
||||
{
|
||||
sf_set_card_full(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("SD free=%dM/%dM\n", storeattrs.SDFree, storeattrs.SDTotalSize);
|
||||
|
||||
if(storeattrs.SDFree < 30) /* 30MB */
|
||||
{
|
||||
if(puiPara->SdLoopSwitch == 0)
|
||||
{
|
||||
sf_set_card_full(1);
|
||||
puiPara->SdFailCount++;
|
||||
sf_sleep_ms(100);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(puiPara->SdFailCount)
|
||||
{
|
||||
puiPara->SdFailCount = 0;
|
||||
sf_sleep_ms(100);
|
||||
}
|
||||
}
|
||||
SYS_SLOGI("SdFailCount:%d\n",puiPara->SdFailCount);
|
||||
|
||||
}
|
||||
else if(!sf_in_card_exist())
|
||||
{
|
||||
puiPara->SdFailCount++;
|
||||
SYS_SLOGI("SdFailCount:%d\n",puiPara->SdFailCount);
|
||||
sf_sleep_ms(100);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1160,6 +1160,12 @@ static SINT32 app_file_transfer(SF_FN_PARAM_S *pfnParam) {
|
|||
{
|
||||
|
||||
s32ret = sf_send_file_to_ftp(2);
|
||||
if(pCustomerParam->SdFailCount)
|
||||
{
|
||||
SLOGD("SdFailCount:%d\n", pCustomerParam->SdFailCount);
|
||||
pCustomerParam->SdFailCount = 0;
|
||||
sf_sleep_ms(200);
|
||||
}
|
||||
//pCustomerParam->GpsSendFlag = 0;
|
||||
if(pCustomerParam->PicUpDailyReport){
|
||||
sf_sms_set_pic(1);
|
||||
|
@ -1251,6 +1257,9 @@ SINT32 sf_cardv_file_to_app_send_thread(void) {
|
|||
SINT32 sf_file_send_auto(void) {
|
||||
SINT32 s32ret = 0;
|
||||
SF_FN_PARAM_S stpfncallback = {0};
|
||||
UIMenuStoreInfo *puiPara = sf_app_ui_para_get();
|
||||
SINT8 Isfull = 0;
|
||||
|
||||
if(SF_FAILURE == sf_check_sd())
|
||||
{
|
||||
MLOGE("ERROR sf_check_sd\n");
|
||||
|
@ -1261,8 +1270,22 @@ SINT32 sf_file_send_auto(void) {
|
|||
return s32ret;
|
||||
}
|
||||
#endif
|
||||
if(2 == puiPara->SdFailCount)
|
||||
{
|
||||
s32ret = sf_card_log_send_ftp();
|
||||
return s32ret;
|
||||
}
|
||||
return SF_FAILURE;
|
||||
}
|
||||
else if(2 == puiPara->SdFailCount)
|
||||
{
|
||||
sleep(1);
|
||||
s32ret = sf_sd_isfull(&Isfull);
|
||||
if(Isfull)
|
||||
{
|
||||
s32ret = sf_card_log_send_ftp();
|
||||
}
|
||||
}
|
||||
|
||||
stpfncallback.pstParam = sf_customer_param_get();
|
||||
stpfncallback.pstaticParam = sf_app_ui_para_get();
|
||||
|
|
|
@ -1769,6 +1769,51 @@ SINT32 sf_usr_mem_photo_ch(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
/*************************************************
|
||||
Function: sf_save_sd_log
|
||||
Description: save sd log to sd
|
||||
Input: N/A
|
||||
Output: N/A
|
||||
Return: N/A
|
||||
Others: N/A
|
||||
*************************************************/
|
||||
UINT8 sf_save_sd_log(void)
|
||||
{
|
||||
UINT8 ret = 1;
|
||||
char *temp = NULL;
|
||||
int fd = 0;
|
||||
printf("[%s:%d] s\n", __FUNCTION__, __LINE__);
|
||||
|
||||
temp = malloc(50);
|
||||
if (temp == NULL) {
|
||||
MLOGE("temp malloc err\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(sf_in_card_exist())
|
||||
{
|
||||
snprintf(temp, 500, "not saving to external storage\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(temp, 500, "SD card removed\r\n");
|
||||
}
|
||||
|
||||
fd = open(SF_SD_LOG_INFO_FILENAME, O_WRONLY | O_CREAT);
|
||||
if(fd)
|
||||
{
|
||||
lseek(fd, 0, SEEK_END);
|
||||
write(fd, temp, strlen(temp));
|
||||
close(fd);
|
||||
system("sync");
|
||||
ret = 0;
|
||||
}
|
||||
free(temp);
|
||||
|
||||
printf("[%s:%d] e\n", __FUNCTION__, __LINE__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
|
|
@ -578,6 +578,8 @@ typedef struct _UIMenuUIMenuStoreInfo {
|
|||
CHAR BluSwitch;/*OFF/ON*/
|
||||
CHAR SimIccidV[21];
|
||||
CHAR SimIccidA[21];
|
||||
UINT32 SdFailCount;
|
||||
|
||||
UINT32 x1;
|
||||
UINT32 x2;
|
||||
UINT32 x3;
|
||||
|
|
Loading…
Reference in New Issue
Block a user