From e6d09b3539b01158c76ea717df1b4782d37ce038 Mon Sep 17 00:00:00 2001 From: penglei <1624952103@qq.com> Date: Fri, 19 Jul 2024 14:57:12 +0800 Subject: [PATCH] =?utf8?q?=E6=B7=BB=E5=8A=A0tcp=E7=BA=BF=E7=A8=8B=E6=8E=A7?= =?utf8?q?=E5=88=B6=EF=BC=8C=E9=99=8D=E4=BD=8E=E5=BE=85=E6=9C=BA=E5=8A=9F?= =?utf8?q?=E8=80=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../src/NetworkAndCallPresenter.cpp | 8 ++-- .../factorytest_protocol.c | 17 +++++-- .../config/target_config/brandy/config.py | 1 + .../drivers/peripheral/utils/custom_utils.c | 46 ++++++++++++++++--- .../drivers/peripheral/utils/custom_utils.h | 3 +- .../third_party/lwip/src/api/tcpip.c | 23 +++++++++- .../third_party/lwip/src/include/lwip/tcpip.h | 2 +- 7 files changed, 82 insertions(+), 18 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/networkandcall/src/NetworkAndCallPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/networkandcall/src/NetworkAndCallPresenter.cpp index de9e89fd0..f456ea7a3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/networkandcall/src/NetworkAndCallPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/networkandcall/src/NetworkAndCallPresenter.cpp @@ -1,8 +1,8 @@ /* * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-23 09:59:32 - * @LastEditors: SnickerSun snickersun@163.com - * @LastEditTime: 2024-05-28 15:07:45 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2024-07-19 14:53:51 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/networkandcall/src/NetworkAndCallPresenter.cpp */ #include "AppViewIDs.h" @@ -91,7 +91,7 @@ namespace OHOS } else if (it->second == "4GCapability") { - power_on_cat1(); + uapi_set4GCapability(true); ConfigModel::GetInstance()->SetCat1_4Gability(uapi_cat1_get_power_stat()); } } @@ -104,7 +104,7 @@ namespace OHOS } else if (it->second == "4GCapability") { - power_off_cat1(); + uapi_set4GCapability(false); ConfigModel::GetInstance()->SetCat1_4Gability(uapi_cat1_get_power_stat()); } } diff --git a/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c b/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c index 102de9603..fc1c54a28 100644 --- a/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c +++ b/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2024-06-17 14:31:08 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2024-07-11 17:35:34 + * @LastEditTime: 2024-07-19 14:21:43 * @FilePath: /FD230/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c * @Description: * @@ -1144,6 +1144,15 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint 0x07, (uint8_t *)chipinfo, strlen(chipinfo)); + } else if(testitem == 0x08) + { + //获取cywee active + uint8_t send_data = uapi_get_cywee_active_state(); + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, + BLE_TEST_CMD_SOFT_TEST_SUB_MODE_ACC, + 0x08, + &send_data, + 1); } break; @@ -1448,8 +1457,8 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint //打开cat1 uint8_t send_data = 0x00; - power_on_cat1(); - + uapi_set4GCapability(true); + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CAT1, 0x01, @@ -1461,7 +1470,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint //关闭cat1 uint8_t send_data = 0x00; - power_off_cat1(); + uapi_set4GCapability(false); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CAT1, diff --git a/code/sdk/build/config/target_config/brandy/config.py b/code/sdk/build/config/target_config/brandy/config.py index 3cc974f4e..65fb3d409 100755 --- a/code/sdk/build/config/target_config/brandy/config.py +++ b/code/sdk/build/config/target_config/brandy/config.py @@ -140,6 +140,7 @@ target = { 'SUPPORT_BLE_SERVICE', 'FD230', 'CYWEE_SPORT', + 'SUPPORT_TCPIP', 'SUPPORT_TELECOM_DMP', # 'SUPPORT_CHINA_MOBILE_DMP', 'SUPPORT_HID_SERVICE', diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index 1a6769c14..dd5d7aee5 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -25,6 +25,10 @@ #include "los_base.h" // #include "config/include/ConfigModelC.h" +#ifdef SUPPORT_TCPIP +#include "lwip/tcpip.h" +#endif + #ifdef FD230 #include "soundandvibration/include/SoundAndVibrationVolumeSettingC.h" #include "networkandcall/include/NetworkAndCallC.h" @@ -80,6 +84,18 @@ errcode_t uapi_terminate_thread(void* thread_id) return ret; } +errcode_t uapi_suspend_thread(void* thread_id) +{ + osStatus_t ret = osThreadSuspend((osThreadId_t)thread_id); + return ret; +} + +errcode_t uapi_resume_thread(void* thread_id) +{ + osStatus_t ret = osThreadResume((osThreadId_t)thread_id); + return ret; +} + uint32_t zh_get_sn(uint8_t *buf_sn, uint32_t *len_sn) { @@ -309,12 +325,10 @@ void startup_post_init_task(void) if ( cm_poweron_cat1_on_bootup_flag() ) { PRINT("PowerOn Cat1 !\r\n"); - - power_on_cat1(); + uapi_set4GCapability(true); }else{ PRINT("PowerOff Cat1 !\r\n"); - - power_off_cat1(); + uapi_set4GCapability(false); } uapi_gei_btmac_and_chipinfo(); } @@ -1053,13 +1067,32 @@ void power_off_cat1(void) //设置4G能力开关是否开启 void uapi_set4GCapability(bool isopen) { + errcode_t ret = 0; + void *tcp_thread_id = NULL; + if(isopen) { power_on_cat1(); + #ifdef SUPPORT_TCPIP + tcp_thread_id = tcp_get_thread_id(); + ret = uapi_resume_thread(tcp_thread_id); + if(ret != ERRCODE_SUCC) + PRINT("tcpip_thread_resume failed ret : %d \n",ret); + else + PRINT("tcpip_thread_resume succed\n"); + #endif } else { power_off_cat1(); + #ifdef SUPPORT_TCPIP + tcp_thread_id = tcp_get_thread_id(); + ret = uapi_suspend_thread(tcp_thread_id); + if(ret != ERRCODE_SUCC) + PRINT("tcpip_thread_suspend failed ret : %d \n",ret); + else + PRINT("tcpip_thread_suspend succed\n"); + #endif } } @@ -2144,8 +2177,7 @@ void uapi_enter_power_saving_mode(void) stop_custom_ble_service(); //关闭cat1 - power_off_cat1(); - + uapi_set4GCapability(false); //停止心率周期检测 //进入normal模式 @@ -2161,7 +2193,7 @@ void uapi_exit_power_saving_mode(void) start_custom_ble_service(); //打开cat1 - power_on_cat1(); + uapi_set4GCapability(true); //开启心率周期检测 } diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.h b/code/sdk/drivers/peripheral/utils/custom_utils.h index 86f1b74da..53c7e5929 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.h +++ b/code/sdk/drivers/peripheral/utils/custom_utils.h @@ -125,7 +125,8 @@ errcode_t init_btaddr_btname(void); errcode_t uapi_create_osThread_custom(app_task_definition_t *task_cfg); errcode_t uapi_terminate_thread(void* thread_id); - +errcode_t uapi_suspend_thread(void* thread_id); +errcode_t uapi_resume_thread(void* thread_id); errcode_t uapi_get_buildversion(uint8_t *para, uint32_t para_len); //获取固件版本号 diff --git a/code/sdk/open_source/openharmony/third_party/lwip/src/api/tcpip.c b/code/sdk/open_source/openharmony/third_party/lwip/src/api/tcpip.c index a7e312a27..ce3b64830 100644 --- a/code/sdk/open_source/openharmony/third_party/lwip/src/api/tcpip.c +++ b/code/sdk/open_source/openharmony/third_party/lwip/src/api/tcpip.c @@ -49,6 +49,7 @@ #include "lwip/pbuf.h" #include "lwip/etharp.h" #include "netif/ethernet.h" +#include "custom_utils.h" #define TCPIP_MSG_VAR_REF(name) API_VAR_REF(name) #define TCPIP_MSG_VAR_DECLARE(name) API_VAR_DECLARE(struct tcpip_msg, name) @@ -65,6 +66,9 @@ static sys_mbox_t tcpip_mbox; sys_mutex_t lock_tcpip_core; #endif /* LWIP_TCPIP_CORE_LOCKING */ + +static app_task_definition_t taskcfg={0}; + static void tcpip_thread_handle_msg(struct tcpip_msg *msg); #if !LWIP_TIMERS @@ -614,7 +618,19 @@ tcpip_init(tcpip_init_done_fn initfunc, void *arg) } #endif /* LWIP_TCPIP_CORE_LOCKING */ - sys_thread_new(TCPIP_THREAD_NAME, tcpip_thread, NULL, TCPIP_THREAD_STACKSIZE, TCPIP_THREAD_PRIO); + taskcfg.create_queue_handle = NULL; + taskcfg.attr.name="TCPIP_THREAD_NAME"; + taskcfg.attr.priority = osPriorityBelowNormal; + taskcfg.attr.stack_size = TCPIP_THREAD_STACKSIZE; + taskcfg.func = tcpip_thread; + taskcfg.use_mem = USE_EXTEND_MEM; + + errcode_t ret=uapi_create_osThread_custom(&taskcfg); + if(ret != ERRCODE_SUCC) + printf("create tcpip_thread failed %d\n",ret); + else + printf("create tcpip_thread succed\n"); + //sys_thread_new(TCPIP_THREAD_NAME, tcpip_thread, NULL, TCPIP_THREAD_STACKSIZE, TCPIP_THREAD_PRIO); } /** @@ -655,4 +671,9 @@ mem_free_callback(void *m) return tcpip_try_callback(mem_free, m); } +void* tcp_get_thread_id(void) +{ + return taskcfg.task_handle; +} + #endif /* !NO_SYS */ diff --git a/code/sdk/open_source/openharmony/third_party/lwip/src/include/lwip/tcpip.h b/code/sdk/open_source/openharmony/third_party/lwip/src/include/lwip/tcpip.h index 0b8880a9f..27300094d 100644 --- a/code/sdk/open_source/openharmony/third_party/lwip/src/include/lwip/tcpip.h +++ b/code/sdk/open_source/openharmony/third_party/lwip/src/include/lwip/tcpip.h @@ -94,7 +94,7 @@ err_t tcpip_callbackmsg_trycallback_fromisr(struct tcpip_callback_msg* msg); /* free pbufs or heap memory from another context without blocking */ err_t pbuf_free_callback(struct pbuf *p); err_t mem_free_callback(void *m); - +void* tcp_get_thread_id(void); #if LWIP_TCPIP_TIMEOUT && LWIP_TIMERS err_t tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg); err_t tcpip_untimeout(sys_timeout_handler h, void *arg); -- 2.17.1