ble连接状态同步到runtime,并在4G开启时开启sntp 904/2 904/head
authorSnickerSun <snickersun@163.com>
Sat, 7 Sep 2024 08:22:49 +0000 (16:22 +0800)
committerSnickerSun <snickersun@163.com>
Sat, 7 Sep 2024 08:22:49 +0000 (16:22 +0800)
code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingModel.cpp
code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp
code/sdk/open_source/openharmony/third_party/lwip/port/lwip-2.1/porting/include/lwip/lwipopts.h
code/sdk/open_source/openharmony/third_party/lwip/src/apps/sntp/sntp.c

index 0926b48..9854fed 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-02-18 09:09:13
- * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-09-05 18:32:45
+ * @LastEditors: SnickerSun snickersun@163.com
+ * @LastEditTime: 2024-09-07 15:17:50
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingModel.cpp
  */
 #include "settings/include/SettingModel.h"
 #include "classicbluetooth/include/BluetoothServiceOptionsView.h"
 #include "player/include/PlayersView.h"
 #include "player/include/PlayersModel.h"
+extern "C" {
+
+#include "custom_runtime.h"
+}
 namespace OHOS
 {
     SettingModel::SettingModel() {}
@@ -77,6 +81,12 @@ namespace OHOS
         {
             PullUpDownView::GetInstance()->UpdatePhoneStatus(status);
         }
+        //更新系统全局状态
+        if (status)
+            uapi_dev_runtime_set_ble_connect_stat(1);
+        else
+            uapi_dev_runtime_set_ble_connect_stat(0);
+
     }
 
     // 更新耳机连接状态
index 6461b4e..7f59e17 100644 (file)
@@ -1244,13 +1244,14 @@ static int udp_packet_parse(char *rx_buffer, int len)
                 restart_time_sync();
                 cat1_getsignal();
 
-                // if(sntp_enabled()==0)
-                // {
-                //     sntp_init();
-                // }else{
-                //     sntp_stop();
-                //     sntp_init();
-                // }
+                if(sntp_enabled()==0)
+                {
+                    sntp_init();
+                }
+                else{
+                    sntp_stop();
+                    sntp_init();
+                }
                 
                 if(g_msg_format_type == 0) break;  //下面指令只有新格式才支持,因此返回
                 int stateOld = get_dmp_change_mode_old();
index d8e4d7c..4a360d9 100644 (file)
 #define LWIP_HTTPC_HAVE_FILE_IO         1
 #define HTTPC_DEBUG_REQUEST             1
 
+#if 1
+#define LWIP_DHCP_MAX_NTP_SERVERS       1 
+#define SNTP_SERVER_DNS                 1
+#if SNTP_SERVER_DNS
+#define SNTP_SERVER_ADDRESS "pool.ntp.org" //"pool.ntp.org"
+#endif
+#else
 #define LWIP_DHCP_MAX_NTP_SERVERS       3 
 #define SNTP_SERVER_DNS                 1
 #if SNTP_SERVER_DNS
 #define SNTP_SERVER_ADDRESS2 "ntp1.aliyun.com" //"pool.ntp.org"
 #define SNTP_SERVER_ADDRESS3 "pool.ntp.org" //"pool.ntp.org"
 #endif
+#endif
+
+
 #define SNTP_CHECK_RESPONSE             2
 
 #define SNTP_SET_SYSTEM_TIME(sec)   uaip_sntp_set_time_utc(sec)
index 3e4ede5..5b58a15 100644 (file)
@@ -608,10 +608,14 @@ static void
 sntp_request(void *arg)
 {
   ip_addr_t sntp_server_address;
-  err_t err;
-
+  err_t err;  
   LWIP_UNUSED_ARG(arg);
-
+  if (uapi_dev_runtime_get_ble_connect_stat())  
+  {
+      LWIP_DEBUGF(SNTP_DEBUG_STATE, ("ble connected, skip sntp_request.\n"));
+      return;
+  }
+  uapi_cat1_wakeup_cat1(1);
   /* initialize SNTP server address */
 #if SNTP_SERVER_DNS
   if (sntp_servers[sntp_current_server].name) {
@@ -622,6 +626,7 @@ sntp_request(void *arg)
     if (err == ERR_INPROGRESS) {
       /* DNS request sent, wait for sntp_dns_found being called */
       LWIP_DEBUGF(SNTP_DEBUG_STATE, ("sntp_request: Waiting for server address to be resolved.\n"));
+      uapi_cat1_wakeup_cat1(0);
       return;
     } else if (err == ERR_OK) {
       sntp_servers[sntp_current_server].addr = sntp_server_address;
@@ -643,6 +648,7 @@ sntp_request(void *arg)
     sys_untimeout(sntp_try_next_server, NULL);
     sys_timeout((u32_t)SNTP_RETRY_TIMEOUT, sntp_try_next_server, NULL);
   }
+  uapi_cat1_wakeup_cat1(0);
 }
 
 /**