智能终端及其网络底层配置方法_2

文档序号:9931142阅读:来源:国知局
的网络群组却可解决这一问题,其 中createGroupO函数的调用起到关键的作用,其完成了本智能终端的热点模式的启动。 [0057]由于本发明重点是希望解决让客户端通过服务端所在的智能设备的WiFi功能访 问外网的网络配置问题。在不考虑客户端自行连接外网的前提下,本智能终端能够访问外 网,是接入本网络群组的客户端访问外网的前提。因此,较佳的方式中,是使本智能终端在 完成上述热点模式的启动之前,便已启动了站点模式。
[0058]欲启动Android系统的站点模式,可以通过用户在系统设置页上手动开启或通过 系统的站点进程来建立。所述站点进程,特指Andro i d系统自身提供的wpa_supp 1 i can t进 程,wpa_supplicant本是开源项目源码,被谷歌修改后加入android移动平台,主要是用来 支持WEP,WPA/WPA2和WAPI无线协议和加密认证的,而实际上的工作内容是通过socket (不 管是wpa_supplicant与上层还是wpa_suppli cant与驱动都采用socket通讯)与驱动交互上 报数据给用户,用户可以通过socket发送命令给wpa_supplicant调动驱动来对WiFi芯片操 作。简单的说,wpa_supp 1 i cant就是WiFi驱动和用户的中转站外加对协议和加密认证的支 持。经过编译后的wpa_supp 1 i can t源程序可以看到两个主要的可执行工具:wpa_ supplicant和wpa_cli jpa+suppli cant是核心程序,它和wpa_cli的关系就是服务端和客 户端的关系:后台运行wpa_supp 1 i cant,使用wpa_c 1 i来搜索、设置、和连接网络。
[0059]以下提供一个利用wpa_cli来完成网络连接的示例供本领域技术人员参照理解本 发明,但不应理解为对本发明的实现的限制。
[0060] 要实现网络连接功能,首先需要运行wpa_supplicant程序以加载基本功能;
[0061 ] 执行:/system/bin/wpa_supplicant-d-Dwext-iwlan〇-c/data/misc/wifi/wpa_ supplicant.conf
[0062]其中:
[0063] -d:增加调试信息
[0064] -Dwext :wext,驱动名称
[0065] -iwlanO :wlan0,网络接 口名称
[0066] /system/bin/wpa_supplicant :wpa_supplicant,可执行程序路径
[0067] /data/misc/wif i/wpa_suppli cant ? conf :wpa_suppli cant 的配置文件路径
[0068] 然后,运行命令行工具wpa_cli;
[0069] 执行:wpa_cli_iwlan〇-p/data/system/wpa_suppli cant
[0070] 注意,-p/data/sys tem/wpa_suppli cant 中的 wpa_suppli cant 并不是可执行程序, 而是个控制套接字。
[0071]此时会进入交互模式。其中交互模式的命令如下表:
[0072] Full command
[0073] Short command
[0074] Description
[0075] status
[0076] stat
[0077] displays the current connection status
[0078] disconnect
[0079] disc
[0080] prevents wpa_supplicant from connecting to any access point
[0081] quit
[0082] q
[0083] exits wpa_cli
[0084] terminate
[0085] term
[0086] kills wpa-supp1i cant
[0087] reconfigure
[0088] recon
[0089] reloads wpa_supplicant with the configuration file supplied(-cparameter)
[0090] scan
[0091] scan
[0092] scans for available access points(only scans it,doesnJ t display anything)
[0093] s can-re su11
[0094] scan-r
[0095] displays the results of the last scan
[0096] list_networks
[0097] list-n
[0098] displays a list of configured networks and their status(active or not,enabled or disabled)
[0099] select_network
[0100] select-n
[0101] select a network among those defined to initiate a connection(ie select-network 0)
[0102] enab1e-ne twork
[0103] enable-n
[0104] makes a configured network available for selection(ie enable-network 〇)
[0105] disable-network
[0106] disable-n
[0107] makes a configured network unavailable for selection(iedisable_ network 0)
[0108] remove-network
[0109] remove-n
[0110] removes a network and its configuration from the 1ist(ieremove_ network 0)
[0111] add-network
[0112] add-n
[0113] adds a new network to the list.Its id will be created automatically
[0114] set-network
[0115] set-n
[0116] shows a very short list of available options to configure a network when supplied with no parameters.
[0117] See next section for a list of extremely useful parameters to be used with set-network and get-network.
[0118] get-network
[0119] get-n
[0120] displays the required parameter for the specified network.See next section for a list of parameters
[0121 ] save_conf ig
[0122] save-c
[0123] saves the configuration
[0124] 以上命令项可以从Android的公开技术文档中查看,此处仅供参考。
[0125] 设置网络的基本格式的指令为:set_network〈network id>〈key>〈parameter>[〈 parameter〉]
[0126] 显示网络信息的基本格式的指令为:get_network〈network id>〈key>
[0127] 相应的参数如下表:
[0128] Key
[0129] Description
[0130] Parameters
[0131] ssid
[0132] Access point name
[0133] string
[0134] id-str
[0135] String identifying the network
[0136] string
[0137] priority
[0138] Connection priority over other APs
[0139] number(0 being the default low priority)
[0140] bssid
[0141] Mac address of the access point
[0142] mac address
[0143] scan-ssid
[0144] Enable/disbale ssid scan
[0145] 0,1,2
[0146] key-mgmt
[0147] Type of key management
[0148] WPA-PSK,WPA-EAP,None
[0149] pairwise
[0150] Pairwise ciphers for WPA
[0151] CCMPJKIP
[0152] group = TKIP
[0153] Group ciphers for WPA
[0154] CCMP,TKIP,WEP104,WEP40
[0155] psk
[0156] Pre-Shared Key(clear or encrypted)
[0157] string
[0158] wep_key0
[0159] WEP key(up to 4:wep_key[0123])
[0160] string [0161 ] eap
[0162] Extensible Authentication Protocol
[0163] MD5,MSCHAPV2,OTP,GTC,TLS,PEAP,TTLS
[0164] identity
[0165] EAP identity string
[0166] string
[0167] password
[0168] EAP password
[0169] string
[0170] ca-cert
[0171] Pathname to CA certificate file
[0172] /ful1/path/to/certificate
[0173] client-cert
[0174] Pathname to client certificate
[0175] /ful1/path/to/certificate(PEM/DER)
[0176] private-key
[0177] Pathname to a client private key file
[0178] /ful1/path/to/private-key(PEM/DER/PFX)
[0179] 同理,以上参数表也可通过公共途径从Android官方得到,仅供参考,恕不赘述。以 下利用一用于连接无加密的AP的具体实例说明如何实现网络连接:
[0180] >add_network(将显示一网络ID,假定返回值为0)
[0181] >set-network 0ssid"666〃
[0182] >set-network Okey-mgmt NONE
[0183] >enable-network 0
[0184] >quit
[0185] 再利用一用于连接WEP加密的AP的具体实例加以说明:
[0186] >add_network(假定网络 ID 返回 1)
[0187] >set-network lssid"666〃
[0188] >set-network lkey-mgmt NONE
[0189] >set-network lwep-key0"your ap password"
[0190] >enable-network 1
[0191] 至于连接WPA-PSK/WPA2-PSK加密的AP的示例如下:
[0192] >add_network (假定网络 ID返回2)
[0193] >set-network 2ssid"666〃
[0194] >set-network 2psk〃your pre-shared key"
[0195] >enable-network 2
[0196] 到此,wifi模块就能连接上AP7。
[0197] 以上是通过命令行工具wpa_cli来实现wif i网络的连接D当然,也可以通过wpa_ 8即口1;[031^的配置文件来实现连接。
[0198] 不妨再回顾前面运行wpa_supplicant时执行的命令:
[0199] / system/bin/wpa_suppl icant-d-Dwext-iwlan〇-c/data/misc/wif i/wpa_ supplicant.conf
[0200] 我们在执行时加上了-c/data/misc/wif i/wpa_suppli cant .conf,故而将要连接 的AP的设置以一定的格式写入wpa_supplicant .conf配置文件中即可例如:
[0201 ] ctrl_interface = DIR = /data/system/wpa_supplicant GROUP = system update_conf ig = 1
[0202] network = {
[0203] ssid = "my access point"
[0204] proto=WPA
[0
当前第2页1 2 3 4 5 6 
网友询问留言 已有0条留言
  • 还没有人留言评论。精彩留言会获得点赞!
1