From efc5b3ed119098963a7bea7372d34406d9521a09 Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Fri, 1 Aug 2025 17:53:04 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0ai=20dev=5Fid=20config?= =?utf8?q?=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../peripheral/config/include/ConfigModel.h | 2 ++ .../peripheral/config/include/ConfigModelC.h | 4 ++++ .../peripheral/config/src/ConfigModel.cpp | 16 ++++++++++++++++ .../slip/cat1Service/cat1_ai_server.cpp | 5 +++-- .../peripheral/slip/cat1Service/cat1_server.cpp | 6 +++++- 5 files changed, 30 insertions(+), 3 deletions(-) diff --git a/code/sdk/drivers/peripheral/config/include/ConfigModel.h b/code/sdk/drivers/peripheral/config/include/ConfigModel.h index 6bfbe4a13..50a11661c 100644 --- a/code/sdk/drivers/peripheral/config/include/ConfigModel.h +++ b/code/sdk/drivers/peripheral/config/include/ConfigModel.h @@ -160,6 +160,7 @@ namespace OHOS CONFIGMODEL_ITEM_BP_CALIBRATION_FIRST_TIME, //血压校准第一次校准 CONFIGMODEL_ITEM_BP_CALIBRATION_SECOND_TIME, //血压校准第二次校准 #endif + CONFIGMODEL_ITEM_DEV_ID, CONFIGMODEL_ITEM_MAX, @@ -436,6 +437,7 @@ namespace OHOS {ConfigDataType::DATATYPE_INT, "bp_calibration_first_time", "0" },//CONFIGMODEL_ITEM_BP_CALIBRATION_FIRST_TIME,//血压第一次校准时间 {ConfigDataType::DATATYPE_INT, "bp_calibration_second_time", "0" },//CONFIGMODEL_ITEM_BP_CALIBRATION_SECOND_TIME,//血压第二次校准时间 #endif + {ConfigDataType::DATATYPE_STRING, "device_id", "" }, // CONFIGMODEL_ITEM_DEV_ID }; ConfigModel(); // 私有构造函数,确保无法在外部实例化 ConfigModel(const ConfigModel &) = delete; // 禁止拷贝构造 diff --git a/code/sdk/drivers/peripheral/config/include/ConfigModelC.h b/code/sdk/drivers/peripheral/config/include/ConfigModelC.h index 009b0333a..f991cdf5e 100644 --- a/code/sdk/drivers/peripheral/config/include/ConfigModelC.h +++ b/code/sdk/drivers/peripheral/config/include/ConfigModelC.h @@ -146,6 +146,10 @@ void set_save_runtime_log_switch(int value); int get_save_runtime_log_switch(void); +int set_dev_id(char *buf); + +int get_dev_id(char *buf); + #ifdef __cplusplus #if __cplusplus diff --git a/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp b/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp index 983209617..d6f1c4c8e 100644 --- a/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp +++ b/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp @@ -1635,6 +1635,22 @@ int get_save_runtime_log_switch(void) { return OHOS::ConfigModel::GetInstance()->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SAVE_RUNTIMR_LOG_STATUS); } + + +int set_dev_id(char *buf) +{ + OHOS::ConfigModel::GetInstance()->set_condigData_String(OHOS::ConfigModel::CONFIGMODEL_ITEM_DEV_ID,buf); + return 0; +} + +int get_dev_id(char *buf) +{ + std::string str = OHOS::ConfigModel::GetInstance()->get_configData_string(OHOS::ConfigModel::CONFIGMODEL_ITEM_DEV_ID); + memcpy(buf,str.c_str(),str.length()); + return 0; +} + + #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ai_server.cpp b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ai_server.cpp index fb7ba1dce..6ffb35ad7 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ai_server.cpp +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ai_server.cpp @@ -368,8 +368,9 @@ bool chat_ws_url_init(char * put_buf,uint8_t type) { char * Service_url="118.145.158.207:22080"; - char * device_id=uapi_dev_runtime_get_DEV_ID(); - + char device_id[128]={0}; + get_dev_id(device_id); + char * product_id="1927646275585744898"; if(type_ai==AI_TYPE_JIU) diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp index 4d0e8a9c9..9334101af 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp @@ -1188,7 +1188,9 @@ static void time_sync_func(void) cat1_getsignal(); #ifdef SUPPORT_CHINA_MOBILE_AI_REGULATION - if(strlen(uapi_dev_runtime_get_DEV_ID())==0) + char device_id[128]={0}; + get_dev_id(device_id); + if(strlen(device_id)==0) cat1_get_DEV_ID(); #endif }else{ @@ -1633,6 +1635,8 @@ static int udp_packet_parse(char *rx_buffer, int len) break; case UDP_MSG_SEND_AI_ID: uapi_dev_runtime_set_cat1_DEV_ID(msg_buffer); + // if(msg_buffer) + set_dev_id(msg_buffer); default: WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"error message: %s\n", rx_buffer); index = 1; -- 2.17.1