I have a camera which can be found in UPnP Search. It also advertises(multicast) the same response as of UPnP search in every 150 seconds.
I have created an android app which can identify the camera either by UPnP search or just listening to the multicast advertisement.
I achieved advertisement listening by just creating a multicast socket and listens for any packets
new Thread(new Runnable() {
public void run() {
try{
Utils.showLog(TAG,"Searching Thread Started " );
// Get the address that we are going to connect to.
InetAddress address = InetAddress.getByName(INET_ADDR);
// Create a buffer of bytes, which will be used to store
// the incoming bytes containing the information from the server.
// Since the message is small here, 256 bytes should be enough.
byte[] buf = new byte[512];
// Create a new Multicast socket (that will allow other sockets/programs
// to join it as well.
try {
clientSocket = new MulticastSocket(PORT);
//Joint the Multicast group.
clientSocket.joinGroup(address);
isSocketOpen=true;
while (isSocketOpen) {
// Receive the information and print it.
DatagramPacket msgPacket = new DatagramPacket(buf, buf.length);
clientSocket.receive(msgPacket);
Utils.showLog(TAG, "------>SocketAddress: " + msgPacket.getSocketAddress());
Utils.showLog(TAG,"------>Port " + msgPacket.getPort());
String URL =getLocation(msgPacket).trim();
}
} catch (IOException ex) {
ex.printStackTrace();
}
} catch (UnknownHostException ex) {
ex.printStackTrace();
}
}
}).start();
now my issue is that on Asus Zenfone(Android version 5.0) ,its work fine but on Lenovo A1000 (same andoid version) it fails.
Lenovo A1000 can capture SSDP packets from windows PC.Issue is with Packets from my camera only.
But if packets from camera is currupted, then how it is captured in Asus Zenfone?
My question is that will android block any packets before reaching my app?