From: hcj <1224667075@qq.com> Date: Tue, 29 Jul 2025 06:52:08 +0000 (+0800) Subject: 增加设备id,及产品id X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=4986886fab6ee7710f5e1f86e2984672ca9588af;p=mirrors%2FFD230.git 增加设备id,及产品id --- diff --git a/cat1modem/fd230/bak/EG810MCNLAR06A01M08_VOLTE_OCPU_QPY_TEST0630_20250630-1944_20250729-1430.zip b/cat1modem/fd230/bak/EG810MCNLAR06A01M08_VOLTE_OCPU_QPY_TEST0630_20250630-1944_20250729-1430.zip new file mode 100644 index 000000000..736805ab5 --- /dev/null +++ b/cat1modem/fd230/bak/EG810MCNLAR06A01M08_VOLTE_OCPU_QPY_TEST0630_20250630-1944_20250729-1430.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9e1bdd2638451c627e343aea61fca117156277d6dbc557b9149d72b3f46223b0 +size 11630387 diff --git a/cat1modem/src/cat1Service.py b/cat1modem/src/cat1Service.py index 8472750c9..9c4e630ba 100644 --- a/cat1modem/src/cat1Service.py +++ b/cat1modem/src/cat1Service.py @@ -50,12 +50,14 @@ import request import ql_fs import pm import sms +import ujson from usr.EventMesh import eventMesh from usr.httpota import httpota # from usr.telecom_dmp import telecomDmpCb # from usr.china_mobile_dmp import chinamobileCb + from usr.china_mobile_ai_regulation import aiRegulation # 设置日志输出级别 log.basicConfig(level=log.INFO) @@ -79,7 +81,7 @@ sms.setCallback(msg_cb)#sms注册回调 CAT1_SERVICE_HEAD = 'FE' #固定head PROJECT_NAME = "Cat1SlipUDPService" -PROJECT_VERSION = "PY_SRV_V20" +PROJECT_VERSION = "PY_SRV_V21" CONFIG_JSON="/usr/system_config.json" CURRENT_APP_TYPE="pysrv" @@ -404,9 +406,13 @@ class Cat1Service: httpota.run( str(parm).split("and")[0], str(parm).split("and")[-1]) # eventMesh.publish("set_volte_switch",int(parm)) # UDP_MSG_OTA + elif cmd == "1C":# + self.read_dev_ai_id() elif cmd == "AC":# if self.ack_sem==1: self.ack_sem=0 + + def telecom_recv_cmd(self,cmd,parm): if cmd == "10": @@ -841,6 +847,30 @@ class Cat1Service: def stop(self): slip.destroy() return 0 + + def read_dev_ai_id(self): + + IFEXIST = ql_fs.path_exists("/usr/cm_ai_regulation.json") # + if IFEXIST == True: #文件存在 + fileSize = ql_fs.path_getsize('usr/cm_ai_regulation.json') + if fileSize == 0: + + print("设备信息配置文件不存在\r\n") + else: + try: + with open("/usr/cm_ai_regulation.json","r",encoding='utf-8') as fd: + try: + config_data = ujson.load(fd) #转换成json格式 + if len(config_data) != 0: + if "deviceId" in config_data:# + deviceId = str(config_data["deviceId"]) #设备ID + self.reply_cmd('1C',"{}".format(deviceId)) + except Exception as error: + print("配置文件的内容不是json格式 保存数据的时候格式不对\r\n") + except Exception as error: + print("打开配置文件失败\r\n") + + # 封装tlv数据包 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 9d22b9507..40e1ecdcb 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ai_server.cpp +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ai_server.cpp @@ -325,21 +325,19 @@ bool chat_result_analysis(char *buf) cJSON_Delete(root); return true; } - +// &device_id=222&product_id=222 bool chat_ws_url_init(char * put_buf,uint8_t type) { char token[64]={0}; if(read_dev_token(token)) { - sprintf(put_buf,"ws://amp.raisound.com/chat/ws?dt=%s&platform=chinamobiledevice&bot_type=jiutian-lan",token); - if(type_ai==AI_TYPE_JIU) { sprintf(put_buf,"ws://amp.raisound.com/chat/ws?dt=%s&platform=chinamobiledevice&bot_type=jiutian-lan",token); } else if(type_ai==AI_TYPE_DOU) { - sprintf(put_buf,"ws://amp.raisound.com/chat/ws?dt=%s&platform=huoshan",token,0); + sprintf(put_buf,"ws://amp.raisound.com/chat/ws?dt=%s&platform=huoshan",token); } else if(type_ai==AI_TYPE_WEN) { @@ -362,9 +360,40 @@ bool chat_ws_url_init(char * put_buf,uint8_t type) } else { + char * Service_url="118.145.158.207:22080"; + + char * device_id=uapi_dev_runtime_get_DEV_ID(); + + char * product_id="1927646275585744898"; + + if(type_ai==AI_TYPE_JIU) + { + sprintf(put_buf,"ws://%s/chat/ws?device_id=%s&product_id=%s&platform=chinamobiledevice&bot_type=jiutian-lan",Service_url,device_id,product_id); + } + else if(type_ai==AI_TYPE_DOU) + { + sprintf(put_buf,"ws://%s/chat/ws?device_id=%s&product_id=%s&platform=huoshan",Service_url,device_id,product_id); + } + else if(type_ai==AI_TYPE_WEN) + { + sprintf(put_buf,"ws://%s/chat/ws?device_id=%s&product_id=%s&platform=baidu",Service_url,device_id,product_id); + } + else if(type_ai==AI_TYPE_KIMI) + { + sprintf(put_buf,"ws://%s/chat/ws?device_id=%s&product_id=%s&platform=moonshot",Service_url,device_id,product_id); + } + else if(type_ai==AI_TYPE_DE) + { + sprintf(put_buf,"ws://%s/chat/ws?device_id=%s&product_id=%s&platform=huoshan&model=ep-20250205103849-582m7",Service_url,device_id,product_id); + } + else + { + sprintf(put_buf,"ws://%s/chat/ws?device_id=%s&product_id=%s&platform=aliyun",Service_url,device_id,product_id); + } return false; } + } uint8_t is_bk_websocket_chat=0; @@ -374,7 +403,7 @@ static uint8_t ai_tts_server_init_flag = 0; //tts初始化标志 // 获取ASR服务初始化标志 uint8_t get_ai_asr_service_init_flag(void) { - return true; + return ai_asr_service_init_flag; } // 设置ASR服务初始化标志 @@ -419,7 +448,7 @@ void bk_websocket_demo(void *data) { char_reconnet: is_bk_websocket_chat=1; - char url_buf[124]={0}; + char url_buf[248]={0}; uint8_t is_raisound_url=0; if(chat_ws_url_init(url_buf,type_ai)) @@ -444,6 +473,9 @@ void bk_websocket_demo(void *data) { } else { + #ifdef SUPPORT_CHINA_MOBILE_AI_REGULATION + chat_client = init_websocket_client(url_buf,NULL,0); + #else if(type_ai==AI_TYPE_JIU) { chat_client = init_websocket_client("ws://118.145.158.207:22080/chat/ws?&platform=chinamobiledevice&bot_type=jiutian-lan",NULL,0); @@ -468,6 +500,7 @@ void bk_websocket_demo(void *data) { { chat_client = init_websocket_client("ws://118.145.158.207:22080/chat/ws?&platform=aliyun",NULL,0); } + #endif } @@ -1521,7 +1554,7 @@ void send_ai_bin(uint8_t *buf,uint32_t len) if (send_websocket_message(asr_client,( uint8_t *)buf,len,WS_BINARY)==0) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"send_websocket_message succ 0\n"); - msleep(50); + msleep(10); } else { diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp index 6626cdb5b..44f5c1335 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.cpp @@ -95,7 +95,9 @@ enum UDP_COMMAND_HEAD { UDP_MSG_SEND_VOLTE_SWITCH = 0x1A,//VOLTE开关 - UDP_MSG_SEND_OTA= 0x1B,//OTA 升级 + UDP_MSG_SEND_OTA= 0x1B,//OTA 升级 + + UDP_MSG_SEND_AI_ID= 0x1C,//ai设备id获取 UDP_MSG_WATCH_REPLY_ACK = 0xAC,// // UDP_MSG_WATCH_REPLY_HANGUP = 0x21,// @@ -406,8 +408,6 @@ void udp_send_msg_toCat1(uint8_t cmd,char *content) if( sourceAddr.sin_port != 0 ) { udp_send_response(station_tx_buffer, cmd, content); - - } uapi_cat1_wakeup_cat1(0); } @@ -944,6 +944,11 @@ void cat1_gettime(void) udp_send_msg_toCat1(UDP_CMD_GET_TIME,"0"); } +void cat1_get_DEV_ID(void) +{ + udp_send_msg_toCat1(UDP_MSG_SEND_AI_ID,"0"); +} + // void watch_replay_cat1_ANSWER(void) // { // udp_send_msg_toCat1(UDP_MSG_WATCH_REPLY_ANSWER,"0"); @@ -1179,6 +1184,11 @@ static void time_sync_func(void) if (uapi_get_screen_state() == 0) { cat1_getsignal(); + + #ifdef SUPPORT_CHINA_MOBILE_AI_REGULATION + if(strlen(uapi_dev_runtime_get_DEV_ID())==0) + cat1_get_DEV_ID(); + #endif }else{ // printf("Screen off skip get signal\n"); } @@ -1506,12 +1516,15 @@ static int udp_packet_parse(char *rx_buffer, int len) //"BOOTUP,pyVer,PY_SRV_V4,modemVer,EG810MCNLAR06A01M08_VOLTE_OCPU_QPY_BETA0312" // VER:xxxxx // ICCID:xxxxxx + if(strstr(msg_buffer,"BOOTUP")!=NULL) { cat1_handle_version_msg(msg_buffer); restart_time_sync(); cat1_getsignal(); + + if(sntp_enabled()==0) { sntp_init(); @@ -1537,8 +1550,10 @@ static int udp_packet_parse(char *rx_buffer, int len) printf("stateNew %d stateOld:%d\r\n",stateNew,stateOld); send_dmp_mode_toCat1(stateNew); if (stateNew == 1){ //0 是不开启入库功能 1 电信 2-255其他移动 + get_software_version_toCat1(); send_dmp_factory_flag(); + }else if (stateNew == 2){ //移动入库功能 get_software_version_toCat1(); send_ble_mac_toCat1(); @@ -1610,6 +1625,8 @@ static int udp_packet_parse(char *rx_buffer, int len) index = cat1_handle_sms(msg_buffer); uapi_save_runtime_log(RUNTIME_LOG_CAT1_UDP_MSG_SMS); break; + case UDP_MSG_SEND_AI_ID: + uapi_dev_runtime_set_cat1_DEV_ID(msg_buffer); default: WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"error message: %s\n", rx_buffer); index = 1; diff --git a/code/sdk/drivers/peripheral/utils/custom_runtime.c b/code/sdk/drivers/peripheral/utils/custom_runtime.c index 5ce3a98ec..144dc9cca 100644 --- a/code/sdk/drivers/peripheral/utils/custom_runtime.c +++ b/code/sdk/drivers/peripheral/utils/custom_runtime.c @@ -46,6 +46,8 @@ typedef struct char imei[20] ; char pyVer[20] ; char modemVer[64] ; + + char DEV_ID[128] ; }cat1_runtime_status_t; /** @@ -215,6 +217,8 @@ 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; @@ -239,6 +243,19 @@ char* uapi_dev_runtime_get_cat1_modemver(void) return (char*)g_runtime.cat1_runtime.modemVer; } +void uapi_dev_runtime_set_cat1_DEV_ID(char* DEV_ID) +{ + if (DEV_ID == NULL) return; + int len=strlen(DEV_ID); + memset_s(g_runtime.cat1_runtime.DEV_ID,sizeof(g_runtime.cat1_runtime.DEV_ID),0,sizeof(g_runtime.cat1_runtime.DEV_ID)); + memcpy_s(g_runtime.cat1_runtime.DEV_ID,sizeof(g_runtime.cat1_runtime.DEV_ID),DEV_ID,len); +} + +char* uapi_dev_runtime_get_DEV_ID(void) +{ + return (char*)g_runtime.cat1_runtime.DEV_ID; +} + /** * 设置 dialname diff --git a/code/sdk/drivers/peripheral/utils/custom_runtime.h b/code/sdk/drivers/peripheral/utils/custom_runtime.h index f9b1fc619..f588f2a68 100644 --- a/code/sdk/drivers/peripheral/utils/custom_runtime.h +++ b/code/sdk/drivers/peripheral/utils/custom_runtime.h @@ -213,6 +213,8 @@ 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); +char* uapi_dev_runtime_get_DEV_ID(void); +void uapi_dev_runtime_set_cat1_DEV_ID(char* DEV_ID); /***************************************蓝牙runtime 变量设置获取函数**************************************************/ /**