본문 바로가기

IT 연구회

WifiConfiguration

반응형

 


* 첫 공통 부분

 

WifiConfiguration wfc = new WifiConfiguration();

wfc.SSID = "\"".concat(ssid).concat("\"");

wfc.status = WifiConfiguration.Status.DISABLED;

wfc.priority = 40;

 

 

1. Capabilites 가 Open 일때 (키값 없이 바로 접속)

wfc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);

wfc.allowedProtocols.set(WifiConfiguration.Protocol.RSN);

wfc.allowedProtocols.set(WifiConfiguration.Protocol.WPA);

wfc.allowedAuthAlgorithms.clear();

wfc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);


wfc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);

wfc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104);

wfc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);

wfc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);

 

 

 


2. WEP 방식
wfc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);

wfc.allowedProtocols.set(WifiConfiguration.Protocol.RSN);

wfc.allowedProtocols.set(WifiConfiguration.Protocol.WPA);

wfc.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);

wfc.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED);

wfc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);


wfc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);

wfc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104);

wfc.wepKeys[0] = "\"".concat(password).concat("\"");

wfc.wepTxKeyIndex = 0;

 

 

 

 

3. WPA, WPA2 방식 (동일)
wfc.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);

wfc.allowedProtocols.set(WifiConfiguration.Protocol.RSN);

wfc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);

wfc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);

wfc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);

wfc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);

wfc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);

wfc.preSharedKey = "\"".concat(password).concat("\"");

 


 

 

 

 

WifiManager wfMgr = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);

int networkId = wfMgr.addNetwork(wfc);

if (networkId != -1) {

// success, can call wfMgr.enableNetwork(networkId, true) to connect

}

 

 

반응형

'IT 연구회' 카테고리의 다른 글

안드로이드 스레드2 핸들러(handler)  (0) 2013.09.17
listview  (0) 2013.09.17
listview 2  (0) 2013.09.17
listview3  (0) 2013.09.17
listview layout xml  (0) 2013.09.17
WifiManager 메소드  (1) 2013.08.23
안드로이드에서 이미지/버튼 드래그하기  (0) 2013.08.10
CSMA/CA  (0) 2013.06.17
circuit switching vs packet switching  (1) 2013.06.17
ALOHA protocal  (0) 2013.06.17