Library can't discover Belkin Wemos

May 21, 2015 at 10:10 PM
Edited May 22, 2015 at 12:59 PM
Hello All,

I'm Drew and I'm new here. I'm very excited to see that this project exists and how mature it is!

However, I'm having a problem: I 'downloaded/compiled/played with' the library and it's test browser where I work. Everything went well. I got home and tried the same, expecting to see a laundry list of 'Belkin Wemo' and other devices in the treeview - but no such luck.

The only thing that shows in the Browser Test Treeview is my wireless router:

Image

The Wemo can't be misbehaving because they show on my phone. Do I have some Windows service turned off? Are there devices that don't allow being discovered via UPnP? Can you think of any other reason I can't "discover" my Wemos?

I'm using Windows 8.1, Visual Studio 2013, and .NET 4.5.2

Thank you all in advance!
Drew Barfield
May 22, 2015 at 12:54 PM
  • I can get info about the Wemo Insight Switch from Windows File Explorer > Network
  • I can see a setup.xml file in my Web browser at an address like: 192.168.1.131:4915/setup.xml
The only thing I can't do is discover the devices with Managed UPnP.

Is all of this implying that I can't discover these devices but will have to know the IP address and port before hand?

...I didn't even bother to look at the Windows Event Log - I'll have to do that when I get home this afternoon.
May 22, 2015 at 7:37 PM
Edited May 26, 2015 at 2:36 PM
Event Viewer yielded nothing of any value... :(

I've enabled additional "media services" (Windows 8.1) and they show in File Explorer, along with my Wemo Insight Switches. The switches are all under "Other Devices" :

Image

But, when I run ManagedUPnPTest, I'm seeing everything but the Wemo switches:

Image

I'll never give up! But I'm running out of ideas...
May 22, 2015 at 7:57 PM
Edited May 26, 2015 at 2:59 PM
Here's what I get when I request "http://192.1??.1.??1:49??3/setup.xml" using Chrome:
<?xml version="1.0"?>
<root xmlns="urn:Belkin:device-1-0">
  <specVersion>
    <major>1</major>
    <minor>0</minor>
  </specVersion>
  <device>
<deviceType>urn:Belkin:device:insight:1</deviceType>
<friendlyName>Bedroom Floor Lamp</friendlyName>
    <manufacturer>Belkin International Inc.</manufacturer>
    <manufacturerURL>http://www.belkin.com</manufacturerURL>
    <modelDescription>Belkin Insight 1.0</modelDescription>
    <modelName>Insight</modelName>
    <modelNumber>1.0</modelNumber>
    <modelURL>http://www.belkin.com/plugin/</modelURL>
<serialNumber>??????????????????????????</serialNumber>
<UDN>uuid:Insight-1_0-???????????????</UDN>
    <UPC>123456789</UPC>
<macAddress>B4750E75811C</macAddress>
<firmwareVersion>WeMo_WW_2.00.8643.PVT-OWRT-Insight</firmwareVersion>
<iconVersion>0|49153</iconVersion>
<binaryState>0</binaryState>
    <iconList> 
      <icon> 
        <mimetype>jpg</mimetype> 
        <width>100</width> 
        <height>100</height> 
        <depth>100</depth> 
         <url>icon.jpg</url> 
      </icon> 
    </iconList>
    <serviceList>
      <service>
        <serviceType>urn:Belkin:service:WiFiSetup:1</serviceType>
        <serviceId>urn:Belkin:serviceId:WiFiSetup1</serviceId>
        <controlURL>/upnp/control/WiFiSetup1</controlURL>
        <eventSubURL>/upnp/event/WiFiSetup1</eventSubURL>
        <SCPDURL>/setupservice.xml</SCPDURL>
      </service>
      <service>
        <serviceType>urn:Belkin:service:timesync:1</serviceType>
        <serviceId>urn:Belkin:serviceId:timesync1</serviceId>
        <controlURL>/upnp/control/timesync1</controlURL>
        <eventSubURL>/upnp/event/timesync1</eventSubURL>
        <SCPDURL>/timesyncservice.xml</SCPDURL>
      </service>
      <service>
        <serviceType>urn:Belkin:service:basicevent:1</serviceType>
        <serviceId>urn:Belkin:serviceId:basicevent1</serviceId>
        <controlURL>/upnp/control/basicevent1</controlURL>
        <eventSubURL>/upnp/event/basicevent1</eventSubURL>
        <SCPDURL>/eventservice.xml</SCPDURL>
      </service>
      <service>
        <serviceType>urn:Belkin:service:firmwareupdate:1</serviceType>
        <serviceId>urn:Belkin:serviceId:firmwareupdate1</serviceId>
        <controlURL>/upnp/control/firmwareupdate1</controlURL>
        <eventSubURL>/upnp/event/firmwareupdate1</eventSubURL>
        <SCPDURL>/firmwareupdate.xml</SCPDURL>
      </service>
      <service>
        <serviceType>urn:Belkin:service:rules:1</serviceType>
        <serviceId>urn:Belkin:serviceId:rules1</serviceId>
        <controlURL>/upnp/control/rules1</controlURL>
        <eventSubURL>/upnp/event/rules1</eventSubURL>
        <SCPDURL>/rulesservice.xml</SCPDURL>
      </service>
      
      <service>
        <serviceType>urn:Belkin:service:metainfo:1</serviceType>
        <serviceId>urn:Belkin:serviceId:metainfo1</serviceId>
        <controlURL>/upnp/control/metainfo1</controlURL>
        <eventSubURL>/upnp/event/metainfo1</eventSubURL>
        <SCPDURL>/metainfoservice.xml</SCPDURL>
      </service>

      <service>
        <serviceType>urn:Belkin:service:remoteaccess:1</serviceType>
        <serviceId>urn:Belkin:serviceId:remoteaccess1</serviceId>
        <controlURL>/upnp/control/remoteaccess1</controlURL>
        <eventSubURL>/upnp/event/remoteaccess1</eventSubURL>
        <SCPDURL>/remoteaccess.xml</SCPDURL>
      </service>
       
      <service>
        <serviceType>urn:Belkin:service:deviceinfo:1</serviceType>
        <serviceId>urn:Belkin:serviceId:deviceinfo1</serviceId>
        <controlURL>/upnp/control/deviceinfo1</controlURL>
        <eventSubURL>/upnp/event/deviceinfo1</eventSubURL>
        <SCPDURL>/deviceinfoservice.xml</SCPDURL>
      </service>

      <service>
        <serviceType>urn:Belkin:service:insight:1</serviceType>
        <serviceId>urn:Belkin:serviceId:insight1</serviceId>
        <controlURL>/upnp/control/insight1</controlURL>
        <eventSubURL>/upnp/event/insight1</eventSubURL>
        <SCPDURL>/insightservice.xml</SCPDURL>
      </service>

      <service>
        <serviceType>urn:Belkin:service:smartsetup:1</serviceType>
        <serviceId>urn:Belkin:serviceId:smartsetup1</serviceId>
        <controlURL>/upnp/control/smartsetup1</controlURL>
        <eventSubURL>/upnp/event/smartsetup1</eventSubURL>
        <SCPDURL>/smartsetup.xml</SCPDURL>
      </service>
      
      <service>
        <serviceType>urn:Belkin:service:manufacture:1</serviceType>
        <serviceId>urn:Belkin:serviceId:manufacture1</serviceId>
        <controlURL>/upnp/control/manufacture1</controlURL>
        <eventSubURL>/upnp/event/manufacture1</eventSubURL>
        <SCPDURL>/manufacture.xml</SCPDURL>
      </service>

    </serviceList>
   <presentationURL>/pluginpres.html</presentationURL>
</device>
</root>
May 25, 2015 at 7:00 PM

Ah Ha!

This code works, but it remains in an infinite receiving loop and doesn't use ManagedUPnP Library:
public static void FindWemos()
{
    var ip = IPAddress.Parse("239.255.255.250");

    IPEndPoint LocalEndPoint = new IPEndPoint(IPAddress.Any, 1901);
    IPEndPoint MulticastEndPoint = new IPEndPoint(ip, 1900);

    Socket UdpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
    UdpSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
    UdpSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true);
    UdpSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, 2);
    UdpSocket.Bind(LocalEndPoint);
    UdpSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(ip, LocalEndPoint.Address));

    string SearchString =
        "M-SEARCH * HTTP/1.1\r\n" +
        "HOST: 239.255.255.250:1900\r\n" +
        "MAN: \"ssdp:discover\"\r\n" +
        "ST: upnp:rootdevice\r\n" +
        "MX: 5\r\n" +
        "\r\n";
            
    UdpSocket.SendTo(Encoding.UTF8.GetBytes(SearchString), SocketFlags.None, MulticastEndPoint);

    Console.WriteLine("M-Search sent...\r\n");

    byte[] ReceiveBuffer = new byte[2048];
    int ReceivedBytes = 0;
    while (true)
    {
        if (UdpSocket.Available > 0)
        {
            ReceivedBytes = UdpSocket.Receive(ReceiveBuffer, SocketFlags.None);

            if (ReceivedBytes > 0)
            {
                string responseString = Encoding.UTF8.GetString(ReceiveBuffer, 0, ReceivedBytes);
                Console.WriteLine(responseString);
            }
        }
    }
}