custom runtime 去掉直接访问变量的方法,采用函数设置获取。 281/1 281/head 282/target/1 283/target/1
authorSnickerSun <snickersun@163.com>
Fri, 14 Jun 2024 02:53:48 +0000 (10:53 +0800)
committerSnickerSun <snickersun@163.com>
Fri, 14 Jun 2024 02:53:48 +0000 (10:53 +0800)
优化Cat1解析,版本6以上的信号解析增加 网络类型和是否连接选项。

code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp
code/sdk/application/wearable/fd230app/nativeui/producttest/src/testcat1.cpp
code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c
code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c
code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp
code/sdk/drivers/peripheral/utils/custom_runtime.c
code/sdk/drivers/peripheral/utils/custom_runtime.h

index a510162..9766f4e 100644 (file)
@@ -675,8 +675,7 @@ namespace OHOS
     int PullUpDownView::GetSignalStrength(void)
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::GetSignalStrength");
-        runtime_status_t *g_runtime = get_device_runtime_status();
-        int SignalStrength = g_runtime->cat1_runtime.signal; // 信号强度
+        int SignalStrength = uapi_dev_runtime_get_cat1_signal(); // 信号强度
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SignalStrength = %d", SignalStrength);
 
         return SignalStrength;
index b14c8c6..43fc7fc 100644 (file)
@@ -183,18 +183,17 @@ namespace OHOS
     {
         cat1_getsignal();
         cat1_getver();
-        runtime_status_t *runtime = get_device_runtime_status();
         OHOS::testcat1View *pview = OHOS::testcat1View::GetInstance();
         OHOS::testcat1View::cat1_Ver msgver={0};
    
-        msgver.cat1appver = runtime->cat1_runtime.pyVer;
-        msgver.modem_version = runtime->cat1_runtime.modemVer;
+        msgver.cat1appver = uapi_dev_runtime_get_cat1_pyver();
+        msgver.modem_version = uapi_dev_runtime_get_cat1_modemver();
 
         OHOS::testcat1View::cat1_msg msg={0};
-        msg.imei = runtime->cat1_runtime.imei;
-        msg.sim = runtime->cat1_runtime.sim;
-        msg.signal = runtime->cat1_runtime.signal;
-        msg.oper = runtime->cat1_runtime.opera;
+        msg.imei = uapi_dev_runtime_get_cat1_imei();
+        msg.sim = uapi_dev_runtime_get_cat1_simstat();
+        msg.signal = uapi_dev_runtime_get_cat1_signal();
+        msg.oper = uapi_dev_runtime_get_cat1_operator();
    
         if(pview !=NULL)
         {
index 1106eea..c12a974 100644 (file)
@@ -5284,9 +5284,7 @@ errcode_t decode_single_dial_info(ble_read_data *buffer_handle)
     memcpy_s(filename,dialinfo.file_name_len,data+sizeof(msg_recv_single_dial_info_t),dialinfo.file_name_len);\r
     filename[dialinfo.file_name_len] ='\0';\r
     //在runtime中备份一个安装文件名。\r
-    memset_s(get_device_runtime_status()->current_dial_name,sizeof(get_device_runtime_status()->current_dial_name),0,sizeof(get_device_runtime_status()->current_dial_name));\r
-    memcpy_s(get_device_runtime_status()->current_dial_name,sizeof(get_device_runtime_status()->current_dial_name),filename,dialinfo.file_name_len);\r
-\r
+    uapi_dev_runtime_set_dialname(filename);\r
     buffer_handle->file_recv_stat.file_name = filename;\r
     buffer_handle->file_recv_stat.file_size = file_size;\r
     buffer_handle->file_recv_stat.file_type = 3;//表盘\r
@@ -5308,8 +5306,8 @@ errcode_t decode_single_dial_info(ble_read_data *buffer_handle)
 }\r
 static errcode_t install_dial(void)\r
 {\r
-    printf("install %s\n",get_device_runtime_status()->current_dial_name);\r
-    char *lzmapkgname =(char*)(get_device_runtime_status()->current_dial_name);\r
+    char *lzmapkgname =uapi_dev_runtime_get_dialname();\r
+    printf("install %s\n",lzmapkgname);\r
     char *lzmaindex = strstr(lzmapkgname,".lzma");\r
     if (lzmaindex != NULL)\r
     {\r
@@ -5318,7 +5316,7 @@ static errcode_t install_dial(void)
         printf("dial_basenamelen %d\n",dial_basenamelen);\r
         if (dial_basenamelen>0 )\r
         {\r
-            memcpy_s(dial_basename,sizeof(dial_basename),get_device_runtime_status()->current_dial_name,dial_basenamelen);\r
+            memcpy_s(dial_basename,sizeof(dial_basename),lzmapkgname,dial_basenamelen);\r
         }\r
         else{\r
             return ERRCODE_FAIL;\r
index 27e5381..ce293ef 100644 (file)
@@ -1514,8 +1514,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
 \r
                 cat1_getsignal();\r
                 msleep(1000);\r
-                runtime_status_t * runtime = get_device_runtime_status();\r
-                send_data[1]=runtime->cat1_runtime.sim;\r
+                send_data[1]=uapi_dev_runtime_get_cat1_simstat();\r
                 factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
                         BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CAT1,\r
                         0x03,\r
@@ -1528,8 +1527,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
 \r
                 cat1_getsignal();\r
                 msleep(1000);\r
-                runtime_status_t * runtime = get_device_runtime_status();\r
-                send_data[1]=runtime->cat1_runtime.signal;\r
+                send_data[1]=uapi_dev_runtime_get_cat1_signal();\r
 \r
                 factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
                         BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CAT1,\r
@@ -1544,15 +1542,14 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
                 cat1_getsignal();\r
                 msleep(1000);\r
  \r
-                runtime_status_t * runtime = get_device_runtime_status();\r
              \r
-                PRINT("send_buf : %s \r\n",runtime->cat1_runtime.opera);\r
+                PRINT("send_buf : %s \r\n",uapi_dev_runtime_get_cat1_operator());\r
                 \r
                 factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
                         BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CAT1,\r
                         0x05,\r
-                        (uint8_t *)runtime->cat1_runtime.opera,\r
-                        strlen(runtime->cat1_runtime.opera));\r
+                        (uint8_t *)uapi_dev_runtime_get_cat1_operator(),\r
+                        strlen(uapi_dev_runtime_get_cat1_operator()));\r
             } else if(testitem == 0x06)\r
             {\r
                 //拨打电话\r
index 05f691c..d40b479 100644 (file)
@@ -360,7 +360,6 @@ static int decodeSMS(char* msg)
 {
 // FE150117ref:0@total_num:1@seq:1@data:0100240D91688139687502F200084250926172722316662F6211670B53CB621153EF80FD9700898198847EA6
     
-    runtime_status_t * runtime = get_device_runtime_status();
     int msglen = strlen(msg)+1;
     if (msglen < 25)
     {
@@ -412,7 +411,6 @@ static int decodeVersion(char* msg)
 {
 
     int update = 0;
-    runtime_status_t * runtime = get_device_runtime_status();
     
     if (strlen(msg) < 50)
     {
@@ -448,11 +446,10 @@ static int decodeVersion(char* msg)
         {
             char* ptmp=s+6;
             PRINT("pyVer= %s\r\n",ptmp);
-            if ( strcmp(runtime->cat1_runtime.pyVer,ptmp)!=0 )
+            if ( strcmp(uapi_dev_runtime_get_cat1_pyver(),ptmp)!=0 )
             {
                 update++;
-                memset(runtime->cat1_runtime.pyVer,0,sizeof(runtime->cat1_runtime.pyVer));
-                strcpy_s(runtime->cat1_runtime.pyVer,sizeof(runtime->cat1_runtime.pyVer),ptmp);
+                uapi_dev_runtime_set_cat1_pyver(ptmp);
             }
             if (strncmp(ptmp,"PY_SRV_V",8)==0 && strlen(ptmp)>8)
             {
@@ -464,30 +461,27 @@ static int decodeVersion(char* msg)
         {
             char* ptmp=s+9;
             PRINT("modemVer= %s\r\n",ptmp);
-            if (strcmp(runtime->cat1_runtime.modemVer,ptmp) != 0)
+            if (strcmp(uapi_dev_runtime_get_cat1_modemver(),ptmp) != 0)
             {
                 update++;
-                memset(runtime->cat1_runtime.modemVer,0,sizeof(runtime->cat1_runtime.modemVer));
-                strcpy_s(runtime->cat1_runtime.modemVer,sizeof(runtime->cat1_runtime.modemVer),ptmp);
+                uapi_dev_runtime_set_cat1_modemver(ptmp);
             }
         } else if (strncmp(s,"PY_",3) == 0 )
         {
             PRINT("pyVer = %s\r\n",s);
-            if ( strcmp(runtime->cat1_runtime.pyVer,s)!=0 )
+            if ( strcmp(uapi_dev_runtime_get_cat1_pyver(),s)!=0 )
             {
                 update++;
-                memset(runtime->cat1_runtime.pyVer,0,sizeof(runtime->cat1_runtime.pyVer));
-                strcpy_s(runtime->cat1_runtime.pyVer,sizeof(runtime->cat1_runtime.pyVer),s);
+                uapi_dev_runtime_set_cat1_pyver(s);
             }
 
         }else if (strncmp(s,"EG810M",6) == 0 )
         {
-            PRINT("modemVer = %s\r\n",s);
-            if (strcmp(runtime->cat1_runtime.modemVer,s) != 0)
+            PRINT("modemVer = %s\r\n",s);            
+            if (strcmp(uapi_dev_runtime_get_cat1_modemver(),s) != 0)
             {
                 update++;
-                memset(runtime->cat1_runtime.modemVer,0,sizeof(runtime->cat1_runtime.modemVer));
-                strcpy_s(runtime->cat1_runtime.modemVer,sizeof(runtime->cat1_runtime.modemVer),s);
+                uapi_dev_runtime_set_cat1_modemver(s);
             }
         }
     }
@@ -505,7 +499,6 @@ static int decodeVersion(char* msg)
 static int decodeNetStat(char* msg)
 {
     int update = 0;
-    runtime_status_t * runtime = get_device_runtime_status();
     if (strlen(msg) < 50)
     {
         PRINT("msg len is too short !\r\n");
@@ -540,12 +533,11 @@ static int decodeNetStat(char* msg)
         if(strncmp(s,"imei:",5) == 0)
         {
             ppbuf = s+5;
-            PRINT("=== imei = %s\r\n",ppbuf);
-            if ( strcmp(runtime->cat1_runtime.imei,ppbuf)!=0 )
+            PRINT("=== imei = %s\r\n",ppbuf);            
+            if ( strcmp(uapi_dev_runtime_get_cat1_imei(),ppbuf)!=0 )
             {
                 update++;
-                memset(runtime->cat1_runtime.imei,0,sizeof(runtime->cat1_runtime.imei));
-                strcpy_s(runtime->cat1_runtime.imei,sizeof(runtime->cat1_runtime.imei),ppbuf);
+                uapi_dev_runtime_set_cat1_imei(ppbuf);
             }   
             continue;
         }else if(strncmp(s,"sim:",4) == 0)
@@ -553,10 +545,10 @@ static int decodeNetStat(char* msg)
             ppbuf=s+4;
             int simstat = atoi(ppbuf);
             PRINT("=== sim = %d\r\n",simstat);
-            if ( runtime->cat1_runtime.sim != simstat)
+            if ( uapi_dev_runtime_get_cat1_simstat() != simstat)
             {
                 update++;
-                runtime->cat1_runtime.sim = simstat;
+                uapi_dev_runtime_set_cat1_simstat(simstat);
             }  
             continue;
         }else if(strncmp(s,"oper:",5) == 0)
@@ -568,11 +560,10 @@ static int decodeNetStat(char* msg)
                 ppbuf=s+5;
         
             PRINT("=== opera = %s\r\n",ppbuf);
-            if ( strcmp(runtime->cat1_runtime.opera,ppbuf)!=0 )
+            if ( strcmp(uapi_dev_runtime_get_cat1_operator(),ppbuf)!=0 )
             {
                 update++;
-                memset(runtime->cat1_runtime.opera,0,sizeof(runtime->cat1_runtime.opera));
-                strcpy_s(runtime->cat1_runtime.opera,sizeof(runtime->cat1_runtime.opera),ppbuf);
+                uapi_dev_runtime_set_cat1_operator(ppbuf);
             } 
 
             continue;
@@ -581,15 +572,15 @@ static int decodeNetStat(char* msg)
             ppbuf=s+7;
             int signals = atoi(ppbuf);
             PRINT("=== signal = %d\r\n",signals);
-            if ( runtime->cat1_runtime.signal != signals)
+            if ( uapi_dev_runtime_get_cat1_signal() != signals)
             {
                 update++;
-                runtime->cat1_runtime.signal = signals;
+                uapi_dev_runtime_set_cat1_signal(signals);
             }  
             continue;
         }  
 
-        if(g_py_ver == 6 && strncmp(s,"net:",4) == 0)
+        if(g_py_ver >= 6 && strncmp(s,"net:",4) == 0)
         {
             ppbuf = s+4;
             /**
@@ -597,8 +588,8 @@ static int decodeNetStat(char* msg)
              * voice_stat 语音网络状态:1,注冊本地网络,5注册漫游网络,其他不通, 
              * voice_rat, 语音网络类型: 0      GSM ;1        GSM COMPACT ;2        UTRAN ;3      GSM wEGPRS ; 4        UTRAN wHSDPA ;5       UTRAN wHSUPA ;
              *              6  UTRAN wHSDPA HSUPA ;7 E_UTRAN ;8    UTRAN HSPAP ;9        E_UTRAN_CA ;10        NONE
-             * data_stat, 数据网络状态
-             * data_rat 数据网络类型
+             * data_stat, 数据网络状态 同上
+             * data_rat 数据网络类型 同上
              * 
              */
             memset(netstat,0,sizeof(netstat));
@@ -608,19 +599,32 @@ static int decodeNetStat(char* msg)
     }
 
 
-    if(g_py_ver == 6 )
+    if(g_py_ver >= 6 )
     {
         int idx=0;
         pchStrTmpIn=NULL;
+        // PRINT("netstat %s\n",netstat);
         for (s = strtok_r(netstat,",",&pchStrTmpIn); s!=NULL;s=strtok_r(NULL,",",&pchStrTmpIn))
         {
+            // PRINT("idx %d, value %s\n",idx,s);
             switch(idx)
             {
                 case 2:
-                    runtime->cat1_runtime.network_on = atoi(s) ;
+                    {
+                        int networkon = atoi(s) ;
+                        PRINT("=== networkon = %d , %s \n",networkon,networkon==1?"connected":networkon==5?"roaming":"unkown");
+                        uapi_dev_runtime_set_cat1_networkstat(networkon);
+                        
+                    }   
                     break;
                 case 3:
-                    runtime->cat1_runtime.cat1_network_type  = atoi(s);
+                    {
+                        int network_type  = atoi(s);
+                        PRINT("=== network_type = %d , %s\n",network_type,
+                        network_type==0?"GSM":network_type==1?"GSM COMPACT":network_type==2?"UTRAN":network_type==3?"GSM wEGPRS":network_type==4?"UTRAN wHSDPA":network_type==5?"UTRAN wHSUPA":network_type==6?"UTRAN wHSDPA HSUPA":network_type==7?"E_UTRAN":network_type==8?"UTRAN HSPAP":network_type==9?"E_UTRAN_CA":"NONE"
+                        );
+                        uapi_dev_runtime_set_cat1_networktype(network_type);
+                    }                    
                     break;
                 case 0:
                 case 1:
@@ -732,9 +736,8 @@ int cat1_handle_networ_msg(char *msg)
 {
     // WEARABLE_LOGI(WEARABLE_LOG_MODULE_MAIN_SERVICE,"cat1 cat1_handle_networ_msg %s\n",msg->buffer);
     if(decodeNetStat(msg) == 0)
-    {
-        runtime_status_t * runtime = get_device_runtime_status();
-        OHOS::ConfigModel::GetInstance()->Setimei(runtime->cat1_runtime.imei);
+    {        
+        OHOS::ConfigModel::GetInstance()->Setimei(uapi_dev_runtime_get_cat1_imei());
         cat1_msg_event_sendmsg_toUI("netupdate");
     }
     //显示UI 信号
@@ -753,9 +756,9 @@ int cat1_handle_version_msg(char *msg)
     
     if(decodeVersion(msg) == 0)
     {
-        runtime_status_t * runtime = get_device_runtime_status();
-        OHOS::ConfigModel::GetInstance()->SetpyVer(runtime->cat1_runtime.pyVer);
-        OHOS::ConfigModel::GetInstance()->SetmoderVer(runtime->cat1_runtime.modemVer);
+        
+        OHOS::ConfigModel::GetInstance()->SetpyVer(uapi_dev_runtime_get_cat1_pyver());
+        OHOS::ConfigModel::GetInstance()->SetmoderVer(uapi_dev_runtime_get_cat1_modemver());
         cat1_msg_event_sendmsg_toUI("verupdate"); 
     }
     
@@ -838,20 +841,19 @@ static void time_sync_func(void)
 {
     
     // PRINT("time_sync_func\n");
-
-    runtime_status_t * runtime = get_device_runtime_status();
+    
     if (uapi_cat1_get_power_stat() == false )
     {
         // PRINT("cat1 power off reset cat1_runtime \n");
         //开关是关的 则cat1所有状态清空
-         runtime->cat1_runtime.cat1_powerOn = 0;
-         runtime->cat1_runtime.network_on = 0;
-         runtime->cat1_runtime.signal = 99;
-         runtime->cat1_runtime.sim = 0;
-         runtime->cat1_runtime.volte = 0;
-         return ;
+        uapi_dev_runtime_set_cat1_powerstat(0);
+        uapi_dev_runtime_set_cat1_networkstat(0);
+        uapi_dev_runtime_set_cat1_signal(0);
+        uapi_dev_runtime_set_cat1_simstat(0);
+
+        return ;
     }else{
-         runtime->cat1_runtime.cat1_powerOn = 1;
+        uapi_dev_runtime_set_cat1_powerstat(1);
 
     }
 
index cd3ce80..30f15cb 100644 (file)
 #include "custom_runtime.h"
 #include "chip_system_time.h"
+
+
+
+typedef struct 
+{
+    uint8_t bt_powerOn;
+    uint8_t bt_ble_connectstat;
+    uint8_t bt_br_connectstat;
+    uint8_t bt_earphone_connectstat;
+    uint8_t android_app_connected;
+    uint16_t ble_kumi_service_handler;
+    uint16_t ble_factory_service_handler;
+    uint16_t ble_alipay_service_handler;
+    uint16_t ble_hrs_service_handler;
+    uint16_t ble_hid_service_handler;
+    uint16_t ble_ancs_client_id;
+    uint16_t ad2p_service_handler;
+    uint16_t spp_service_handler;
+    uint16_t hfp_service_handler;
+
+}bt_runtime_status_t;
+/**
+ * cat1_powerOn 0,1
+ * volte volte开关
+ * network_on 0,1
+ * cat1_network_type, 0, 无网络, 1 GSM,2 3G , 4 4G/LTE
+ * sim 1,0
+ * signal 1,31 ; 99 no signal
+ * opera  -1 , "CNUTS"
+ * imei
+ * pyVer
+ * modemVer
+*/
+typedef struct 
+{
+    uint8_t cat1_powerOn;
+    uint8_t volte ;
+    uint8_t network_on ;
+    uint8_t cat1_network_type ; 
+    int sim ;
+    int signal ;
+    char opera[20] ;
+    char imei[20] ;
+    char pyVer[20] ;
+    char modemVer[64] ;
+}cat1_runtime_status_t;
+
+/**
+ * 设备实时状态记录
+ * in_silent_mode 勿扰模式  1 勿扰模式, 0 正常模式
+ * in_lowpower_mode 低电模式  1 低电模式, 0 正常模式
+ * stepcount 步数
+ * bt_powerOn 蓝牙开关 1 开 , 0 关
+ * bt_ble_connectstat 设备已连接手机 1连接, 0 未连接
+ * bt_br_connectstat 经典蓝牙连接状态 0 未连接, 1 连接a2dp 2 连接hfp 3 连接 a2dp+hfp
+ * bt_earphone_connectstat 连接耳机状态 1连接, 0 未连接
+ * android_app_connected , 0 not connected, 1 android connected
+ * cat1_runtime  cat1实时状态,详见 cat1_runtime_status_t 定义
+ * */
+typedef struct 
+{
+    uint8_t in_silent_mode;
+    uint8_t in_lowpower_mode;
+    uint8_t stepcount;
+
+    bt_runtime_status_t bt_runtime;
+    cat1_runtime_status_t cat1_runtime;
+    char current_dial_name[32];
+    uint8_t time_hour_show_model;
+} runtime_status_t;
+
+
 static runtime_status_t g_runtime={0};
-runtime_status_t * get_device_runtime_status(void)
+// runtime_status_t * get_device_runtime_status(void)
+// {
+//     return &g_runtime;
+// }
+
+
+void uapi_dev_runtime_set_cat1_powerstat(uint8_t cat1_powerOn)
+{
+    g_runtime.cat1_runtime.cat1_powerOn=cat1_powerOn;
+}
+uint8_t uapi_dev_runtime_get_cat1_powerstat(void)
+{
+    return g_runtime.cat1_runtime.cat1_powerOn;
+}
+
+void uapi_dev_runtime_set_cat1_networkstat(uint8_t network_on)
+{
+    g_runtime.cat1_runtime.network_on=network_on;
+}
+uint8_t uapi_dev_runtime_get_cat1_networkstat(void)
+{
+    return g_runtime.cat1_runtime.network_on;
+}
+
+
+void uapi_dev_runtime_set_cat1_signal(int signal)
+{
+    g_runtime.cat1_runtime.signal=signal;
+}
+int uapi_dev_runtime_get_cat1_signal(void)
+{
+    return g_runtime.cat1_runtime.signal;
+}
+
+void uapi_dev_runtime_set_cat1_simstat(int simstat)
+{
+    g_runtime.cat1_runtime.sim=simstat;
+}
+int uapi_dev_runtime_get_cat1_simstat(void)
+{
+    return g_runtime.cat1_runtime.sim;
+}
+
+void uapi_dev_runtime_set_cat1_networktype(uint8_t networtype)
 {
-    return &g_runtime;
+    g_runtime.cat1_runtime.cat1_network_type=networtype;
+}
+uint8_t uapi_dev_runtime_get_cat1_networtype(void)
+{
+    return g_runtime.cat1_runtime.cat1_network_type;
+}
+
+
+void uapi_dev_runtime_set_cat1_operator(char* cat1_operator)
+{
+    if (cat1_operator == NULL) return;
+    int len=strlen((char*)cat1_operator);
+    memset_s(g_runtime.cat1_runtime.opera,sizeof(g_runtime.cat1_runtime.opera),0,sizeof(g_runtime.cat1_runtime.opera));
+    memcpy_s(g_runtime.cat1_runtime.opera,sizeof(g_runtime.cat1_runtime.opera),cat1_operator,len);
+}
+char* uapi_dev_runtime_get_cat1_operator(void)
+{
+    return (char*)g_runtime.cat1_runtime.opera;
+}    
+
+void uapi_dev_runtime_set_cat1_imei(char* imei)
+{
+    if (imei == NULL) return;
+    int len=strlen((char*)imei);
+    memset_s(g_runtime.cat1_runtime.opera,sizeof(g_runtime.cat1_runtime.opera),0,sizeof(g_runtime.cat1_runtime.opera));
+    memcpy_s(g_runtime.cat1_runtime.opera,sizeof(g_runtime.cat1_runtime.opera),imei,len);
+}
+char* uapi_dev_runtime_get_cat1_imei(void)
+{
+     return (char*)g_runtime.cat1_runtime.imei;
+}
+
+void uapi_dev_runtime_set_cat1_pyver(char* pyver)
+{
+    if (pyver == NULL) return;
+    int len=strlen((char*)pyver);
+    memset_s(g_runtime.cat1_runtime.opera,sizeof(g_runtime.cat1_runtime.opera),0,sizeof(g_runtime.cat1_runtime.opera));
+    memcpy_s(g_runtime.cat1_runtime.opera,sizeof(g_runtime.cat1_runtime.opera),pyver,len);
+}
+char* uapi_dev_runtime_get_cat1_pyver(void)
+{
+     return (char*)g_runtime.cat1_runtime.pyVer;
+}
+
+void uapi_dev_runtime_set_cat1_modemver(char* modemver)
+{
+    if (modemver == NULL) return;
+    int len=strlen((char*)modemver);
+    memset_s(g_runtime.cat1_runtime.opera,sizeof(g_runtime.cat1_runtime.opera),0,sizeof(g_runtime.cat1_runtime.opera));
+    memcpy_s(g_runtime.cat1_runtime.opera,sizeof(g_runtime.cat1_runtime.opera),modemver,len);
+}
+char* uapi_dev_runtime_get_cat1_modemver(void)
+{
+     return (char*)g_runtime.cat1_runtime.modemVer;
 }
 
 
+/**
+ * 设置 dialname
+*/
+void uapi_dev_runtime_set_dialname(char* dialname)
+{
+
+    if (dialname == NULL) return;
+     //在runtime中备份一个安装文件名。
+    int dialnamelen=strlen((char*)dialname);
+    memset_s(g_runtime.current_dial_name,sizeof(g_runtime.current_dial_name),0,sizeof(g_runtime.current_dial_name));
+    memcpy_s(g_runtime.current_dial_name,sizeof(g_runtime.current_dial_name),dialname,dialnamelen);
+}
+/**
+ * 获取 dialname
+*/
+char* uapi_dev_runtime_get_dialname(void)
+{
+    return (char*)&(g_runtime.current_dial_name[0]);
+}
 void uapi_dev_runtime_set_bt_powerstat(uint8_t stat)
 {
-    g_runtime.bt_powerOn = stat;
+    g_runtime.bt_runtime.bt_powerOn = stat;
 }
 void uapi_dev_runtime_set_ble_connect_stat(uint8_t  connect)
 {
-    g_runtime.bt_ble_connectstat = connect;
+    g_runtime.bt_runtime.bt_ble_connectstat = connect;
 }
 void uapi_dev_runtime_set_br_connect_stat(uint8_t  connect)
 {
-    g_runtime.bt_br_connectstat = connect;
+    g_runtime.bt_runtime.bt_br_connectstat = connect;
 }
 void uapi_dev_runtime_set_earphone_connect_stat(uint8_t  connect)
 {
-    g_runtime.bt_earphone_connectstat = connect;
+    g_runtime.bt_runtime.bt_earphone_connectstat = connect;
 }
 
 
 
 uint8_t uapi_dev_runtime_get_bt_powerstat(void)
 {
-    return g_runtime.bt_powerOn ;
+    return g_runtime.bt_runtime.bt_powerOn ;
 }
 uint8_t uapi_dev_runtime_get_ble_connect_stat(void)
 {
-    return g_runtime.bt_ble_connectstat;
+    return g_runtime.bt_runtime.bt_ble_connectstat;
 }
 uint8_t uapi_dev_runtime_get_br_connect_stat(void)
 {
-    return g_runtime.bt_br_connectstat ;
+    return g_runtime.bt_runtime.bt_br_connectstat ;
 }
 uint8_t uapi_dev_runtime_get_earphone_connect_stat(void)
 {
-    return g_runtime.bt_earphone_connectstat ;
+    return g_runtime.bt_runtime.bt_earphone_connectstat ;
 }
 
 
 
 void uapi_dev_runtime_set_android_connection_status(uint8_t is_android)
 {
-    g_runtime.android_app_connected = is_android;    
+    g_runtime.bt_runtime.android_app_connected = is_android;    
 }
 uint8_t uapi_dev_runtime_get_android_connection_status(void)
 {
-    return g_runtime.android_app_connected;
+    return g_runtime.bt_runtime.android_app_connected;
 }
 
 uint8_t uapi_dev_runtime_get_time_hour_show_model(void)
@@ -67,8 +254,15 @@ void uapi_dev_runtime_sync_runtime_env_to_config(void)
 {
     uint16_t timezone_quarters=uapi_get_timezone();
     set_timezone_quarters(timezone_quarters);
-
     set_hour_show_model(g_runtime.time_hour_show_model);
-    
-    
+}
+
+void uapi_dev_runtime_set_ancs_clientid(uint16_t clientid)
+{
+    g_runtime.bt_runtime.ble_ancs_client_id = clientid;
+}
+
+uint16_t uapi_dev_runtime_get_ancs_clientid(void)
+{
+    return g_runtime.bt_runtime.ble_ancs_client_id;
 }
\ No newline at end of file
index d5596c8..53fd241 100644 (file)
@@ -27,67 +27,54 @@ typedef enum{
     CAT1_5G
 } cat1_network_type_t;
 
-
 /**
- * cat1_powerOn 0,1
- * volte volte开关
- * network_on 0,1
- * cat1_network_type, 0, 无网络, 1 GSM,2 3G , 4 4G/LTE
- * sim 1,0
- * signal 1,31 ; 99 no signal
- * opera  -1 , "CNUTS"
- * imei
- * pyVer
- * modemVer
+ * 获取 设备实时状态变量
+ * 详细内容见 runtime_status_t 定义
 */
-typedef struct 
-{
-    uint8_t cat1_powerOn;
-    uint8_t volte ;
-    uint8_t network_on ;
-    uint8_t cat1_network_type ; 
-    int sim ;
-    int signal ;
-    char opera[20] ;
-    char imei[20] ;
-    char pyVer[20] ;
-    char modemVer[64] ;
-}cat1_runtime_status_t;
+// runtime_status_t * get_device_runtime_status(void);
 
 /**
- * 设备实时状态记录
- * in_silent_mode 勿扰模式  1 勿扰模式, 0 正常模式
- * in_lowpower_mode 低电模式  1 低电模式, 0 正常模式
- * stepcount 步数
- * bt_powerOn 蓝牙开关 1 开 , 0 关
- * bt_ble_connectstat 设备已连接手机 1连接, 0 未连接
- * bt_br_connectstat 经典蓝牙连接状态 0 未连接, 1 连接a2dp 2 连接hfp 3 连接 a2dp+hfp
- * bt_earphone_connectstat 连接耳机状态 1连接, 0 未连接
- * android_app_connected , 0 not connected, 1 android connected
- * cat1_runtime  cat1实时状态,详见 cat1_runtime_status_t 定义
- * */
-typedef struct 
-{
-    uint8_t in_silent_mode;
-    uint8_t in_lowpower_mode;
-    uint8_t stepcount;
-    uint8_t bt_powerOn;
-    uint8_t bt_ble_connectstat;
-    uint8_t bt_br_connectstat;
-    uint8_t bt_earphone_connectstat;
-    uint8_t android_app_connected;
-    cat1_runtime_status_t cat1_runtime;
-    uint8_t current_dial_name[32];
-    uint8_t time_hour_show_model;
-} runtime_status_t;
-
+ * 设置 dialname
+*/
+void uapi_dev_runtime_set_dialname(char* dialname);
 /**
- * 获取 设备实时状态变量
- * 详细内容见 runtime_status_t 定义
+ * 获取 dialname
 */
-runtime_status_t * get_device_runtime_status(void);
+char* uapi_dev_runtime_get_dialname(void);
+
+/***************************************cat1 runtime 变量设置获取函数**************************************************/
+
+
+void uapi_dev_runtime_set_cat1_powerstat(uint8_t cat1_powerOn);
+uint8_t uapi_dev_runtime_get_cat1_powerstat(void);
+
+void uapi_dev_runtime_set_cat1_networkstat(uint8_t network_on);
+uint8_t uapi_dev_runtime_get_cat1_networkstat(void);
+
+void uapi_dev_runtime_set_cat1_signal(int signal);
+int uapi_dev_runtime_get_cat1_signal(void);
+
+void uapi_dev_runtime_set_cat1_simstat(int simstat);
+int uapi_dev_runtime_get_cat1_simstat(void);
+
+void uapi_dev_runtime_set_cat1_networktype(uint8_t networtype);
+uint8_t uapi_dev_runtime_get_cat1_networtype(void);    
+
+
+void uapi_dev_runtime_set_cat1_operator(char* cat1_operator);
+char* uapi_dev_runtime_get_cat1_operator(void);    
+
+void uapi_dev_runtime_set_cat1_imei(char* cat1_operator);
+char* uapi_dev_runtime_get_cat1_imei(void);    
+
+void uapi_dev_runtime_set_cat1_pyver(char* cat1_operator);
+char* uapi_dev_runtime_get_cat1_pyver(void);    
+
+void uapi_dev_runtime_set_cat1_modemver(char* cat1_operator);
+char* uapi_dev_runtime_get_cat1_modemver(void);    
 
 
+/***************************************蓝牙runtime 变量设置获取函数**************************************************/
 /**
  * 设置蓝牙开关状态
 */
@@ -141,6 +128,8 @@ void uapi_dev_runtime_sync_runtime_env_to_config(void);
 uint8_t uapi_dev_runtime_get_time_hour_show_model(void);
 void uapi_dev_runtime_set_time_hour_show_model(uint8_t hour_type);
 
+void uapi_dev_runtime_set_ancs_clientid(uint16_t clientid);
+uint16_t uapi_dev_runtime_get_ancs_clientid(void);