0

I am trying to write the code for WPS pin and push method for Android Lollipop. The code compiles correctly but the configuration is not initiated by the station when invoked. Not sure what i am doing wrong. My piece of code snippet is as below:

WpsInfo getWpsConfig(){
  WpsInfo config=new WpsInfo();
  config.setup=WpsInfo.PBC;
 config.setup=WpsInfo.DISPLAY;
config.setup=WpsInfo.INVALID;
return config;
}

I even tried this:

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;
        }
ankuranurag2
  • 2,300
  • 15
  • 30

2 Answers2

0

try this:

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;
}

and

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");
                }
});

Also don't forget to add permissions in the manifest file.

CVA
  • 1,477
  • 1
  • 14
  • 23
0

try this

config.wps.setup = WpsInfo.PBC;
config.wps.setup=WpsInfo.DISPLAY;
config.wps.setup=WpsInfo.INVALID;
pratham kesarkar
  • 3,770
  • 3
  • 19
  • 29