精华内容
下载资源
问答
  • 6531E硬件资料.rar

    2020-08-04 15:18:14
    6531E硬件资料,SC6531E-F-M GPIO_Spec_V1.2,SC6531E-F-M NV Configuration notes V1.0
  • SC6531E硬件设计指导,官方文件,介绍了平台的规格,以及硬件设计指导
  • 6531E平台为展讯的featurephone平台,故将选项选择为featurephone。让后将手机打开,选择手机的工程模式(默认命令为#*111111#)。选择USBlog选项,并将其打开。 将电脑装好驱动,驱动所在的文件夹为:tools/debug_...

    展讯平台使用自研软件audiotest进行相关音频调试。软件界面如下:
    展讯autiotest软件界面
    该软件界面可以调试所有手机平台。6531E平台为展讯的featurephone平台,故将选项选择为featurephone。让后将手机打开,选择手机的工程模式(默认命令为#*111111#)。选择USBlog选项,并将其打开。
    将电脑装好驱动,驱动所在的文件夹为:tools/debug_tools内的sciusb2serial文件。安装完成后将常规USB线插入后电脑会识别USB设备,在上述软件的Port处选择usb_dig,点击右边的connect按钮即可。
    当连接上后,下面四个灰色按钮会变为可用。其中Get Audio Information按钮为读取通话 录音等相关音频参数的设置。Get Music Information按钮为设置音乐播放 fm播放 开关机铃声 来电铃声等的音量。

    展开全文
  • 6531E平台HTTPS接口调试

    2019-03-03 11:32:58
    展讯6531平台socket 中有详细的说明,这里我们只说差异的部分,根据第一部分的SSL流程的分析。在收发数据之前都需要通知调用SSL的加密解密。然后通过SSL的回调在进行密文的收发。流程如下 1、sci_sock_connect...

     平台SSL协议

     一、协议部分

     

     

     

     

    SSL_AsyncRegCallback注册回调

    http_SecurityRecvDataCllback加密成功回调

    http_SecuritySendDataCllback解密成功回调

    http_SecurityPostMessageCllback握手信息回调

    http_SecurityShowCertInfoCllback证书错误回调

     

    二、工作流程分析

    由上图的协议可以,在发送、接收数据之前,都要先通知SSL层。成功之后再走正常的Socket收发流程

    例如发送数据的流程(接收同理)

    Soket的处理在我的文章展讯6531平台socket中有详细的说明,这里我们只说差异的部分,根据第一部分的SSL流程的分析。在收发数据之前都需要通知调用SSL的加密解密。然后通过SSL的回调在进行密文的收发。流程如下

    1、sci_sock_connect之后建立SSL:SSL_Create(源码在HTTP_SslInit),并且给SSL注册上层回调SSL_AsyncRegCallback(源码在httpHandshaking)

    2、线程内监听socket事件的到来

    socket可写:SSL_EncryptPasser加密数据,SSL加密成功之后调用我们注册的回调http_SecuritySendDataCllback,之后处理逻辑,我这里直接sci_sock_send,并且通知SSL:SSL_AsyncMessageProc(((HX_SALE_SSL_INSTANCE *)httpmachine_ptr)->hSSl, SSL_RECV_MESSAGE_SEND_SUCC, data_len);我发送成功了,释放占用的资源吧

    socket可读:sci_sock_recv之后,此时的数据还是密文状态,需要调用SSL接口解密数据:SSL_DecryptPasser,SSL解密成功之后调用回调:http_SecurityRecvDataCllback,之后就是对接收的数据操作了,我是直接解析数据的内容,然后SSL_AsyncMessageProc(((HX_SALE_SSL_INSTANCE *)httpmachine_ptr)->hSSl, SSL_RECV_MESSAGE_RECV_SUCC, data_len);,通知SSL释放资源。

    至此,SSL的处理流程完毕。只是在HTTP的基础上加上SSL的处理,就能调用HTTPS的接口收发数据了

    SSL_EncryptPasser(SslInstance->hSSl, buf, strlen(buf));
                    |
                    |
    
    http_SecuritySendDataCllback
                    |
                    |
    http_Sending
                    |
                    |
    sci_sock_send
                    |
                    |
    SSL_AsyncMessageProc(((HX_SALE_SSL_INSTANCE *)httpmachine_ptr)->hSSl, SSL_RECV_MESSAGE_SEND_SUCC, data_len);//发送成功之后,需要向SSL发送异步消息。通知SSL释放占用的资源

     

     

     

     

     

    三、源码

    部分实现源码如下: 

     

    /*****************************************************************************/
    //  Description : 封装JSON格式的数据
    //  Global resource dependence : none
    //  Author: jiemin lai
    //  Note: HX_SALE_SEND_DATA_TYPE
    /*****************************************************************************/
    
    LOCAL uint8 * MMISALE_CreateJSONpack(HX_SALE_SEND_DATA_TYPE CustomData)
    {
    	cJSON *root = PNULL;
    	char *ret_ptr = PNULL;
    
    	char plmn_info_data[8] = {0};
    
    	SCI_TRACE_LOW("MMISALE_CreateJSONpack ...entry...");
    
    	root=cJSON_CreateObject();	
    
    	cJSON_AddItemToObject(root, "IMEI1", 			cJSON_CreateString(CustomData.imei1));
    	cJSON_AddItemToObject(root, "IMEI2", 			cJSON_CreateString(CustomData.imei2));
    	cJSON_AddItemToObject(root, "model", 			cJSON_CreateString(CustomData.model));
    	cJSON_AddItemToObject(root, "modelDetail", 		cJSON_CreateString(CustomData.modelDetail));
    	cJSON_AddItemToObject(root, "currentVersion", 	cJSON_CreateString(CustomData.currentVersion));
    	cJSON_AddItemToObject(root, "serialNumber", 	cJSON_CreateString(CustomData.serialNumber));
    	
    	sprintf(plmn_info_data, 	"%d%02d", 			CustomData.sim1plmn.mcc, CustomData.sim1plmn.mnc);
    	cJSON_AddItemToObject(root, "operator", 		cJSON_CreateString(plmn_info_data));
    	memset(plmn_info_data, 0, sizeof(plmn_info_data));
    	sprintf(plmn_info_data, 	"%d%02d", 			CustomData.sim2plmn.mcc, CustomData.sim2plmn.mnc);
    	cJSON_AddItemToObject(root, "operator2", 		cJSON_CreateString(plmn_info_data));
    	cJSON_AddItemToObject(root, "language", 		cJSON_CreateString(CustomData.language));
    
    	ret_ptr = cJSON_Print(root);
    	cJSON_Delete(root);
    	//free(root);
    
    	SCI_TRACE_LOW("MMISALE_CreateJSONpack ...out...");
    	
    	return ret_ptr;
    	
    }
    
    /*****************************************************************************/
    //  Description : 解析服务器返回的数据
    //  Global resource dependence : none
    //  Author: jiemin lai
    //  Note: 
    /*****************************************************************************/
    LOCAL BOOLEAN HxSaleParseDataInfo(char* CustomData)
    {
    	char* b = PNULL;
    	char* e = PNULL;
    	char RecvData[8] = {0};
    
    	SCI_TRACE_LOW("HxSaleParseDataInfo Entry !");
    	
    	if(PNULL == CustomData)
    	{
    		SCI_TRACE_LOW("HxSaleParseDataInfo  CustomData == PNULL!");
    		return FALSE;
    	}
    	if( MMIAPICOM_Stristr(CustomData," 200") == NULL)   //不是返回的200,那说明是错误的
    	{
    	    SCI_TRACE_LOW("HxSaleParseDataInfo  (server data:HTTP/1.1 200)  no data");
    		return FALSE;
    	}
    
    #if defined(TP_LINK_SALES_STATISTICS)&&defined(WIN32)//激活次数统计
        Sales_start_flag_add();
    	if(TP_LINK_Sales_Start_Flag_Times()<5)
    	{
            MMIDefault_StartSalesTimer();
    		return FALSE;
    	}
    #endif
    
    
    	//成功的标志是{"type":"success"}
    	e = b = MMIAPICOM_Stristr(CustomData,"{\"type\":\"") + strlen("{\"type\":\""); //到前一个分号
    	e = MMIAPICOM_Stristr(b, "\"");   //到后一个分号,e跟b之间就是返回的数据
    
    	strncpy(RecvData, b, e - b);
    
    	SCI_TRACE_LOW("HxSaleParseDataInfo RecvData=:%s", RecvData);
    
    	if((strlen(RecvData) != 0) && (0 == strncmp("success", RecvData, strlen(RecvData))))  // 表示成功,服务器已接收请求
    	{
    		//清除销量统计的NV
    	  #if defined(TP_LINK_SALES_STATISTICS)
            sales_statistics_send_success();
            MMIIDefault_StopSalesTimer();
    	  #endif
    		SCI_TRACE_LOW("HxSaleParseDataInfo parse custom data success !");
    		return TRUE;
    	}
    	
    }
    
    /*****************************************************************************/
    //  Description : 向socket线程发送信号(socket打开过程中遇到错误)
    //  Global resource dependence : none
    //  Author: jiemin lai
    //  Note: 
    /*****************************************************************************/
    LOCAL BOOLEAN HxSaleSendSignal(void)
    {
    	xSignalHeaderRec *sig_ptr = 0;
    
    	SCI_TRACE_LOW("HxSaleSendSignal");
    
    	sig_ptr = (xSignalHeaderRec *)SCI_ALLOCA(sizeof(xSignalHeaderRec));
    	SCI_ASSERT(sig_ptr);/*assert verified*/
    
    	sig_ptr->SignalCode = MSG_SALE_SOCKET_ERROR;
    	sig_ptr->SignalSize = sizeof(xSignalHeaderRec);
    	sig_ptr->Sender = SCI_IdentifyThread();
    
    	SCI_SendSignal((xSignalHeader)sig_ptr, s_sale_task_id);
    }
    
    /*****************************************************************************/
    //  Description :销量统计条件达到,调用此函数执行网络端发送,本模块实现,外部模块调用 
    //  Global resource dependence : none
    //  Author: jiemin lai
    //  Note: HX_SALE_SEND_DATA_TYPE
    /*****************************************************************************/
    PUBLIC BOOLEAN MMISALE_RunSendInfor(void)
    {
    #if defined(TP_LINK_SALES_STATISTICS)
       if(TP_LINK_Sales_Start_Flag_Times()<5)
    #endif   
       {
        #ifdef WIN32
    	char testbuf[]="HTTP/1.1 200 Date: Tue, 19 Feb 2019 10:28:54 GMT Content-Type: application/json;charset=UTF-8 Transfer-Encoding: chunked Connection: close Server: nginx/1.12.1 12 {\"type\":\"success\"}";
    	HxSaleParseDataInfo(testbuf);
        #else
    	MMIAPIPDP_Deactive(MMI_MODULE_SALE);
    	HxSaleActivePDP();
        #endif
       }    
    }
    
    #ifdef HTTPS_SUPPORT
    /*****************************************************************************/
    //  Description : 加密数据成功的回调
    //  Global resource dependence : none
    //  Author: jiemin lai
    //  Note: httpmachine_ptr SSL句柄  data_ptr加密后的数据  data_len加密后的数据长度
    /*****************************************************************************/
    int32 http_SecuritySendDataCllback( void *httpmachine_ptr, uint8 *data_ptr, uint32 data_len)
    {
    
    	SCI_TRACE_LOW("http_SecuritySendDataCllback is run!");
    	
    	if((PNULL == httpmachine_ptr) || (PNULL == data_ptr) || (0 == data_len))
    	{
    		SCI_TRACE_LOW("http_SecuritySendData  parameters fail!");
    		return 0;
    	}
    #if 0
    	BackBuf = SCI_MALLOC(uint8 *, data_len * sizeof(uint8));
    	SCI_MEMCPY(BackBuf, data_ptr, data_len);
    
    	//获取数据
    	HTTP_SslGetRequestData(buf);
    
    	
    	//SSL_DecryptPasser((HX_SALE_SSL_INSTANCE *)httpmachine_ptr->hSSL, buf, strlen(buf));
    	//加密
    	SSL_EncryptPasser((HX_SALE_SSL_INSTANCE *)httpmachine_ptr->hSSL, buf, strlen(buf));
    
    	return_ret = sci_sock_send((HX_SALE_SSL_INSTANCE *)httpmachine_ptr->fd, buf, strlen(buf), 0);
    
    	SCI_TRACE_LOW("http_SecuritySendData send ret = :%d", return_ret);
    #endif
    	//加密成功了就调用发送接口
    	http_Sending(httpmachine_ptr, data_ptr, data_len);
    	//SSL_AsyncMessageProc((HX_SALE_SSL_INSTANCE *)httpmachine_ptr->hSSL, SSL_RECV_MESSAGE_SEND_SUCC);
    		
    }
    
    /*****************************************************************************/
    //  Description : 解密数据成功的回调
    //  Global resource dependence : none
    //  Author: jiemin lai
    //  Note: httpmachine_ptr SSL句柄  data_ptr解密后的数据  data_len解密后的数据长度
    /*****************************************************************************/
    void http_SecurityRecvDataCllback(void  *httpmachine_ptr, uint8 *data_ptr, uint32 data_len)
    {
    
    	SCI_TRACE_LOW("http_SecurityRecvDataCllback is run!");
    	
    	if((PNULL == httpmachine_ptr) || (PNULL == data_ptr) || (0 == data_len))
    	{
    		SCI_TRACE_LOW("http_SecurityRecvData  parameters fail!");
    		return ;
    	}
    
    	
    	http_Receiveing(httpmachine_ptr, data_ptr, data_len);
    	
    }
    
    /*****************************************************************************/
    //  Description : 传递加密解密数据以及握手过程中可能出现的问题
    //  Global resource dependence : none
    //  Author: jiemin lai
    //  Note: void *httpmachine_ptr句柄,  uint32 message_id消息ID
    /*****************************************************************************/
    void http_SecurityPostMessageCllback(void *httpmachine_ptr,  uint32 message_id)
    {
    	SCI_TRACE_LOW("http_SecurityPostMessageCllback is run!");
    	
    	if(PNULL == httpmachine_ptr)
    	{
    		SCI_TRACE_LOW("http_SecurityPostMessage parameters fail");
    		return ;
    	}
    
    	switch (message_id)
    	{
    		//case SECURITY_HANDSHAKE_SUCC:
    		case SSL_SEND_MESSAGE_HANDSHAKE_SUCC:  // 握手成功
    			{
    			 	//http handle this case according to its state
    			 	SCI_TRACE_LOW("http_SecurityPostMessage SSL_SEND_MESSAGE_HANDSHAKE_SUCC");
    			}
    			break;
    			
    		case SSL_SEND_MESSAGE_FAIL:      //发送失败
    			{
    				//http handle this case according to its state
    				SCI_TRACE_LOW("http_SecurityPostMessage SSL_SEND_MESSAGE_FAIL");
    			}
    			break;
    			
    		//case SSL_RECV_MESSAGE_SEND_SUCC:
    			//SSL_EncryptPasser(SSL_HANDLE ssl_handle, uint8 * data_ptr, uint32 len)
    			//break;
    
    		//case SSL_RECV_MESSAGE_RECV_SUCC:  //接收成功
    			//SSL_DecryptPasser((HX_SALE_SSL_INSTANCE *)httpmachine_ptr->hSSL, RecvBuf, RecvDateLenn);
    			//break;
    			
    	    case SSL_SEND_MESSAGE_CLOSE_BY_SERVER:   //服务器发送关闭
    			{
    				SCI_TRACE_LOW("http_SecurityPostMessage SSL_SEND_MESSAGE_CLOSE_BY_SERVER");
    			}
    			break;
    			
    		case SSL_SEND_MESSAGE_CANCLED_BY_USER: // 证书出现问题
    			{
    				//http handle this case according to its state
    				SCI_TRACE_LOW("http_SecurityPostMessage SSL_SEND_MESSAGE_CANCLED_BY_USER");
    			}
    			break;
    			
    		default:
    			SCI_TRACE_LOW("http_SecurityPostMessage default");
    			break;
    	}
    
    }
    
    /*****************************************************************************/
    //  Description : 当证书无法验证时,需要将将需要确认的消息传递给应用协议
    //  Global resource dependence : none
    //  Author: jiemin lai
    //  Note: 
    /*****************************************************************************/
    void http_SecurityShowCertInfoCllback(void *machine_ptr, uint8 *title_ptr, uint8 *info_ptr)
    {
    	SCI_TRACE_LOW("http_SecurityShowCertInfoCllback is run!");
    	if((PNULL == machine_ptr) || (PNULL == title_ptr) || (PNULL == info_ptr))
    	{
    		SCI_TRACE_LOW("http_SecurityShowCertInfo parameters fail");
    		return ;
    	}
    
    	//通知SSL。停止
    	SSL_UserCnfCert(((HX_SALE_SSL_INSTANCE *)machine_ptr)->hSSl , SSL_ASYNC);
    }
    
    /*****************************************************************************/
    //  Description :  建立SSL的安全连接
    //  Global resource dependence : none
    //  Author: jiemin lai
    //  Note: 
    /*****************************************************************************/
    void* httpHandshaking(void* machine_ptr)
    {
    	SSL_CALLBACK_T  astCbFun = {0};
    	struct sci_sockaddr  addr;
        struct sci_hostent  * hostent_date = PNULL;
        uint32 ip = 0;
    	uint32 hostip = 0;
    	uint16 port = SALE_SERVICE_PORT;
    	char *addr_str = NULL;
    
    	SCI_TRACE_LOW("httpHandshaking is run!");
    	astCbFun.decryptout_cb = http_SecurityRecvDataCllback;
    	astCbFun.encryptout_cb = http_SecuritySendDataCllback;
    	astCbFun.postmessage_cb = http_SecurityPostMessageCllback;
    	astCbFun.showcert_cb = http_SecurityShowCertInfoCllback;
    
    	hostent_date = sci_gethostbyname(g_sale_domain);
    	SCI_MEMCPY(&hostip, hostent_date->h_addr_list[0], 4);
        //ntohl(ip);
        ip = ntohl(hostip);
    
       
        
        addr.family = AF_INET;
        //addr.ip_addr = htonl(ip);
        addr.ip_addr = htonl(ip);
        addr.port = htons(port);
        //memset(addr.sa_data, 0, 8 * sizeof(char));
        SCI_MEMSET((void*)addr.sa_data, 0, 8*sizeof(char));
    
    	addr_str = inet_ntoa(addr.ip_addr);
    
    	SSL_AsyncRegCallback(((HX_SALE_SSL_INSTANCE *)machine_ptr)->hSSl, &astCbFun);
    
    	SSL_ProtocolChoose(((HX_SALE_SSL_INSTANCE *)machine_ptr)->hSSl,SSL_PROTOCOLBOTH,SSL_ASYNC);  //两个版本都支持
    	
    	SSL_HandShake(((HX_SALE_SSL_INSTANCE *)machine_ptr)->hSSl, addr_str, SALE_SERVICE_PORT, SSL_ASYNC);
    }
    
    
    /*****************************************************************************/
    //  Description :  发送数据
    //  Global resource dependence : none
    //  Author: jiemin lai
    //  Note: 
    /*****************************************************************************/
    void* http_Receiveing(void  *httpmachine_ptr, uint8 *data_ptr, uint32 data_len)
    {
    
    	SCI_TRACE_LOW("http_Receiveing is run!");
    	if((PNULL == httpmachine_ptr) || (PNULL == data_ptr) || (0 == data_len))
    	{	
    		SCI_TRACE_LOW("http_Receiveing parameters fail");
    		return PNULL ;
    	}
    
    	SCI_TRACE_LOW("http_Receiveing data_ptr:%s", data_ptr);
    	
    	HxSaleParseDataInfo(data_ptr);
    }
    
    /*****************************************************************************/
    //  Description :  接收数据
    //  Global resource dependence : none
    //  Author: jiemin lai
    //  Note: 
    /*****************************************************************************/
    void*  http_Sending(void  *httpmachine_ptr, uint8 *data_ptr, uint32 data_len)
    {
    	int return_ret = 0;
    
    	SCI_TRACE_LOW("http_Sending is run!");
    	if((PNULL == httpmachine_ptr) || (PNULL == data_ptr) || (0 == data_len))
    	{	
    		SCI_TRACE_LOW("http_Sending parameters fail");
    		return PNULL ;
    	}
    	
    	return_ret = sci_sock_send(((HX_SALE_SSL_INSTANCE *)httpmachine_ptr)->fd, data_ptr, data_len, 0);
    	SCI_TRACE_LOW("http_SecuritySendData send ret = :%d", return_ret);
    
    	if(return_ret > 0)
    	{
    		//发送成功,给上层发送消息,释放SSL的资源
    		SSL_AsyncMessageProc(((HX_SALE_SSL_INSTANCE *)httpmachine_ptr)->hSSl, SSL_RECV_MESSAGE_SEND_SUCC, data_len);
    	}
    }
    
    /*****************************************************************************/
    //  Description :  创建SSL状态机
    //  Global resource dependence : none
    //  Author: jiemin lai
    //  Note: 
    /*****************************************************************************/
    void*  http_CreateSSL(int socket_id)
    {
        SCI_TRACE_LOW("http_Sending is run!");
        SslInstance = (HX_SALE_SSL_INSTANCE *)malloc(sizeof(HX_SALE_SSL_INSTANCE));
       if (PNULL == SslInstance)
       {
       	  return NULL;
       }
       
       SCI_MEMSET(SslInstance,0,sizeof(HX_SALE_SSL_INSTANCE));
       
       SslInstance->fd = socket_id;
       SslInstance->hSSl = SSL_Create(SslInstance, socket_id, SSL_ASYNC);
    
       return SslInstance;
    }
    
    /*****************************************************************************/
    //  Description :   后去需要加密的发送数据
    //  Global resource dependence : none
    //  Author: jiemin lai
    //  Note: 
    /*****************************************************************************/
    void  HTTP_SslGetRequestData(char* RequestData)
    {
    	char json[256] = {0};
            HX_SALE_SEND_DATA_TYPE CustomBuffer = {0};
    
    	SCI_TRACE_LOW("HTTP_SslGetRequestData is run!");
    	MMISALE_GetCustomInfo(&CustomBuffer);
    
    	if(PNULL == RequestData)
    	{
    		SCI_TRACE_LOW("HTTP_SslGetRequestData parameter fail!");
    		return;
    	}
    
    	sprintf(RequestData,"POST https://%s/fota-open-ota/phone/rom/active HTTP/1.1\r\nHost: %s\r\nConnection: close\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: %d\r\nAccept: */*\r\n\r\n%s\r\n", g_sale_domain, g_sale_domain, strlen(json), json);
    }
    
    /*****************************************************************************/
    //  Description :   SSL初始化
    //  Global resource dependence : none
    //  Author: jiemin lai
    //  Note: 
    /*****************************************************************************/
    void  HTTP_SslInit(int socket_id)
    {
    	SCI_TRACE_LOW("HTTP_SslInit is run!");
    	http_CreateSSL(socket_id);
    	
    	httpHandshaking((void *)SslInstance);
    }
    
    #endif

    四、HTTPS调试遇到的问题

     1、展讯 SC6531E\SC7703平台只支持SSL 3.0 TLS1.0版本。如果服务器的加密版本高于此,在在HTTP的四次握手完成之后的SSL握手中,将会拒绝我们的握手请求。报文如下(Wireshark分析)

    2、HTTPS请求被拒绝

    HTTPS的端口号默认是443、HTTP是80,在调试完HTTP之后切换HTTPS时,由于没有修改端口号,导致握手请求在发起第一次握手时就被拒绝。实在CSDN的大佬帖子上看到的,其中一个原因就是端口号不对。找不到帖子地址了。

     

     

    展开全文
  • 展讯6531平台socket

    千次阅读 2017-12-10 14:52:29
    最近公司接到一个新项目,搞展讯6531E平台的天气预报,基本流程其实也简单,就是手机端发送一个请求到服务器,然后服务器把数据发送回来,手机端接收并且解析就可以了,由于之前没有做过展讯socket相关的东西,网上...

    最近公司接到一个新项目,搞展讯6531E平台的天气预报,基本流程其实也简单,就是手机端发送一个请求到服务器,然后服务器把数据发送回来,手机端接收并且解析就可以了,由于之前没有做过展讯socket相关的东西,网上能搜索到的资源非常有限,所以在此做个总结,非常欢迎展友给我指出其中的错误以及纰漏。

    功能基本流程如下:

    1、激活PDP、拿到net_id

    2、socket 通信

    3、关闭socket

    4、detach PDP

     

    说明:这个流程有很大的局限性,因为手机端跟服务器端只有请求跟相应请求两个交互,再无其他交互,所以设计的很简单,但是socket的操作六层大致如此

     

    1、激活PDP

    //TEST cmnet 回调函数
    LOCAL void HandlePDPTESTMsg(MMIPDP_CNF_INFO_T *msg_ptr)
    {
            if(PNULL == msg_ptr)
               {
                    return;
            }
            SCI_TRACE_LOW("[MMIMMS]:HandlePDPTESTMsg msg_id=%d",msg_ptr->msg_id);
            switch(msg_ptr->msg_id)
            {
            case MMIPDP_ACTIVE_CNF:
                if(msg_ptr->result != 0)
                {
                    //记得把else里面重复激活PDP的定时器关闭
                    taiodu_net_id = msg_ptr->nsapi;   //这个是net_id 知名socket使用的链路
                    SCI_TRACE_LOW("+++++++HandlePDPTESTMsg,case MMIPDP_ACTIVE_CNF,taiodu_net_id :%ld",taiodu_net_id);        
                    TEST_OpenSocket();   //建立sock,开始搞事
                }else
                {
                    //这里再开一个定时器,继续调用openTESTNet,一直到这个回调接收到MMIPDP_ACTIVE_CNF,并且msg_ptr->result != 0
                }
                break;
                // MMK_PostMsg(MAIN_IDLE_WIN_ID, MSG_TEST_NETLINK_SUCCESS, PNULL,0); //发送网络激活成功 break;
            case MMIPDP_DEACTIVE_CNF:
                    break;
            case MMIPDP_DEACTIVE_IND:
                    SCI_TRACE_LOW("+++++++HandlePDPMsg: MMIPDP_DEACTIVE_IND");
                    //MMK_PostMsg(MAIN_IDLE_WIN_ID, MSG_TEST_NETLINK_DISCONNECT, PNULL,0); //发送网络断开 break;
            default:
                    break;
            }
            //SCI_FREE(msg_ptr);
    }
    //打开cmnet
    BOOLEAN openTESTNet(void)
    {
            MMIPDP_ACTIVE_INFO_T active_info = {0};
            char apn_ptr[10] = {0};//apn string
            BOOLEAN ret = FALSE;
            strcpy(apn_ptr,"cmnet");
            if (MMIPHONE_IsSimAvailable(0))//判断飞行模式
            {
                    SCI_TRACE_LOW("openTESTNet");
    
                    active_info.dual_sys = 0;
    
                    //注意这个auth_type,6531E的代码需要更新过新的网络参数工具
    
                    active_info.auth_type = 1;
                    active_info.priority = 3;
                    active_info.app_handler = MMI_MODULE_COMMON;
                    active_info.handle_msg_callback = HandlePDPTESTMsg;
                    active_info.apn_ptr = apn_ptr;
                    active_info.ps_service_rat = MN_TD_PREFER;        
                    MNGPRS_ReadStorageExtReqQosEx(active_info.dual_sys,MN_GPRS_STORAGE_ALL,BROWSER_E,&active_info.qos_info);                
                    ret =MMIAPIPDP_Active(&active_info);
            }
            SCI_TRACE_LOW("openTESTNet :MMIAPIPDP_Active = %d!", ret);
            return ret;
    }
    
    



     

    2、socket通信

      新建线程处理socket时间

    PUBLIC uint32 HxWeather_CreateTask(void)
    {
        if (0 != s_weather_task_id)
        {
            //之前创建的task还没有关闭!
            return 0;
        }
    
        s_weather_task_id = SCI_CreateThread( 
                            "T_WEATHER", 
                            "Q_WEATHER", 
                            Weather_TaskHandle, 
                            0, 
                            0, 
                            WEATHER_STACK_SIZE, 
                            WEATHER_STACK_QUEUE_NUM, 
    #ifdef WIN32
                            30,
    #else
                            PRI_APP_WEATHER_TASK, 
    #endif
                            SCI_PREEMPT, 
                            SCI_AUTO_START);
        
        SCI_TRACE_LOW(" HxWeather_CreateTask    create task ID %d", s_weather_task_id);
        return s_weather_task_id;
    }
    
    LOCAL void Weather_TaskHandle(uint32 argc, void * argv)
    {
        xSignalHeaderRec                  *signal_ptr = PNULL;
        uint32                      sock_id = 0;
        static   BOOLEAN            is_on_free= FALSE;
        BLOCK_ID tsak_id = SCI_IdentifyThread();  // 获取当前taskID
    
        
     
        for(;;)
        {
            SCI_TRACE_LOW("Weather_TaskHandle Entry for(;;) !");
            
            signal_ptr = (xSignalHeaderRec *)SCI_GetSignal(tsak_id);
    
            SCI_TRACE_LOW("Weather_TaskHandle sci_sock_select sig_ptr->SignalCode = %d",signal_ptr->SignalCode);
            SCI_TRACE_LOW("Weather_TaskHandle sci_sock_select sig_ptr->SignalCode = %d",signal_ptr->SignalCode);
            SCI_TRACE_LOW("Weather_TaskHandle sci_sock_select sig_ptr->SignalCode = %d",signal_ptr->SignalCode);
            SCI_TRACE_LOW("Weather_TaskHandle sci_sock_select sig_ptr->SignalCode = %d",signal_ptr->SignalCode);
            if (PNULL != signal_ptr)
            {
                switch(signal_ptr->SignalCode)
                {
                    case SOCKET_READ_EVENT_IND:    //
                        //可读
                       if(HxWeatherRecvData(s_cosket_id))
                        {
                            //解析数据
                            
                            //is_continue = FALSE;
                            //SCI_ThreadExit();
                        }else
                        {
                                //接收错误会返回到这里
                                HxWeatherUpdateSetErrorType(HX_WEATHER_UPDATE_ERROR_RECV_DATA);
                                 //is_continue = FALSE;
                                 //SCI_ThreadExit();
                        }
                        break;
    
    
                    case SOCKET_CONNECTION_CLOSE_EVENT_IND:
                        //is_continue = FALSE;  //结束循环
                        SCI_TRACE_LOW("Weather_TaskHandle   exit sur thread task!");
                        s_weather_task_id = 0;
                        SCI_ThreadExit();
                        //关闭
                        break;
    
                    case SOCKET_WRITE_EVENT_IND:
                        memset(G_Weather_Dta, 0, G_Data_Buffer);
                        SCI_TRACE_LOW("Weather_TaskHandle  memset G_Weather_Dta 0 !");
                        HxWeatherSendRequest(s_cosket_id);
                        //连接
                        break;
    
                        default :
                            break;
                } 
            }else
            {
                    SCI_TRACE_LOW("Weather_TaskHandle  SCI_GetSignal  ptr is NULL!");
            }
    #if 0
            if (!s_weather_task_id)
            {
                SCI_TRACE_LOW("Weather_TaskHandle   exit sur thread task for ");
                SCI_ThreadExit();
            }
    #endif
        }
    
    }

    打开socket

    LOCAL int HxWeather_OpenSocket(void)
    {
        int32 socket_id = 0;
        int return_ret = 0;
        int error = 0;
        struct sci_sockaddr  addr;
        //struct sci_sockaddrext connect_add;
        struct sci_hostent  * hostent_date = PNULL;
        uint32 ip = 0;
        uint32 hostip = 0;
        int rept_connect = 0;
        //int32 host_ip = 0;
        char addr_buf[128] = {0};
        uint16 port = 10620;
        sci_fd_set writefds;
        BLOCK_ID tsak_id = s_weather_task_id;//为socket事件新建的线程,由他来检测socket的动态,如果使用主线程,会导致主线程阻塞,系统崩溃
        BOOLEAN is_continue = FALSE; 
        xSignalHeaderRec* sig_ptr = NULL;    //task signal
    
        //创建socket
        
        socket_id = sci_sock_socket(AF_INET, SOCK_STREAM, 0, s_weather_net_id);
    
        s_cosket_id =  socket_id;
    
        SCI_TRACE_LOW("HxWeather_OpenSocket socket_id = %d",socket_id);
        SCI_TRACE_LOW("HxWeather_OpenSocket socket_id = %d",socket_id);
        SCI_TRACE_LOW("HxWeather_OpenSocket s_weather_net_id = %d",s_weather_net_id);
        SCI_TRACE_LOW("HxWeather_OpenSocket s_weather_net_id = %d",s_weather_net_id);
    
        if(socket_id == TCPIP_SOCKET_INVALID)
       {
            HxWeatherUpdateSetErrorType(HX_WEATHER_UPDATE_ERROR_SOCKET_CREATE);
            return 0;
        }
    
    //设置属性
        error = sci_sock_setsockopt(socket_id, SO_NBIO, PNULL);//设置socket 为非阻塞模式
        SCI_TRACE_LOW("HxWeather_OpenSocket sci_sock_setsockopt error = %d",error);
        SCI_TRACE_LOW("HxWeather_OpenSocket sci_sock_setsockopt error = %d",error);
        if(-1 == error )//失败
        {
            error = sci_sock_errno(socket_id);
    
            SCI_TRACE_LOW("HxWeather_OpenSocket sci_sock_errno error = %x",error);
            SCI_TRACE_LOW("HxWeather_OpenSocket sci_sock_errno error = %x",error);
            HxWeatherUpdateSetErrorType(HX_WEATHER_UPDATE_ERROR_SOCKET_CREATE);
            sci_sock_socketclose(socket_id);
            return 0;
        }
    
    #if 0
        error = sci_sock_setsockopt(socket_id, SS_ASYNC, NULL);
    
        if(-1 == return_ret)
        {
            error = sci_sock_errno(socket_id);
            sci_sock_socketclose(socket_id);
            return 0;
        }
    #endif
    
        //绑定
        //return_ret = sci_parse_host((char *)g_hxweather_domain,&ip,0);
       // return_ret = sci_parse_host_ext((char *)g_hxweather_domain, &ip, 0, s_weather_net_id);
        hostent_date = sci_gethostbyname(g_hxweather_domain);
        //SCI_TRACE_LOW("HxWeather_OpenSocket sci_parse_host_ext ip = %x",ip);
        //SCI_TRACE_LOW("HxWeather_OpenSocket sci_parse_host_ext ip = %x",ip);
        //SCI_TRACE_LOW("HxWeather_OpenSocket sci_parse_host_ext return_ret = %d",return_ret);
        //SCI_TRACE_LOW("HxWeather_OpenSocket sci_parse_host_ext return_ret = %d",return_ret);
        SCI_TRACE_LOW("HxWeather_OpenSocket sci_parse_host_ext hostent_date = %x",hostent_date);
        SCI_TRACE_LOW("HxWeather_OpenSocket sci_parse_host_ext hostent_date = %x",hostent_date);
        //SCI_TRACE_LOW("HxWeather_OpenSocket sci_parse_host_ext IP = %s",*(hostent_date->h_addr_list));
        //SCI_TRACE_LOW("HxWeather_OpenSocket sci_parse_host_ext IP = %s",*(hostent_date->h_addr_list));
        
        if(NULL == hostent_date) //获取IP addr失败
        {
            HxWeatherUpdateSetErrorType(HX_WEATHER_UPDATE_ERROR_GET_HOSTNAME);
            sci_sock_socketclose(socket_id);
           return 0;
        }
    
        SCI_MEMCPY(&hostip, hostent_date->h_addr_list[0], 4);
        SCI_TRACE_LOW("HxWeather_OpenSocket sci_parse_host_ext hostip = %d",hostip);
        SCI_TRACE_LOW("HxWeather_OpenSocket sci_parse_host_ext hostip = %d",hostip);
        //ntohl(ip);
        ip = ntohl(hostip);
    
        SCI_TRACE_LOW("HxWeather_OpenSocket sci_parse_host_ext ip = %x",ip);
        SCI_TRACE_LOW("HxWeather_OpenSocket sci_parse_host_ext ip = %x",ip);
        SCI_TRACE_LOW("HxWeather_OpenSocket sci_parse_host_ext return_ret = %d",return_ret);
        SCI_TRACE_LOW("HxWeather_OpenSocket sci_parse_host_ext return_ret = %d",return_ret);
        SCI_TRACE_LOW("HxWeather_OpenSocket sci_parse_host_ext hostent_date->h_addr_list = %s",hostent_date->h_addr_list[0]);
        SCI_TRACE_LOW("HxWeather_OpenSocket sci_parse_host_ext hostent_date->h_addr_list = %s",hostent_date->h_addr_list[0]);
        
        addr.family = AF_INET;
        //addr.ip_addr = htonl(ip);
        addr.ip_addr = htonl(ip);
        addr.port = htons(port);
        //memset(addr.sa_data, 0, 8 * sizeof(char));
        SCI_MEMSET((void*)addr.sa_data, 0, 8*sizeof(char));
        //sci_sock_bind(socket_id, &addr, sizeof(struct sci_sockaddr));
    
        //连接
        //非阻塞方式需要等待连接成功
        return_ret = sci_sock_connect(socket_id, &addr, sizeof(struct sci_sockaddr));
        if(-1 == return_ret)
        {
            for(rept_connect = 0; rept_connect < HXWEATHER_REPT_CONNECT_NUMBER; rept_connect ++)
            {
                //取得错误的原因
                error = sci_sock_errno(socket_id);
                if(error != EINPROGRESS)   //不是这个错误号的都需要关闭socket,属于严重的错误
                {
                    HxWeatherUpdateSetErrorType(HX_WEATHER_UPDATE_ERROR_SOCK_CONNECT);
                    sci_sock_socketclose(socket_id);
                    return 0;
                }
                SCI_SLEEP(HXWEATHER_REPT_CONNECT_TIME);   // 1S一次重连
                return_ret = sci_sock_connect(socket_id, &addr, sizeof(struct sci_sockaddr));
                if(0 == return_ret)   // 重连成功,跳出循环 
                {
                     break;
                }
            }
            //获取错误的原因
            //error = sci_sock_errno(socket_id);
            SCI_TRACE_LOW("HxWeather_OpenSocket sci_sock_connect eror_num = %d",error);
        }
        
        SCI_TRACE_LOW("HxWeather_OpenSocket sci_sock_connect return_ret = %d",return_ret);
        SCI_TRACE_LOW("HxWeather_OpenSocket sci_sock_connect return_ret = %d",return_ret);
         SCI_TRACE_LOW("HxWeather_OpenSocket sci_parse_host_ext addr.ip_addr = %x",addr.ip_addr);
        SCI_TRACE_LOW("HxWeather_OpenSocket sci_parse_host_ext addr.ip_addr = %x",addr.ip_addr);
    
        //监听
        //socket = s_mr_sockets[param].s;
        SCI_FD_ZERO (&writefds);
        SCI_FD_SET((long)socket_id, &writefds);
        //sci_sock_select(sci_fd_set * in, sci_fd_set * out, sci_fd_set * ex, long tv)
        return_ret = sci_sock_select(NULL, &writefds, NULL, 0); 
        SCI_TRACE_LOW("HxWeather_OpenSocket sci_sock_select return_ret = %d",return_ret);
        SCI_TRACE_LOW("HxWeather_OpenSocket sci_sock_select return_ret = %d",return_ret);
    
        //注册event消息
        SCI_TRACE_LOW("HxWeather_OpenSocket  sci_sock_asyncselect task ID:%d", s_weather_task_id);
        return_ret = sci_sock_asyncselect(socket_id, s_weather_task_id, AS_CONNECT|AS_READ|AS_WRITE|AS_CLOSE);
         SCI_TRACE_LOW("HxWeather_OpenSocket sci_sock_select sci_sock_asyncselect = %d",return_ret);
        SCI_TRACE_LOW("HxWeather_OpenSocket sci_sock_select sci_sock_asyncselect = %d",return_ret);
        if(return_ret == -1)
        {
            sci_sock_errno(socket_id);
        }
    
        is_continue = TRUE;
        
    
        //前面connect连接成功,表明可以发送数据了....
        HxWeatherSendRequest(socket_id);   //有可能发送过程中,buf不足,发送失败,在下面的task里等待WRITE消息,继续发送
    
        //MMIAPIPDP_Deactive(MMI_MODULE_HXWEATHER);
        //sci_sock_connect(TCPIP_SOCKET_T so, struct sci_sockaddrext * addr_ptr, int addr_len)
        return socket_id;
    }

     

    展开全文
  • <div><p>This PR addresses JMC-6531 <a href="https://bugs.openjdk.java.net/browse/JMC-6531">[0], in which the flame chart view displays nothing in Windows. <p>tl;dr: the proposed solution uses a fork ...
  • m running has a few users who seem to think they have accented characters in their email address addr-spec, e.g. rémy.fr. This requires client support for the SMTPUTF8 extension. <p>RFC 6530/1/2 is ...
  • <p><img alt="Peek 2019-11-15 03-45" src="https://img-blog.csdnimg.cn/img_convert/bc01c6af6e6531e051924825f6f069a9.gif" /></p><p>该提问来源于开源项目:openshift/console</p></div>
  • <p><img alt="grafik" src="https://user-images.githubusercontent.com/42890695/94272216-0a5d4d80-ff43-11ea-8b12-04cf6531e954.png" /></p> <p>In dem Feld gleich neben der Systemvariable kann ich entweder ...
  • <div><p>This happens when testing code of #336 on HW-based node, using <code>make test_e2e There will be a problem described in #317: after umount returns in pmem-csi node, file system remains mounted...
  • Release 2013.11

    2020-12-02 07:15:09
    <p>I am preparing to tag https://github.com/swcarpentry/bc/commit/aa87704a1920cac9fa6531e0f5d91470d626d630 as 2013.11</p> <p>So far, I've accumulated the following list of 54 authors: - Amanda ...
  • "071c3b5f969bed1d1e2ee4b6531e4444.jpg" ] }, { "gallery_id": "3", "title": "Sports Day", "description": "", "galleryImagesCount": 4, "gallery": [ "f0ba574fd46a01ff5a41855a97c710ca.jpg", "1d...
  • <div><p>Bumps <a href="https://github.com/facebook/jest">jest</a> from 25.1.0 to 25.2.3. Release notes <p><em>Sourced from <a href="https://github.com/facebook/jest/releases">jest'...
  • <div><p>Bumps <a href="https://github.com/facebook/jest/tree/HEAD/packages/jest-runner">jest-runner</a> from 25.1.0 to 25.2.3. Release notes <p><em>Sourced from ...
  • <div><p>Bumps <a href="https://github.com/facebook/jest/tree/HEAD/packages/jest-config">jest-config</a> from 25.1.0 to 25.2.3. Release notes <p><em>Sourced from ...
  • <div><p>Bumps <a href="https://github.com/facebook/jest/tree/HEAD/packages/babel-preset-jest">babel-preset-jest</a> from 25.1.0 to 25.2.1. Release notes <p><em>Sourced from ...
  • fix EMAN2-2.21a (WIP)

    2020-12-09 05:49:25
    <div><p>(created using <code>eb --new-pr) depends on PR ~~#6531~~</p><p>该提问来源于开源项目:easybuilders/easybuild-easyconfigs</p></div>
  • windows xshell 跳板机登陆

    千次阅读 2017-08-28 09:02:49
    2E60089C-923A-4888-BE53-CEB13E46E869.png 2- 设置用户身份验证,秘钥验证 A71075EB-A59C-4F73-A095-C4B8C502B395.png 3.设置登录后跳转 3A3D6531-10EF-4C8A-86EF-ACAC4267A106.png 4.设置跳板机...

    1- 设置跳板机


    2E60089C-923A-4888-BE53-CEB13E46E869.png

    2- 设置用户身份验证,秘钥验证


    A71075EB-A59C-4F73-A095-C4B8C502B395.png

    3.设置登录后跳转


    3A3D6531-10EF-4C8A-86EF-ACAC4267A106.png

    4.设置跳板机代理


    08C06592-C5D5-4262-84B7-31C606E99A41.png


    作者:xiaopang
    链接:http://www.jianshu.com/p/b4bf21ade6df
    來源:简书
    著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
    展开全文
  • Help on what to do next!

    2020-12-09 05:09:19
    0000950 2e2e 7c2e 300a 3030 3030 6531 2030 3020 0000960 2030 3030 3020 2030 3030 3020 2030 3030 0000970 3020 2030 3030 2020 3030 3020 2030 3030 0000980 3020 2030 3030 3020 2030 3030 3020 2030 0000990 ...
  • issue with resultDir

    2020-12-08 23:37:43
    src/modules/users/e2e/users.e2e-spec.ts PASS src/modules/users/users.controller.spec.ts PASS src/modules/users/users.component.spec.ts <p>Test Suites: 3 passed, 3 total Tests: 16 passed, 16 total ...
  • 蓝色 简单 [img]/upload/attachment/96471/af9a837c-6531-35d7-8b0a-61e851dfe5cc.jpg[/img]
  • <div><p>Also I think we should bump the version since the AR/AS requirements ... 4.0.0</code> due to 50a8298d6531f436de6d96a5968183e5c6b009f9 .</p><p>该提问来源于开源项目:mbleigh/seed-fu</p></div>
  • <div><h3>Current Behaviour (for problems) <p>Data Curator throws error ('unable to parse data. there could be a problem with data format') when loading this CSV file: ... <h3>Expected Behaviour ...
  • <p><img alt="Screenshot from 2020-12-24 05-42-09" src="https://img-blog.csdnimg.cn/img_convert/f38e6531ff48a30bfcd79bf374ad3edc.png" /></p><p>该提问来源于开源项目:fossasia/open-event-frontend...
  • ERP力振双拳--PDM、SCM将大显身手http://www.226e.net/article/13/Article6531_1.htm企业资源计划(ERP)是当今热门的企业管理系统,但是如何让ERP系统顺利实施?如何配合企业...
  • <div><p>As is defined in RFC 5322 (http://tools.ietf.org/html/rfc5322) and RFC 6531 (http://tools.ietf.org/html/rfc6531) some especial chars are allowed in email addresses - [x] Characters !#$%&&#...
  • 546f74616c2e5761722e524f4d452e49492e48616e6e6962616c2e61742e5468652e47617465732e696e636c2e444c432e4d756c7469322e762e312e31312e302e537465616d2d526970202d204f726967696e73' of dcfbcba77e08fa56d3f89...
  • <p><img width="730" alt="screen shot 2016-07-18 at 4 38 16 pm" src="https://cloud.githubusercontent.com/assets/62331/16911211/684096d4-4d07-11e6-8007-95a6531b281e.png" /></p><p>该提问来源于开源项目&#...
  • 转一篇关于神经网络的小品文   ...amp;mid=401758390&amp;idx=1&...sn=a870201b307b6531abfe9c571461876e&amp;scene=1&amp;srcid=0122t2d7CyeurEFwtlp2ya3k&amp;pass_ticket=5...
  • https://etherscan.io/token/0xA6FA6531acDf1f9F96EDdD66a0F9481E35c2e42A</p> </li><li> <p>Additional technical requirements (yes/no) No. </li><li> <p>Initial coin offering (yes/no) No. </li></ol>该提问...

空空如也

空空如也

1 2 3 4 5 ... 7
收藏数 126
精华内容 50
关键字:

展讯6531e