Android Based UPnP Discovery

From Android 4.1 (when opening the Wi-Fi Direct service), it is supposed to support native detection of the UPnP service.

I assume it was designed for Wi-Fi Direct, but the methods available seem to be common. Even the JavaDoc for methods mentions that it searches for all UPnP services on the network, not just Wi-Fi virtual slaves / masters.

However, I donโ€™t execute it to make it work ... I manage to configure all the requirements and I receive positive onSuccess , but I do not receive onUpnpServiceAvailable notifying about network services. I have 3 services on UPnP that I can detect using a third-party library.

Has anyone tried this feature?

  final Channel mChannel; final WifiP2pManager mManager; WifiP2pServiceRequest mRequester; mManager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE); mChannel = mManager.initialize(this, getMainLooper(), new ChannelListener() { public void onChannelDisconnected() { Log.i("CI", "Channel detected!"); } }); mManager.setUpnpServiceResponseListener(mChannel, new UpnpServiceResponseListener() { public void onUpnpServiceAvailable(List<String> arg0, WifiP2pDevice arg1) { Log.i("sd", "Found device!!"); } }); mRequester = WifiP2pUpnpServiceRequest.newInstance(); mManager.addServiceRequest(mChannel, mRequester, new ActionListener() { public void onSuccess() { Log.i("d", "AddServiceRequest success!"); mManager.discoverServices(mChannel, new ActionListener() { public void onSuccess() { Log.i("d", "DiscoverServices success!"); } public void onFailure(int reason) { } }); } public void onFailure(int reason) { } }); 
+6
source share
1 answer

Yes, I tried this, and I think it all relates to WIFI_P2P_SERVICE - which means P2P - it means PeerToPeer or "Wi-Fi Direct" or "Adhoc Wifi Mode". In other words, it will not work when you are in a normal WiFi situation with access point / station mode.

I donโ€™t think Android has its own way of listening to UPnP / SSdP at the OS level, except for the โ€œWi-Fi Directโ€ situation.

If someone else wants to call back, do it!

+2
source

Source: https://habr.com/ru/post/952991/


All Articles