Java Code Examples for android.net.wifi.WpsInfo#PBC

The following examples show how to use android.net.wifi.WpsInfo#PBC . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Wifi-Connect   File: WifiP2PServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public synchronized void connectDevice(WifiP2pDevice wifiP2pDevice) {
    WifiP2pConfig config = new WifiP2pConfig();
    config.deviceAddress = wifiP2pDevice.deviceAddress;
    config.wps.setup = WpsInfo.PBC;
    config.groupOwnerIntent = 15;
    manager.connect(channel, config, new WifiP2pManager.ActionListener() {
        @Override
        public void onSuccess() {}
        @Override
        public void onFailure(int reason) {
            if(wifiP2PConnectionCallback != null) {
                activity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        wifiP2PConnectionCallback.onPeerConnectionFailure();
                    }
                });
            }
        }
    });
}
 
Example 2
Source Project: ShareBox   File: P2pReceiver.java    License: Apache License 2.0 6 votes vote down vote up
public void connect(WifiP2pDevice device)
{
    WifiP2pConfig config=new WifiP2pConfig();

    config.deviceAddress=device.deviceAddress;
    config.wps.setup= WpsInfo.PBC;

    _wifiP2pManager.connect(_channel, config, new WifiP2pManager.ActionListener() {
        @Override
        public void onSuccess() {

        }

        @Override
        public void onFailure(int reason) {

        }
    });
}
 
Example 3
Source Project: WiFi-Buddy   File: WifiDirectHandler.java    License: MIT License 6 votes vote down vote up
/**
 * Initiates a connection to a service
 * @param service The service to connect to
 */
public void initiateConnectToService(DnsSdService service) {
    // Device info of peer to connect to
    WifiP2pConfig wifiP2pConfig = new WifiP2pConfig();
    wifiP2pConfig.deviceAddress = service.getSrcDevice().deviceAddress;
    wifiP2pConfig.wps.setup = WpsInfo.PBC;

    // Starts a peer-to-peer connection with a device with the specified configuration
    wifiP2pManager.connect(channel, wifiP2pConfig, new WifiP2pManager.ActionListener() {
        // The ActionListener only notifies that initiation of connection has succeeded or failed

        @Override
        public void onSuccess() {
            Log.i(TAG, "Initiating connection to service");
        }

        @Override
        public void onFailure(int reason) {
            Log.e(TAG, "Failure initiating connection to service: " + FailureReason.fromInteger(reason).toString());
        }
    });
}
 
Example 4
/**
 * Initiate a connection with the peer.
 */
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    Log.d(TAG, "onListItemClick");
    WifiP2pDevice device = (WifiP2pDevice)getListAdapter().getItem(position);
    Log.d(TAG, "device is: " + device.deviceAddress);
    WifiP2pConfig config = new WifiP2pConfig();
    config.deviceAddress = device.deviceAddress;
    config.wps.setup = WpsInfo.PBC;
    if (progressDialog != null && progressDialog.isShowing()) {
        progressDialog.dismiss();
    }
    progressDialog = ProgressDialog.show(getActivity(), "Press back to cancel",
            "Connecting to :" + device.deviceAddress, true, true);

    ((DeviceActionListener)getActivity()).connect(config);

}
 
Example 5
Source Project: ShareBox   File: P2pManager.java    License: Apache License 2.0 5 votes vote down vote up
public void connect(WifiP2pDevice device,WifiP2pManager.ActionListener listener)
{
    WifiP2pConfig config=new WifiP2pConfig();

    config.deviceAddress=device.deviceAddress;
    config.wps.setup= WpsInfo.PBC;

    _wifiP2pManager.connect(_channel, config, listener);
}
 
Example 6
Source Project: libcommon   File: WiFiP2pHelper.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 指定したMACアドレスの機器へ接続を試みる
 * @param remoteMacAddress
 */
public void connect(@NonNull final String remoteMacAddress) {
	if (DEBUG) Log.v(TAG, "connect:remoteMacAddress=" + remoteMacAddress);
	final WifiP2pConfig config = new WifiP2pConfig();
	config.deviceAddress = remoteMacAddress;
	config.wps.setup = WpsInfo.PBC;
	connect(config);
}
 
Example 7
Source Project: libcommon   File: WiFiP2pHelper.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 指定した機器へ接続を試みる
 * @param device
 */
public void connect(@NonNull final WifiP2pDevice device) {
	if (DEBUG) Log.v(TAG, "connect:device=" + device);
	final WifiP2pConfig config = new WifiP2pConfig();
	config.deviceAddress = device.deviceAddress;
	config.wps.setup = WpsInfo.PBC;
	connect(config);
}
 
Example 8
Source Project: android-p2p   File: PeerActivity.java    License: MIT License 5 votes vote down vote up
private void connectPeer(WifiP2pDevice peer) {
    WifiP2pConfig config = new WifiP2pConfig();
    config.deviceAddress = peer.deviceAddress;
    config.wps.setup = WpsInfo.PBC;
    this.Application.P2pHandler.Manager.connect(this.Application.P2pHandler.Channel, config, new WifiP2pManager.ActionListener() {
        @Override
        public void onSuccess() {
            Toast.makeText(PeerActivity.this, "Connecting to peer ...", Toast.LENGTH_SHORT).show();
        }
        @Override
        public void onFailure(int reason) {
            Toast.makeText(PeerActivity.this, "Peer connection failed with code " + Integer.toString(reason), Toast.LENGTH_SHORT).show();
        }
    });
}
 
Example 9
Source Project: ShareBox   File: WifiDirectManager.java    License: Apache License 2.0 4 votes vote down vote up
public void wifiP2pConnect() {
	ALog.i(TAG, "wifiP2pConnect mRemoteWifiP2pDeviceAddress:" + mRemoteWifiP2pDeviceAddress);
	WifiP2pConfig config = new WifiP2pConfig();
	config.deviceAddress = mRemoteWifiP2pDeviceAddress;
	config.wps.setup = WpsInfo.PBC;
}