Is it possible to check if a device exists on the home network? I was thinking if I could see if my or my wife's iPhones are on the wireless at home, to automatically set the AC to ON. If they are both not found online, to set the AC to OFF.
I was thinking of doing some sort of ping test for the devices and somehow tie the status to a virtual device.
Check if device exists on the network?
- 91 Views
- Last Post 29 November 2013
Is it possible to check if a device exists on the home network? I was thinking if I could see if my or my wife's iPhones are on the wireless at home, to automatically set the AC to ON. If they are both not found online, to set the AC to OFF.
I was thinking of doing some sort of ping test for the devices and somehow tie the status to a virtual device.
This sounds like an intriguing idea. I'm not sure we could do a ping test though - I'm guessing that doing a 'ping' to a device's ip address will fail since the device manufactures probably disable it for security reasons.
IOS devices respond to ping.
This could be a nice lazy mans way to make the app location aware.
Maybe something with this? Just haven't had time to really look into this.
[code]
using System;
using System.Net;
using System.Net.NetworkInformation;
using System.Text;
namespace Examples.System.Net.NetworkInformation.PingTest
{
public class PingExample
{
// args[0] can be an IPaddress or host name.
public static void Main (string[] args)
{
Ping pingSender = new Ping ();
PingOptions options = new PingOptions ();
// Use the default Ttl value which is 128,
// but change the fragmentation behavior.
options.DontFragment = true;
// Create a buffer of 32 bytes of data to be transmitted.
string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
byte[] buffer = Encoding.ASCII.GetBytes (data);
int timeout = 120;
PingReply reply = pingSender.Send (args[0], timeout, buffer, options);
if (reply.Status == IPStatus.Success)
{
Console.WriteLine ("Address: {0}", reply.Address.ToString ());
Console.WriteLine ("RoundTrip time: {0}", reply.RoundtripTime);
Console.WriteLine ("Time to live: {0}", reply.Options.Ttl);
Console.WriteLine ("Don't fragment: {0}", reply.Options.DontFragment);
Console.WriteLine ("Buffer size: {0}", reply.Buffer.Length);
}
}
}
}
[/code]
You might have to set your router to give static IPs to the phones - just in case the IP gets changed...