From 590414b4740851edf4a7c2a29d8d68675a0be1f6 Mon Sep 17 00:00:00 2001 From: SnickerSun Date: Fri, 14 Jun 2024 10:53:48 +0800 Subject: [PATCH] =?utf8?q?custom=20runtime=20=E5=8E=BB=E6=8E=89=E7=9B=B4?= =?utf8?q?=E6=8E=A5=E8=AE=BF=E9=97=AE=E5=8F=98=E9=87=8F=E7=9A=84=E6=96=B9?= =?utf8?q?=E6=B3=95=EF=BC=8C=E9=87=87=E7=94=A8=E5=87=BD=E6=95=B0=E8=AE=BE?= =?utf8?q?=E7=BD=AE=E8=8E=B7=E5=8F=96=E3=80=82=20=E4=BC=98=E5=8C=96Cat1?= =?utf8?q?=E8=A7=A3=E6=9E=90=EF=BC=8C=E7=89=88=E6=9C=AC6=E4=BB=A5=E4=B8=8A?= =?utf8?q?=E7=9A=84=E4=BF=A1=E5=8F=B7=E8=A7=A3=E6=9E=90=E5=A2=9E=E5=8A=A0?= =?utf8?q?=20=E7=BD=91=E7=BB=9C=E7=B1=BB=E5=9E=8B=E5=92=8C=E6=98=AF?= =?utf8?q?=E5=90=A6=E8=BF=9E=E6=8E=A5=E9=80=89=E9=A1=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/main/src/PullUpDownView.cpp | 3 +- .../nativeui/producttest/src/testcat1.cpp | 13 +- .../service/ble_service/bleservice/bleEvent.c | 10 +- .../factorytest_protocol.c | 13 +- .../slip/cat1Service/cat1_server.cpp | 98 ++++---- .../drivers/peripheral/utils/custom_runtime.c | 224 ++++++++++++++++-- .../drivers/peripheral/utils/custom_runtime.h | 95 ++++---- 7 files changed, 317 insertions(+), 139 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp index a51016211..9766f4ee3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp @@ -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; diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testcat1.cpp b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testcat1.cpp index b14c8c608..43fc7fcbc 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testcat1.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testcat1.cpp @@ -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) { diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c index 1106eeaba..c12a97415 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -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); filename[dialinfo.file_name_len] ='\0'; //在runtime中备份一个安装文件名。 - 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)); - memcpy_s(get_device_runtime_status()->current_dial_name,sizeof(get_device_runtime_status()->current_dial_name),filename,dialinfo.file_name_len); - + uapi_dev_runtime_set_dialname(filename); buffer_handle->file_recv_stat.file_name = filename; buffer_handle->file_recv_stat.file_size = file_size; buffer_handle->file_recv_stat.file_type = 3;//表盘 @@ -5308,8 +5306,8 @@ errcode_t decode_single_dial_info(ble_read_data *buffer_handle) } static errcode_t install_dial(void) { - printf("install %s\n",get_device_runtime_status()->current_dial_name); - char *lzmapkgname =(char*)(get_device_runtime_status()->current_dial_name); + char *lzmapkgname =uapi_dev_runtime_get_dialname(); + printf("install %s\n",lzmapkgname); char *lzmaindex = strstr(lzmapkgname,".lzma"); if (lzmaindex != NULL) { @@ -5318,7 +5316,7 @@ static errcode_t install_dial(void) printf("dial_basenamelen %d\n",dial_basenamelen); if (dial_basenamelen>0 ) { - memcpy_s(dial_basename,sizeof(dial_basename),get_device_runtime_status()->current_dial_name,dial_basenamelen); + memcpy_s(dial_basename,sizeof(dial_basename),lzmapkgname,dial_basenamelen); } else{ return ERRCODE_FAIL; 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 27e5381da..ce293ef40 100644 --- a/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c +++ b/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c @@ -1514,8 +1514,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint cat1_getsignal(); msleep(1000); - runtime_status_t * runtime = get_device_runtime_status(); - send_data[1]=runtime->cat1_runtime.sim; + send_data[1]=uapi_dev_runtime_get_cat1_simstat(); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CAT1, 0x03, @@ -1528,8 +1527,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint cat1_getsignal(); msleep(1000); - runtime_status_t * runtime = get_device_runtime_status(); - send_data[1]=runtime->cat1_runtime.signal; + send_data[1]=uapi_dev_runtime_get_cat1_signal(); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CAT1, @@ -1544,15 +1542,14 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint cat1_getsignal(); msleep(1000); - runtime_status_t * runtime = get_device_runtime_status(); - PRINT("send_buf : %s \r\n",runtime->cat1_runtime.opera); + PRINT("send_buf : %s \r\n",uapi_dev_runtime_get_cat1_operator()); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CAT1, 0x05, - (uint8_t *)runtime->cat1_runtime.opera, - strlen(runtime->cat1_runtime.opera)); + (uint8_t *)uapi_dev_runtime_get_cat1_operator(), + strlen(uapi_dev_runtime_get_cat1_operator())); } else if(testitem == 0x06) { //拨打电话 diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp index 05f691cf8..d40b4793f 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp @@ -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); } diff --git a/code/sdk/drivers/peripheral/utils/custom_runtime.c b/code/sdk/drivers/peripheral/utils/custom_runtime.c index cd3ce8045..30f15cb79 100644 --- a/code/sdk/drivers/peripheral/utils/custom_runtime.c +++ b/code/sdk/drivers/peripheral/utils/custom_runtime.c @@ -1,57 +1,244 @@ #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 diff --git a/code/sdk/drivers/peripheral/utils/custom_runtime.h b/code/sdk/drivers/peripheral/utils/custom_runtime.h index d5596c8ad..53fd241d4 100644 --- a/code/sdk/drivers/peripheral/utils/custom_runtime.h +++ b/code/sdk/drivers/peripheral/utils/custom_runtime.h @@ -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); -- 2.17.1