--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:9e1bdd2638451c627e343aea61fca117156277d6dbc557b9149d72b3f46223b0
+size 11630387
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)
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"
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":
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数据包
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)
{
}
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;
// 获取ASR服务初始化标志
uint8_t get_ai_asr_service_init_flag(void)
{
- return true;
+ return ai_asr_service_init_flag;
}
// 设置ASR服务初始化标志
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))
}
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);
{
chat_client = init_websocket_client("ws://118.145.158.207:22080/chat/ws?&platform=aliyun",NULL,0);
}
+ #endif
}
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
{
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,//
if( sourceAddr.sin_port != 0 ) {
udp_send_response(station_tx_buffer, cmd, content);
-
-
}
uapi_cat1_wakeup_cat1(0);
}
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");
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");
}
//"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();
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();
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;
char imei[20] ;
char pyVer[20] ;
char modemVer[64] ;
+
+ char DEV_ID[128] ;
}cat1_runtime_status_t;
/**
return (char*)g_runtime.cat1_runtime.imei;
}
+
+
void uapi_dev_runtime_set_cat1_pyver(char* pyver)
{
if (pyver == NULL) return;
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
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 变量设置获取函数**************************************************/
/**