1.低电量警告;

2.集中发送问题;
3.dp统计值清空;
4.max num;
5.usb net检查20s
6.拨建时变量标识清空
This commit is contained in:
payton 2023-08-09 13:52:33 +08:00
parent 477d06b3dd
commit 82fc4f4bc7
9 changed files with 193 additions and 28 deletions

2
code/application/source/sf_app/code/include/sf_file.h Normal file → Executable file
View File

@ -25,6 +25,8 @@ void sf_app_set_battery(UINT8 val, UINT8 type);
UINT32 sf_create_dailyreport_file(void);
UINT32 sf_create_low_power_warn_file(void);
UINT8 sf_app_get_battery(void);
void sf_custom_send_str_get(UINT8 *sendName, UINT8 *pStr);

1
code/application/source/sf_app/code/include/sf_ftp.h Normal file → Executable file
View File

@ -219,5 +219,6 @@ SINT32 sf_hd_ftp_send(void);
SINT32 sf_video_ftp_send(void);
SINT32 sf_get_ftp_open_flag(void);
SINT32 sf_log_send_ftp(void);
SINT32 sf_low_power_warn_send_ftp(void);
#endif /*_SF_FTP_H_*/

View File

@ -147,6 +147,7 @@ extern "C" {
#define SF_ERROR_CODE SF_SD_ROOT"THUMB/warning.txt"
#define SF_DAILYREPORT_TXT "DailyReport.txt"
#define SF_LOG_TXT "log.txt"
#define SF_LOW_POWER_WARN_FILENAME SF_SD_ROOT"/THUMB/btalarm.txt"
#define GPIO_DIR_OUT 1
#define GPIO_DIR_IN 0

View File

@ -117,52 +117,55 @@ extern char gsmPara[GPRS_INFO_LINE_MAX];
SINT32 sf_check_max_num(void)
{
SINT32 ret = SF_SEND_ERROR_REACH_MAX_NUM;
/*UIMenuStoreInfo *pPara = sf_app_ui_para_get();
sfPara_t *sfParam = sf_ParaGet();
UIMenuStoreInfo *puiPara = sf_app_ui_para_get();
SF_PDT_PARAM_STATISTICS_S *sfParam = sf_statistics_param_get();
SF_PARA_TIME_S rTime;
printf("[%s:%d]sfParam->SendSuccCntPerDay=%d,puiPara->SendMaxNum=%d\n", __FUNCTION__, __LINE__, sfParam->SendSuccCntPerDay, puiPara->SendMaxNum);
printf("[%s:%d]sfParam->picSendMax=%d,puiPara->SendMaxNum=%d\n", __FUNCTION__, __LINE__, sfParam->picSendMax, puiPara->SendMaxNum);
//the next day or more long time,need clear the max num limit.
sf_sys_rtc_time_get(&rTime);
if((rTime.year != sfParam->PreYear) || (rTime.mon != sfParam->PreMonth) || (rTime.day != sfParam->Preday))
if((rTime.Year != sfParam->Year) || (rTime.Mon != sfParam->Mon) || (rTime.Day != sfParam->Day))
{
printf("new day, refresh counter!\n");
sfParam->EmailSendCntPerDay = 0;
sfParam->SendSuccCntPerDay = 0;
sfParam->PreYear = rTime.Year;
sfParam->PreMonth = rTime.Mon;
sfParam->Preday = rTime.Day;
sfParam->picSendMax = 0;
sfParam->subscribeSendCnt = 0;
sfParam->subscribeVideoSendCnt = 0;
sfParam->Year=rTime.Year;
sfParam->Mon=rTime.Mon;
sfParam->Day=rTime.Day;
sfParam->Hour=rTime.Hour;
}
if(puiPara->SendMaxNum == 0)
{
sfParam->PreYear = rTime.Year;
sfParam->PreMonth = rTime.Mon;
sfParam->Preday = rTime.Day;
sfParam->Year = rTime.Year;
sfParam->Mon = rTime.Mon;
sfParam->Day = rTime.Day;
ret = SF_SUCCESS;
}
else
{
if((sfParam->SendSuccCntPerDay < puiPara->SendMaxNum) || (sf_get_pic() == SF_TRUE))
if((sfParam->picSendMax < puiPara->SendMaxNum) || (sf_sms_check_send() == SF_TRUE))
{
ret = SF_SUCCESS;
}
}
if(ConfigureModeFlag)
if(SF_MCU_STARTUP_ONKEY == sf_poweron_type_get())
{
ret = SF_SUCCESS;
}
if(ret != SF_SUCCESS)
{
sprintf((char *)errMsg, "[%s:%d]Reach Max Num/Day Limit,Error Code:0x%08x", __FUNCTION__, __LINE__, ret);
SLOGE((SINT8 *)errMsg);
}*/
sprintf((char *)logStr, "[%s:%d]Reach Max Num/Day Limit,Error Code:0x%08x", __FUNCTION__, __LINE__, ret);
SLOGE((char *)logStr);
}
ret = SF_SUCCESS;
printf("[%s:%d]ret=%d\n", __FUNCTION__, __LINE__, ret);
@ -1120,6 +1123,7 @@ SINT32 sf_ftp_dailyreport_send(void)
UINT8 filePath[64] = { 0 };
int timeout = 120000;
UIMenuStoreInfo *pPara = sf_app_ui_para_get();
SF_PDT_PARAM_STATISTICS_S *pSifarPara = sf_statistics_param_get();
printf("%s:%d start\n", __FUNCTION__, __LINE__);
@ -1151,6 +1155,21 @@ SINT32 sf_ftp_dailyreport_send(void)
printf("%s:%d err ret: [0x%08X] filePath:%s\n", __FUNCTION__, __LINE__, ret, filePath);
}else {
DailyReportFtpSendSucess = 1;
pSifarPara->picSendCount = 0;
pSifarPara->sendThumbnailCount = 0;
pSifarPara->picSendSucessCount = 0;
pSifarPara->picSendTimeoutCount = 0;
pSifarPara->picSendFailCount = 0;
pSifarPara->sendThumbnailFailCount = 0;
pSifarPara->picSendTimeCount = 0;
pSifarPara->sendThumbnailTimeCount = 0;
pSifarPara->TirgNum=0;
pSifarPara->NewFlieCount=0;
pSifarPara->videoSendCount = 0;
pSifarPara->videoSendTimeCount = 0;
pSifarPara->videoSendFailCount = 0;
pSifarPara->videoSendSucessCount = 0;
pSifarPara->SendlowPowerWarnCnt = 0;
}
sf_dailyReport_set();
}
@ -1551,7 +1570,7 @@ SINT32 sf_concentrated_ftp_send(void)
{
while((sf_app_while_flag()) && (((piccount+1) <= SendFileTotal) && ((pSifarPara->picSendMax < pPara->SendMaxNum) || (pPara->SendMaxNum == 0))))
{
snprintf((char *)ftpFileName, sizeof(ftpFileName), "%s", pThumbFileCfg->stfileattr[piccount].thumbfileName);
/*snprintf((char *)ftpFileName, sizeof(ftpFileName), "%s", pThumbFileCfg->stfileattr[piccount].thumbfileName);
snprintf((char *)filePath, sizeof(filePath), "%s", pThumbFileCfg->stfileattr[piccount].thumbfilePath);
sf_set_del_flag(FALSE);
@ -1566,7 +1585,7 @@ SINT32 sf_concentrated_ftp_send(void)
{
ret1 = sf_quectel_upload_file_to_module(filePath, ftpFileName);
}
}
}*/
battery = sf_app_get_battery();
memset(cameraID, '\0', sizeof(cameraID));
memset(ftpFileName, '\0', sizeof(ftpFileName));
@ -1578,7 +1597,8 @@ SINT32 sf_concentrated_ftp_send(void)
}else{
snprintf((char *)ftpFileName, sizeof(ftpFileName), "%s%s", cameraID, pThumbFileCfg->stfileattr[piccount].thumbfileName);
}
snprintf((char *)filePath, sizeof(filePath), "UFS:/%s", pThumbFileCfg->stfileattr[piccount].thumbfileName);
//snprintf((char *)filePath, sizeof(filePath), "UFS:/%s", pThumbFileCfg->stfileattr[piccount].thumbfileName);
snprintf((char *)filePath, sizeof(filePath), "%s", pThumbFileCfg->stfileattr[piccount].thumbfilePath);
printf("%s:%d ftpFileName:%s filePath:%s\n", __FUNCTION__, __LINE__, ftpFileName, filePath);
@ -2151,6 +2171,49 @@ SINT32 sf_log_send_ftp(void)
return ret2;
}
}
SINT32 sf_low_power_warn_send_ftp(void)
{
SINT32 ret = SF_SUCCESS;
UINT8 uploadFname[64] = { 0 };
UINT8 customStr[64] = { 0 };
UINT8 filePath[64] = { 0 };
int timeout = 120000;
UIMenuStoreInfo *pPara = sf_app_ui_para_get();
SF_PDT_PARAM_STATISTICS_S *pSifarPara = sf_statistics_param_get();
MLOGD("chack\n");
if(pSifarPara->SendlowPowerWarnCnt)
{
MLOGD("SendlowPowerWarnCnt:%d",pSifarPara->SendlowPowerWarnCnt);
return SF_FAILURE;
}
if(SUCCESS != sf_create_low_power_warn_file())
{
MLOGD("err\n");
return SF_FAILURE;
}
MLOGD("start\n");
sprintf((char *)filePath, "%s", SF_LOW_POWER_WARN_FILENAME);
printf("%s:%d filePath:%s\n", __FUNCTION__, __LINE__, filePath);
sf_custom_str_get(customStr);
sprintf((char *)uploadFname, "%s-%s-btalarm.txt",pPara->ModuleImei, customStr);
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 {
pSifarPara->SendlowPowerWarnCnt++;
}
printf("[%s:%d]ret:[0x%08X]\n\n", __FUNCTION__, __LINE__, ret);
return ret;
}
#ifdef __cplusplus
#if __cplusplus
}

View File

@ -177,7 +177,7 @@ SINT32 sf_USB_net_init(void) {
if(SUCCESS != ret){
MLOGE("usb net err %d\n",ret);
}else {
for (i = 0; i < 40; i++) {
for (i = 0; i < 20; i++) {
if(strncmp(puiPara->ModuleVer, GPRS_MODULE_TYPE_EG915Q, 6) == 0){
ret = sf_check_usb0();
}else{
@ -1051,12 +1051,13 @@ static SINT32 app_file_transfer(SF_FN_PARAM_S *pfnParam) {
if (TRUE == sf_check_auto_thumb_file()) {
s32ret = sf_send_file_to_ftp(1);
}
sf_low_power_warn_send_ftp();
break;
case SF_MCU_STARTUP_BATCH_SEND:
if (TRUE == sf_check_auto_thumb_file()) {
s32ret = sf_concentrated_ftp_send();
}
sf_low_power_warn_send_ftp();
break;
case SF_MCU_STARTUP_RING:

View File

@ -936,6 +936,7 @@ UINT32 sf_create_dailyreport_file(void)
UINT8 localfea[5] = {0};/*Software fea*/
SF_PARA_TIME_S drRtcTime;
SINT16 fTemper = 0, cTemper = 0;
/*Avoid New Card*/
@ -967,7 +968,8 @@ UINT32 sf_create_dailyreport_file(void)
i=0;
sprintf(str, "%d Celsius Degree", sf_app_get_temper(1));
sf_stamp_temperature_get(&fTemper,&cTemper);
sprintf(str, "%d Celsius Degree", cTemper);
sf_sys_rtc_time_get(&drRtcTime);
@ -1043,16 +1045,16 @@ UINT32 sf_create_dailyreport_file(void)
pSifarPara->picSendCount + pSifarPara->videoSendCount);
sf_versionGet(localver,localfea);
temp = batteryType;
temp = sf_battery_type_get();
//if(CameraCmd.setPara)
// pPara = pPara_sms_saved;
if(temp == 1)
if(temp == SF_POWER_TYPE_DC)
{
sprintf(str, "DC");
}
else if(temp == 2)
else if(temp == SF_POWER_TYPE_LI_POLYER)
{
sprintf(str, "Custom");
}
@ -1259,6 +1261,100 @@ UINT32 sf_create_dailyreport_file(void)
return ret;
}
/*************************************************
Function: sf_create_low_power_warn_file
Description: create low power warn file
Input: N/A
Output: N/A
Return: SUCCESS/FAIL
Others: N/A
*************************************************/
UINT32 sf_create_low_power_warn_file(void)
{
UINT32 fd = 0, ret = FAIL;
UINT8 szTmp[50] = {0};
UINT8 str[20]= {0};
UINT16 temp = 0;
UINT8 batVal = 0;
UIMenuStoreInfo *pPara = sf_app_ui_para_get();
temp = sf_battery_type_get();
batVal = sf_battery_value_get(0);
if (batVal > 20)
{
printf("battery val > 20,no need to send\n");
return ret;
}
/*Avoid New Card*/
if (access(SF_THUMB_DIR, F_OK) == -1) {
printf("%s directory does not exist. Creating...\n", SF_THUMB_DIR);
if (mkdir(SF_THUMB_DIR, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == -1) {
//perror("mkdir() error");
} else {
printf("%s directory created.\n", SF_THUMB_DIR);
}
} else {
printf("%s directory exists.\n", SF_THUMB_DIR);
}
if(sf_file_IsExsit(SF_LOW_POWER_WARN_FILENAME) == SF_TRUE){
sf_file_remove(SF_LOW_POWER_WARN_FILENAME);
}
fd = open(SF_LOW_POWER_WARN_FILENAME, O_APPEND | O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR);
if(!fd)
{
fd = open(SF_LOW_POWER_WARN_FILENAME, O_APPEND | O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR);
}
if(fd)
{
if(temp == SF_POWER_TYPE_DC)
{
SF_SPRINTF(str, "DC");
}
else if(temp == SF_POWER_TYPE_LI_POLYER)
{
SF_SPRINTF(str, "Custom");
}
else
{
if(pPara->BatteryType == 0)
SF_SPRINTF(str, "Alkaline");
else if(pPara->BatteryType == 1)
SF_SPRINTF(str, "NI-MH");
else
SF_SPRINTF(str, "Lithium");
}
SF_SPRINTF(szTmp, "Battery:%d%%\r\nPower Type:%s\r\n", batVal, str);
printf("Low Power Warn:%s", szTmp);
ret = write(fd, szTmp, SF_STRLEN(szTmp));
if(ret <0)
{
close(fd);
sf_file_remove(SF_LOW_POWER_WARN_FILENAME);
printf("write low power warn file failed!,ret:%d\n",ret);
ret = FAIL;
}
else
{
close(fd);
ret = SUCCESS;
}
}
return ret;
}
#if 0
/*************************************************
Function: sf_is_enough_power_to_update

View File

@ -1138,7 +1138,7 @@ void sf_statistics_param_reset(SF_PDT_PARAM_STATISTICS_S *pSfPara)
pSfPara->subscribeSendCnt = 0;
pSfPara->subscribeVideoSendCnt = 0;
pSfPara->GpsSearchFailCnt = 0;/*dailyReport mode, search gps fail cnt*/
pSfPara->SendlowPowerWarnCnt = 0;
pSfPara->SmsFlag = 0;
pSfPara->SmsNumber = 0;

View File

@ -956,6 +956,7 @@ unsigned char sf_commu_parse_mcu_data(unsigned char * src, unsigned int len)
}
else if(1 == stMessageBuf.arg3) //ON->SETUP
{
sf_set_pir_statu_flag(0);
sf_set_module_sleep_flag(0);
sf_com_message_send_to_cardv(&stMessageBuf);
}

View File

@ -754,7 +754,7 @@ BOOL sf_cmd_latitude(unsigned char argc, char **argv)
{
//UINT32 value;
UIMenuStoreInfo *puiPara = sf_ui_para_get();
//printf("[%s:%d] value:%d\n", __FUNCTION__, __LINE__,value);
//printf("[%s:%d] value:%d\n", __FUNCTION__, __LINE__,value);
if(1 == argc)
{
strncpy(puiPara->Latitude, argv[0], ((sizeof(puiPara->Latitude) <= strlen(argv[0])) ? (sizeof(puiPara->Latitude)) : (strlen(argv[0]))));