ImageVerifierCode 换一换
格式:PPT , 页数:60 ,大小:907.50KB ,
资源ID:580728      下载积分:10 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.docduoduo.com/d-580728.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录   微博登录 

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(mtk-socket数据存储联网.ppt)为本站会员(天天快乐)主动上传,道客多多仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知道客多多(发送邮件至docduoduo@163.com或直接QQ联系客服),我们立即给予删除!

mtk-socket数据存储联网.ppt

1、Network Service,Yao.wen,2018/4/12,Copyright MediaTek Inc. All rights reserved.,1,Agenda,CBM OverviewCBM OverviewCBM APIsSample CodeSocket OverviewSocket OverviewSocket APIsSample CodeWPS OverviewWPS OverviewWPS MessagesSample Code,CBM,2018/4/12,Copyright MediaTek Inc. All rights reserved.,3,CBM Over

2、view,CBM provides a set of APIs that all internet applications could register / deregister app id and encode / decode app_id, sim info from/into Data account ID. These APIs are thread-safed, they could be called by any task.,2018/4/12,Copyright MediaTek Inc. All rights reserved.,4,Common Data Accoun

3、t Selecting Screen,mmi_dtcnt_select_account_option_with_id() will launch this screen,When user select an account, application will get the selected account id from callback function,2018/4/12,Copyright MediaTek Inc. All rights reserved.,5,CBM APIs,2018/4/12,Copyright MediaTek Inc. All rights reserve

4、d.,6,CBM APIs,2018/4/12,Copyright MediaTek Inc. All rights reserved.,7,Coding Guide,Register app_idg_app_id = cbm_register_app_id(APP_STR_ID, APP_ICON_ID); /* Register app_id */Launch Data Account Screenmmi_dtcnt_select_account_option_with_id(data_account_callback, /* Callback Functions */MENU_ID_AP

5、P, /* Menu ID */DATA_ACCOUNT_BEARER_GPRS | DATA_ACCOUNT_BEARER_WIFI, /* Bearer */0, /* DTCNT_SELECT_SIM: Dual SIM supported, 0 : dont support dual SIM*/g_app_id, /* app_id from step 1 */0); /* Default selected account in MMI screen */data_account_callback (U32 index) /* index user selected */mmi_dtc

6、nt_get_account_name(index, buf, len); /* Account Name for Display */g_data_account_id = index;Create Socket and Make Connectionsoc_create(., g_data_account_id); /* Create socket and make connections */,Socket,2018/4/12,Copyright MediaTek Inc. All rights reserved.,9,The Socket module provides a Socke

7、t API for applications, e.g., WAP, Email, etc. The Socket API consists of several function calls. Each function is implemented in the way of thread-safe and reentrant. Socket API is largely based on Berkeley Socket API.,Socket Overview,2018/4/12,Copyright MediaTek Inc. All rights reserved.,10,Socket

8、 Overview,LayeringSocket Applications (e.g., WAP, Email)Socket Layer (SOC task)Protocol Layer (TCPIP task: TCP, UDP, IP, ICMP, ARP)Bearer Layer (PPP, TCM, WNDRV)CBM (Central Bearer Management),WAP,SOC,TCPIP,PPP,TCM,WNDRV,Email,CBM,2018/4/12,Copyright MediaTek Inc. All rights reserved.,11,Socket Mode

9、,Socket blocking (default) modeSocket non-blocking mode Non-blocking + Asynchronous notification mode,2018/4/12,Copyright MediaTek Inc. All rights reserved.,12,Blocking mode,2018/4/12,Copyright MediaTek Inc. All rights reserved.,13,Non-blocking mode,2018/4/12,Copyright MediaTek Inc. All rights reser

10、ved.,14,Asynchronous notification mode,2018/4/12,Copyright MediaTek Inc. All rights reserved.,15,SOC APP SAP,SOC,APP,APP_SOC_GET_HOST_BY_NAME_INDAPP_SOC_GET_HOST_BY_ADDR_INDAPP_SOC_NOTIFY_IND,soc_create, soc_bind,soc_connectsoc_send, soc_sendtosoc_recv, soc_recvfromsoc_getsockopt, soc_setsockoptsoc_

11、gethostbyname, soc_gethostbyname2soc_gethostbyaddrsoc_get_account_localipsoc_getsockaddrsoc_get_last_errorsoc_close,2018/4/12,Copyright MediaTek Inc. All rights reserved.,16,Message,APP_SOC_GET_HOST_BY_NAME_IND APP_SOC_GET_HOST_BY_ADDR_IND APP_SOC_NOTIFY_IND,2018/4/12,Copyright MediaTek Inc. All rig

12、hts reserved.,17,Primitives,APP_SOC_GET_HOST_BY_NAME_INDResponse of soc_gethostbyname()Fields:addr : returned IP addressaddr_len: returned IP address lengthaccess_id: set in soc_gethostbyname(),APP_SOC_GET_HOST_BY_NAME_INDAPP_SOC_GET_HOST_BY_ADDR_INDAPP_SOC_NOTIFY_IND,2018/4/12,Copyright MediaTek In

13、c. All rights reserved.,18,Primitives,APP_SOC_GET_HOST_BY_ADDR_INDResponse of soc_gethostbyaddr()Fields:name: returned domain name (null terminated)access_id: set in soc_gethostbyaddr(),APP_SOC_GET_HOST_BY_NAME_INDAPP_SOC_GET_HOST_BY_ADDR_INDAPP_SOC_NOTIFY_IND,2018/4/12,Copyright MediaTek Inc. All r

14、ights reserved.,19,Primitives,APP_SOC_NOTIFY_INDUsed to give notifications of network eventsFieldsevent_type: SOC_READNotify to read SOC_WRITENotify to write SOC_ACCEPTNotify to accept SOC_CONNECT Notify to connect SOC_CLOSENotify to closeresult: Indicate CONNECT succeed or noterror_cause,APP_SOC_GE

15、T_HOST_BY_NAME_INDAPP_SOC_GET_HOST_BY_ADDR_INDAPP_SOC_NOTIFY_IND,2018/4/12,Copyright MediaTek Inc. All rights reserved.,20,Functions,soc_createTo create a socketFields:domain:Currently, only PF_INET supported type: SOCK_STREAM/SOCK_DGRAMprotocol:Shall set to zeromod_id:MOD_GISnwk_account_id:Network

16、account idReturn:=0socket_id0errorInfo:Blocking,soc_create, soc_bindsoc_connectsoc_send, soc_sendtosoc_recv, soc_recvfromsoc_setsockopt/soc_getsockoptsoc_gethostbynamesoc_gethostbyname2soc_get_last_errorsoc_get_account_localipsoc_ip_check, soc_close,2018/4/12,Copyright MediaTek Inc. All rights reser

17、ved.,21,Functions,soc_bindTo bind a local ip address to a socketFields:s: socket_idaddr:local ip address, portReturn:0:success0number of bytes sentSOC_WOULDBLOCK in progressothersfail,soc_create, soc_bindsoc_connectsoc_send, soc_sendtosoc_recv, soc_recvfromsoc_setsockopt/soc_getsockoptsoc_gethostbyn

18、amesoc_gethostbyname2soc_get_last_errorsoc_get_account_localipsoc_ip_check, soc_close,2018/4/12,Copyright MediaTek Inc. All rights reserved.,24,Functions,soc_recv, soc_recvfromTo receive data (and return the source address)Fields:s: socket_idbuf:buffer pointer to datalen:length of buffer*fromaddr:ip

19、 address, port (only for soc_recvfrom)Returns:0number of bytes receivedSOC_WOULDBLOCK in progressothersfailInfo:Need to call iteratively till returns SOC_WOULDBLOCK,soc_create, soc_bindsoc_connectsoc_send, soc_sendtosoc_recv, soc_recvfromsoc_setsockopt/soc_getsockoptsoc_gethostbynamesoc_gethostbynam

20、e2soc_get_last_errorsoc_get_account_localipsoc_ip_check, soc_close,2018/4/12,Copyright MediaTek Inc. All rights reserved.,25,Functions,soc_setsockopt/soc_getsockoptTo set (get) options on sockets.Fields:s: socket_idoption:option_type (soc_option_enum)val:option valuevalsize:size of the option valueR

21、eturns:0success0fail,soc_create, soc_bindsoc_connectsoc_send, soc_sendtosoc_recv, soc_recvfromsoc_setsockopt/soc_getsockoptsoc_gethostbynamesoc_gethostbyname2soc_get_last_errorsoc_get_account_localipsoc_ip_check, soc_close,2018/4/12,Copyright MediaTek Inc. All rights reserved.,26,Socket Options,SOC_

22、NBIOSet to non-blocking modeSOC_ASYNCSpecify the events application wants to receive.SOC_READ/SOC_WRITE/SOC_CONNECT/SOC_CLOSESOC_UDP_ANY_FPORTFor a connected UDP socket, those packets from the same remote address but different port will also be accepted.,soc_create, soc_bindsoc_connectsoc_send, soc_

23、sendtosoc_recv, soc_recvfromsoc_setsockopt/soc_getsockoptsoc_gethostbynamesoc_gethostbyname2soc_close_nwk_accountsoc_close_nwk_account_by_idsoc_get_last_errorsoc_get_account_localipsoc_ip_check, soc_close,2018/4/12,Copyright MediaTek Inc. All rights reserved.,27,Functions,soc_gethostbynameTo get ip

24、address by giving domain nameFields:is_blocking only non-blocking supportedmod_idMOD_GISrequest_idto distinguish different DNS requestdomain_name*addr/ *addr_lenreturned ip address and lengthaccess_idembeded in GET_HOST_BY_NAME_INDnwk_account_idnetwork account idReturns:0successSOC_WOULDBLOCK In pro

25、gressothersfail,soc_create, soc_bindsoc_connectsoc_send, soc_sendtosoc_recv, soc_recvfromsoc_setsockopt/soc_getsockoptsoc_gethostbynamesoc_gethostbyname2soc_get_last_errorsoc_get_account_localipsoc_ip_check, soc_close,2018/4/12,Copyright MediaTek Inc. All rights reserved.,28,Functions,soc_gethostbyn

26、ame2To get ip addresses by giving domain nameFields:is_blocking only non-blocking supported*addr/*addr_lenreturned ip addresses, lengthin_entry_numMax allowed number of return entries*out_entry_numNumber of returned entriesReturns:0successSOC_WOULDBLOCK in progressothersfail,soc_create, soc_bindsoc_

27、connectsoc_send, soc_sendtosoc_recv, soc_recvfromsoc_setsockopt/soc_getsockoptsoc_gethostbynamesoc_gethostbyname2soc_get_last_errorsoc_get_account_localipsoc_ip_check, soc_close,2018/4/12,Copyright MediaTek Inc. All rights reserved.,29,Functions,soc_get_last_errorTo get the last network error.Fields

28、:s: socket_iderror:SOC_BEARER_FAIL/othersdeatil_cause:detailed errorReturns:0success0fail,soc_create, soc_bindsoc_connectsoc_send, soc_sendtosoc_recv, soc_recvfromsoc_setsockopt/soc_getsockoptsoc_gethostbynamesoc_gethostbyname2soc_get_last_errorsoc_get_account_localipsoc_ip_check, soc_close,2018/4/1

29、2,Copyright MediaTek Inc. All rights reserved.,30,Functions,soc_get_account_localipTo get the local IP address of the socketFields:s: socket_id*local_ip:returned ip addressReturnes:0success0fail,soc_create, soc_bindsoc_connectsoc_send, soc_sendtosoc_recv, soc_recvfromsoc_setsockopt/soc_getsockoptsoc

30、_gethostbynamesoc_gethostbyname2soc_get_last_errorsoc_get_account_localipsoc_ip_check, soc_close,2018/4/12,Copyright MediaTek Inc. All rights reserved.,31,Functions,soc_ip_checkTo check if the input string in the valid form of IP address.Fields:asci_addr:domain name or IP address*ip_addr:returned IP

31、 address (in byte format)*ip_validity the result of checkReturns:KAL_TRUE an IP addressKAL_FALSEnot an IP address,soc_create, soc_bindsoc_connectsoc_send, soc_sendtosoc_recv, soc_recvfromsoc_setsockopt/soc_getsockoptsoc_gethostbynamesoc_gethostbyname2soc_get_last_errorsoc_get_account_localipsoc_ip_c

32、heck, soc_close,2018/4/12,Copyright MediaTek Inc. All rights reserved.,32,Functions,soc_closeTo close a socketFieldss: socket_idReturns:0success0failInfo:close the socket,soc_create, soc_bindsoc_connectsoc_send, soc_sendtosoc_recv, soc_recvfromsoc_setsockopt/soc_getsockoptsoc_gethostbynamesoc_gethos

33、tbyname2soc_get_last_errorsoc_get_account_localipsoc_ip_check, soc_close,2018/4/12,Copyright MediaTek Inc. All rights reserved.,33,Sample code,Socket Usage Sample Codes (Client side):,/* create socket */handle = soc_create(SOC_PF_INET, SOC_SOCK_STREAM, 0, MOD_JAYSN, nwk_acct_id);if (handle 0) return

34、 -1;/* set socket option */option = SOC_READ | SOC_WRITE | SOC_ACCEPT | SOC_CONNECT | SOC_CLOSE;result = soc_setsockopt(handle, SOC_ASYNC, if (result = SOC_WOULDBLOCK) /* wait for the APP_SOC_NOTIFY_IND(SOC_CONNECT) */,2018/4/12,Copyright MediaTek Inc. All rights reserved.,34,Sample code,Socket Usag

35、e Sample Codes (Server side):,sockaddr_struct addr;Kal_mem_set(,WPS,2018/4/12,Copyright MediaTek Inc. All rights reserved.,36,WPS Overview,WAP 2.0 Protocol Service (WPS) provides interface for application that needs to communicate with WAP gateway, HTTP proxy/server through WAP 2.0 protocol stackCha

36、nnel Setup:Configure a specific channel to handle HTTP/WSP requestHTTP and WSP request:Send HTTP/WSP request for applicationReceive HTTP/WSP response for applicationCache and cookie clear request:Clear cache or cookie, which is shared by all users,2018/4/12,Copyright MediaTek Inc. All rights reserve

37、d.,37,WPS Overview,Application,Socket Task,Function call,soc_create, soc_close, soc_connect,soc_send, soc_sendto,soc_recv, soc_recvfrom,APP_SOC_GET_HOST_BY_NAME_INDAPP_SOC_GET_HOST_BY_ADDR_INDAPP_SOC_NOTIFY_IND,MSG_ID_WPS_SET_CHANNEL_REQMSG_ID_WPS_HTTP_REQMSG_ID_WPS_READ_CONTENT_REQ,MSG_ID_WPS_SET_C

38、HANNEL_RSPMSG_ID_WPS_HTTP_RSPMSG_ID_WPS_READ_CONTENT _RSP,2018/4/12,Copyright MediaTek Inc. All rights reserved.,38,WPS Message,2018/4/12,Copyright MediaTek Inc. All rights reserved.,39,WPS Message,2018/4/12,Copyright MediaTek Inc. All rights reserved.,40,WPS Message,2018/4/12,Copyright MediaTek Inc

39、. All rights reserved.,41,MSG_ID_WPS_SET_CHANNEL_REQLocal Parameter wps_set_channel_req_struct,2018/4/12,Copyright MediaTek Inc. All rights reserved.,42,MSG_ID_WPS_SET_CHANNEL_REQ Peer buffer wps_set_channel_req_struct,If application doesnt specify Static_header, then WPS will use the value currentl

40、y used by WAPStatic_header (if necessary) must be filled in wps_set_channel_req_var_struct and then packed in peer buffer by wps_pun_var_part() before sending to WPS. Static_header will be used in the header when establishing WSP session when conn_type is WSP_CONN_TYPE_WSP_CO and the first WSP reque

41、st of some dedicated channel with connection type WSP_CONN_TYPE_WSP_CL.,2018/4/12,Copyright MediaTek Inc. All rights reserved.,43,MSG_ID_WPS_HTTP_REQ Local Parameter wps_http_req_struct,2018/4/12,Copyright MediaTek Inc. All rights reserved.,44,MSG_ID_WPS_HTTP_REQ Peer Buffer wps_http_req_var_struct,

42、2018/4/12,Copyright MediaTek Inc. All rights reserved.,45,MSG_ID_WPS_READ_CONTENT_REQ Local Parameter wps_read_content_req_struct,2018/4/12,Copyright MediaTek Inc. All rights reserved.,46,MSG_ID_WPS_POST_CONTENT_RESLocal Parameter wps_post_content_res_struct,2018/4/12,Copyright MediaTek Inc. All rig

43、hts reserved.,47,MSG_ID_WPS_POST_CONTENT_RESPeer Buffer wps_post_content_res_var_struct,2018/4/12,Copyright MediaTek Inc. All rights reserved.,48,Message Flow: GET,Scenario: application wants to get a file using WPS serviceStep 1: setup a channelStep 2: send the HTTP requestStep 3: receive the replyStep 4: Remove the channelInvolved ILM :MSG_ID_WPS_SET_CHANNEL_REQMSG_ID_WPS_SET_CHANNEL_RSPMSG_ID_WPS_HTTP_REQMSG_ID_WPS_HTTP_RSPMSG_ID_WPS_READ_CONTENT_REQMSG_ID_WPS_READ_CONTENT_RSPMSG_ID_WPS_UNSET_CHANNEL_REQMSG_ID_WPS_UNSET_CHANNEL_RSP,

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报