我试图实现我自己的UpNP扫描,它主要是工作,并证明这不是我,我有一个
Windows程序,允许您发送数据包,看看有什么回应.
我在端口1900发送一个数据包到239.255.255.250,我发送以下数据:
M-SEARCH * HTTP/1.1 Host: 239.255.255.250:1900 Man: "ssdp:discover" MX: 10 ST: ssdp:all
只需要进一步的信息,在我的Java代码(Android)我有以下,但我得到相同的响应作为数据包测试程序应用程序:
try { byte[] sendData = new byte[1024]; //byte[] receiveData = new byte[1024]; byte[] receiveData; String mSearch = "M-SEARCH * HTTP/1.1\r\nHost: 239.255.255.250:1900\r\nMan: \"ssdp:discover\"\r\nMX: 10\r\nST: ssdp:all\r\n\r\n"; sendData = mSearch.getBytes(); DatagramPacket sendPacket = new DatagramPacket(sendData,sendData.length,InetAddress.getByName("239.255.255.250"),1900); DatagramSocket clientSocket = new DatagramSocket(); clientSocket.send(sendPacket); while (keepGoing) { receiveData = new byte[1024]; receivePacket = new DatagramPacket(receiveData,receiveData.length); clientSocket.receive(receivePacket); String response = new String(receivePacket.getData()); if (response == null || response.length() == 0) { keepGoing = false; } else { iupnpScan.updateText(response); } } iupnpScan.complete(true); return true; } catch (UnknownHostException ex) { Log.e("MainActivity","Unknown Host Exception: " + ex.toString()); } catch (SocketException ex) { Log.e("MainActivity","Socket Exception: " + ex.toString()); } catch (IOException ex) { Log.e("MainActivity","IO Exception: " + ex.toString()); } iupnpScan.complete(false); return false;
我正在收到一些设备回来,比如我的智能电视,路由器和NAS,但是Phyips Hue Bridge从来没有在回复中返回.
飞利浦色相桥是否实现了UpNP的不同之处,我可以看到,现在所发现的响应是什么,需要什么才能找到.
谢谢
解决方法
虽然
Philips site笔记支持UPnP,但我不知道它是否为真.
我会尝试扫描整个网络并通过IP测试IP.是的,我知道,这不是标准所说的,但现实有时是疯狂的.
这个发现已经在this way实施了.
我过去编程了一个网络搜索(寻找一个Raspberry PI),我可以使用的最好的方法是匹配的MAC地址与我已知的地址开始.幸运的是,Philips publish their MAC addresses range.