Android native UPnP service discovery
Asked Answered
S

1

6

From Android 4.1 (under Wi-Fi Direct service discovery) it is suppose to support native UPnP service discovery.

I presume it was developed for Wi-Fi Direct, but the methods available seem to be generic. Even the JavaDoc for methods mention that it searches for all UPnP services on the network and not only WiFi Direct slaves/masters.

However, I am failing to implement it so that it works... I manage to set up all requirements and I get positive onSuccess callbacks, but I receive no onUpnpServiceAvailable callbacks notifying about services on the network. I do have 3 services on UPnP which I can discover using 3rd-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) {
        }
    });
Stepper answered 2/9, 2013 at 15:26 Comment(1)
P2P UPNP discovery is for Wi-Fi direct connections only. The only commonality between P2P UPNP Discover, and the full UPNP protocol is that P2P UPNP discovery uses UPNP resource names to discover Wi-Fi direct devices. Android Provides DNS-SD over networks, but not UPNP (non-P2P) discovery.Chinkapin
P
2

Yes, I have tried it, and I think it's all about WIFI_P2P_SERVICE - meaning P2P - meaning PeerToPeer or "Wi-Fi Direct" or "Adhoc Wifi Mode". In other words, it won't work when you are in a normal WiFi situation with an Access Point / station mode.

I don't think Android has any native way to listen for UPnP / SSdP at the OS level except in this situation of "Wi-Fi Direct".

If anyone else wants to chime in, please do!

Pedate answered 8/9, 2013 at 18:22 Comment(1)
Not correct. You can have simultaneous Wi-Fi Direct and Access Point connections. That's kind of the whole point of Wi-Fi Direct!Chinkapin

© 2022 - 2024 — McMap. All rights reserved.