From 4c9527f1a92ddb6409ff2843d8b5b598ab684245 Mon Sep 17 00:00:00 2001 From: payton Date: Tue, 22 Aug 2023 17:57:37 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E5=8F=82=E6=95=B0=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E7=BA=BF=E7=A8=8B=E4=BC=91=E7=9C=A0=E5=94=A4=E9=86=92?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=9B2.gprs=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sf_app/code/include/sf_param_enum.h | 2 + .../source/sf_app/code/include/sf_system.h | 3 +- .../source/sf_app/code/source/app/sf_app.c | 9 ++- .../source/sf_app/code/source/app/sf_common.c | 7 +++ .../source/sf_app/code/source/app/sf_system.c | 53 ++++++++++++++++- .../lib/source/sifar/code/include/sf_common.h | 2 + .../sifar/code/source/common/sf_common.c | 58 +++++++++++++++++++ 7 files changed, 130 insertions(+), 4 deletions(-) diff --git a/code/application/source/sf_app/code/include/sf_param_enum.h b/code/application/source/sf_app/code/include/sf_param_enum.h index 3c2605e30..1abfaba3d 100755 --- a/code/application/source/sf_app/code/include/sf_param_enum.h +++ b/code/application/source/sf_app/code/include/sf_param_enum.h @@ -480,6 +480,8 @@ typedef enum sf_PARA_MESSAGE_TYPE_E SF_PARA_CMD_NET_STATUS = 0x1F00, SF_PARA_CMD_IR_LED_STATUS = 0x1F01, SF_PARA_CMD_BATTERY_LEVEL = 0x1F02, + SF_PARA_CMD_WAIT = 0x1F03, + SF_PARA_CMD_SIG = 0x1F04, }SF_PARA_MESSAGE_TYPE_E; typedef enum sf_WIFI_MESSAGE_TYPE_E diff --git a/code/application/source/sf_app/code/include/sf_system.h b/code/application/source/sf_app/code/include/sf_system.h index 4012b7f17..337efbac7 100755 --- a/code/application/source/sf_app/code/include/sf_system.h +++ b/code/application/source/sf_app/code/include/sf_system.h @@ -49,7 +49,8 @@ SINT32 app_preinit(void); UINT8 *sf_versionGet(UINT8 ver[],UINT8 fea[]); void sf_power_off(void); - +void sf_set_wait_shared_condition(int in); +SINT32 sf_app_para_signaling_start(void); SINT32 sf_app_para_check_start(void); SINT32 sf_app_para_check_stop(void); SINT32 sf_app_battery_start(void); diff --git a/code/application/source/sf_app/code/source/app/sf_app.c b/code/application/source/sf_app/code/source/app/sf_app.c index 889684e71..cd17175ca 100755 --- a/code/application/source/sf_app/code/source/app/sf_app.c +++ b/code/application/source/sf_app/code/source/app/sf_app.c @@ -61,6 +61,7 @@ extern pthread_mutex_t Param_mutexLock; extern pthread_mutex_t GPIO_mutexLock; +extern pthread_cond_t condition; //---------------------UIInfo Global Variables ----------------------------- UIMenuStoreInfo currentInfo = {0}; //#NT#Init the array to zero. UIMenuStoreInfo origInfo = {0}; /* backup */ @@ -154,7 +155,7 @@ int main(int argc, char *argv[]) if((!isUsb) && (SF_MCU_STARTUP_NORMAL != startup) && (SF_MCU_STARTUP_OFF != startup)/*&& (0 == isUpdate)*/) { #if SF_IQ_TEST != ENABLE - if((0 == isUpdate)) + if((0 == isUpdate) && (puiPara->GprsSwitch)) { sf_4G_usb_init(); app_RegisterNet_start(); @@ -217,7 +218,10 @@ int main(int argc, char *argv[]) } }*/ - + if((!isUsb) && (SF_MCU_STARTUP_NORMAL != startup) && (SF_MCU_STARTUP_OFF != startup) && (SF_MCU_STARTUP_ONKEY != startup)&& (!puiPara->GprsSwitch)) + { + sf_power_off(); + } //if((SF_MCU_STARTUP_ONKEY == startup) || (TRUE == autosend)) { //////////////////////////////// @@ -244,6 +248,7 @@ int main(int argc, char *argv[]) sf_share_mem_customer_deinit(); SF_MUTEX_DESTROY(Param_mutexLock); SF_MUTEX_DESTROY(GPIO_mutexLock); + pthread_cond_destroy(&condition); exit(0); printf("********************sf app end***********************\n"); diff --git a/code/application/source/sf_app/code/source/app/sf_common.c b/code/application/source/sf_app/code/source/app/sf_common.c index b60b6c69d..4b2a15398 100755 --- a/code/application/source/sf_app/code/source/app/sf_common.c +++ b/code/application/source/sf_app/code/source/app/sf_common.c @@ -790,6 +790,13 @@ static SINT32 sf_app_proccess_cmd_para_update(SF_MESSAGE_BUF_S *pMessageBuf) case SF_PARA_CMD_IR_LED_STATUS: IsNightLedOn = pMessageBuf->arg2; break; + case SF_PARA_CMD_WAIT: + sf_set_wait_shared_condition(0); + break; + case SF_PARA_CMD_SIG: + sf_app_para_signaling_start(); + break; + default: break; } diff --git a/code/application/source/sf_app/code/source/app/sf_system.c b/code/application/source/sf_app/code/source/app/sf_system.c index 1daa1b977..4fe41cd71 100755 --- a/code/application/source/sf_app/code/source/app/sf_system.c +++ b/code/application/source/sf_app/code/source/app/sf_system.c @@ -123,7 +123,11 @@ SF_THREAD_S McuParaTskCfg = .IsRun = 0, .TskId = -1, }; - +SF_THREAD_S WaiParaTskCfg = +{ + .IsRun = 0, + .TskId = -1, +}; SINT8 debugFlag = 0; void app_poweroff_time_clear(void) @@ -934,6 +938,48 @@ void sf_power_off(void) sf_com_message_send_to_cardv(&stMessageBuf); printf("[%s:%d] e\n", __FUNCTION__, __LINE__); } +pthread_cond_t condition; +extern pthread_mutex_t Param_mutexLock; +int shared_condition = 1; + +void* sf_para_signaling_thread(void* arg) +{ + pthread_mutex_lock(&Param_mutexLock); + + // Modify the status that meets the conditions + shared_condition = 1; + + // Wake up waiting threads + pthread_cond_signal(&condition); + + pthread_mutex_unlock(&Param_mutexLock); + WaiParaTskCfg.IsRun = 0; + pthread_exit(NULL); +} + +SINT32 sf_app_para_signaling_start(void) +{ + SINT32 ret = SF_FAILURE; + if(WaiParaTskCfg.IsRun) + { + SLOGE("thread has already run !!!\n"); + return SF_FAILURE; + } + SLOGI("thread run\n"); + ret = pthread_create(&WaiParaTskCfg.TskId, NULL, sf_para_signaling_thread, NULL); + if(ret != SF_SUCCESS) + { + MLOGD("thread creat fail!\n"); + return ret; + } + return SF_SUCCESS; +} + +void sf_set_wait_shared_condition(int in) +{ + shared_condition = in; + SLOGI("shared_condition:%d\n", shared_condition); +} void* sf_app_para_check_thread(void *arg) { @@ -941,6 +987,10 @@ void* sf_app_para_check_thread(void *arg) ParaTskCfg.IsRun = 1; while(ParaTskCfg.IsRun) { + while (shared_condition == 0) { + pthread_cond_wait(&condition, &Param_mutexLock); + } + if(TRUE == sf_get_para_check_flag()){ MLOGI("menu info is changed\n"); sf_share_mem_customer_down(1); @@ -960,6 +1010,7 @@ SINT32 sf_app_para_check_start(void) SLOGE("thread has already run !!!\n"); return SF_FAILURE; } + pthread_cond_init(&condition, NULL); ret = pthread_create(&ParaTskCfg.TskId, NULL, sf_app_para_check_thread, NULL); if(ret != SF_SUCCESS) { diff --git a/code/lib/source/sifar/code/include/sf_common.h b/code/lib/source/sifar/code/include/sf_common.h index ac81eaa4c..1525d0273 100755 --- a/code/lib/source/sifar/code/include/sf_common.h +++ b/code/lib/source/sifar/code/include/sf_common.h @@ -120,4 +120,6 @@ BOOL sf_cmd_ftp(unsigned char argc, char **argv); BOOL sf_cmd_ftps(unsigned char argc, char **argv); UINT32 sf_cardv_cap_start(void); UINT32 sf_cardv_hd_cap_start(void); +void sf_cardv_set_wait_shared_condition(int in); +int sf_cardv_para_signaling_start(void); #endif diff --git a/code/lib/source/sifar/code/source/common/sf_common.c b/code/lib/source/sifar/code/source/common/sf_common.c index 28e117624..54dccb19e 100755 --- a/code/lib/source/sifar/code/source/common/sf_common.c +++ b/code/lib/source/sifar/code/source/common/sf_common.c @@ -83,6 +83,10 @@ static UINT8 batteryVal = 0; static UINT8 batteryType = 0; static SINT16 fTemper = 0; static SINT16 cTemper = 0; +static pthread_cond_t condition; +static pthread_mutex_t Param_mutexLock; +static int shared_condition = 1; + static SF_THREAD_S UpgradeTskParam = { .IsRun = 0, @@ -109,6 +113,11 @@ static SF_THREAD_S HdCapTskCfg = .IsRun = 0, .TskId = -1, }; +static SF_THREAD_S WaiParaTskCfg = +{ + .IsRun = 0, + .TskId = -1, +}; int sf_pir_statu_read(void) { static UINT8 state = 0; @@ -388,6 +397,7 @@ BOOL sf_cmd_img_size(unsigned char argc, char **argv) printf("[%s:%d] value:%d\n", __FUNCTION__, __LINE__,value); if(value < PHOTO_SIZE_ID_MAX){ SysSetFlag(FL_PHOTO_SIZE, value); + Photo_SetUserIndex(PHOTO_USR_SIZE, puiPara->ImgSize); puiPara->ImgSize = value; Save_MenuInfo(); } @@ -1595,6 +1605,12 @@ static SINT32 sf_cardv_proccess_cmd_para_update(SF_MESSAGE_BUF_S *pMessageBuf) case SF_PARA_CMD_NET_STATUS: NetWorkFlag = pMessageBuf->arg2; break; + case SF_PARA_CMD_WAIT: + sf_cardv_set_wait_shared_condition(0); + break; + case SF_PARA_CMD_SIG: + sf_cardv_para_signaling_start(); + break; default: break; } @@ -2010,6 +2026,47 @@ void sf_do_upgrade_thread(void) } } + +void* sf_cardv_para_signaling_thread(void* arg) +{ + pthread_mutex_lock(&Param_mutexLock); + + // Modify the status that meets the conditions + shared_condition = 1; + + // Wake up waiting threads + pthread_cond_signal(&condition); + + pthread_mutex_unlock(&Param_mutexLock); + WaiParaTskCfg.IsRun = 0; + pthread_exit(NULL); +} + +int sf_cardv_para_signaling_start(void) +{ + int ret = SF_FAILURE; + if(WaiParaTskCfg.IsRun) + { + SLOGE("thread has already run !!!\n"); + return SF_FAILURE; + } + SLOGI("thread run\n"); + ret = pthread_create(&WaiParaTskCfg.TskId, NULL, sf_cardv_para_signaling_thread, NULL); + if(ret != SF_SUCCESS) + { + MLOGD("thread creat fail!\n"); + return ret; + } + return SF_SUCCESS; +} + +void sf_cardv_set_wait_shared_condition(int in) +{ + shared_condition = in; + SLOGI("shared_condition:%d\n", shared_condition); +} + + void* sf_cardv_para_check_thread(void *arg) { SLOGI("thread run\n"); @@ -2038,6 +2095,7 @@ UINT32 sf_cardv_para_check_start(void) SLOGE("thread has already run !!!\n"); return 1; } + pthread_cond_init(&condition, NULL); ret = pthread_create(&ParaTskCfg.TskId, NULL, sf_cardv_para_check_thread, NULL); if(ret != SF_SUCCESS) {