我正在尝试为Android Lollipop编写WPS引脚和推送方法的代码。代码正确编译,但调用时站不会启动配置。不知道我做错了什么。我的代码片段如下:
WpsInfo getWpsConfig(){
WpsInfo config=new WpsInfo();
config.setup=WpsInfo.PBC;
config.setup=WpsInfo.DISPLAY;
config.setup=WpsInfo.INVALID;
return config;
}
我甚至试过这个:
WpsInfo wpsManager = new WpsInfo();
if(cmdParams[0].equalsIgnoreCase("pbc")){
wpsManager.setup=wpsInfo.PBC;
int wpsStatus = wpsManager.describeContents();
Log.i(TAG,"Status of the device is:"+wpsStatus);
System.out.println("Status of the device is:\"+wpsStatus");
return cmdExecStatus.SUCCESS;
}
else if (cmdParams[0].equalsIgnoreCase("pin")){
wpsManager.setup= WpsInfo.DISPLAY;
String wpsPin = wpsManager.pin;
Log.i(TAG,"Pin on the device is:"+wpsPin);
System.out.println("Pin on the device is:"+wpsPin);
int wpsStatus = wpsManager.describeContents();
Log.i(TAG,"Status of the device is:"+wpsStatus);
System.out.println("Status of the device is:\"+wpsStatus");
return cmdExecStatus.SUCCESS;
}
答案 0 :(得分:0)
试试这个:
WpsInfo getWpsConfig(){
WpsInfo config=new WpsInfo();
if(cmdParams[0].equalsIgnoreCase("pbc")){
config.setup=WpsInfo.PBC;
} else if(cmdParams[0].equalsIgnoreCase("pin")){
config.setup=WpsInfo.DISPLAY;
} else {
config.setup=WpsInfo.INVALID;
}
return config;
}
和
WifiManager mWifiManager = (WifiManager)getSystemService(Context.WIFI_SERVICE);
mWifiManager.startWps(getWPSConfig(), new WifiManager.WpsCallback() {
@Override
public void onStarted(String pin) {
Log.d("WPS", "onStarted " + pin);
}
@Override
public void onSucceeded() {
Log.d("WPS", "onSucceeded");
}
@Override
public void onFailed(int reason) {
Log.d("WPS", "onFailed");
}
});
另外,请不要忘记在清单文件中添加权限。
答案 1 :(得分:0)
试试这个
config.wps.setup = WpsInfo.PBC;
config.wps.setup=WpsInfo.DISPLAY;
config.wps.setup=WpsInfo.INVALID;