Author Topic: Need a shell scripter to develop mac/ipad/iphone detection routine  (Read 16809 times)

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Hello everybody,

I'm progressing on the new AirPlay/AirTunes implementation, and AirTunes is working well. AirPlay is coming next.

But I need some help in parallel. I need a simple radar that can consistently scan the network, and return if any Apple Mac/iPhones/iPads are present. This will be used to trigger a Device Detected event on each media director to install the AirPlay Streamer device.

This can be accomplished as a two step process:

* for each IP address in the network:
* match its MAC address against the known Apple Computer MAC address ranges: http://standards.ieee.org/develop/regauth/oui/oui.txt

there are a LOT of MAC address ranges, and they all need to be matched against, but this way, we can effectively match. Don't worry about sending the Device Detected event, I just need something that can give me a 0 or a 1 if an apple device of any kind is on the network.

-Thom

Marie.O

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 3676
  • Wastes Life On LinuxMCE Since 2007
    • View Profile
    • My Home
Re: Need a shell scripter to develop mac/ipad/iphone detection routine
« Reply #1 on: March 24, 2013, 06:03:16 pm »
It seems Avahi shows _apple-mobdev._tcp for mobile Apple devices, and _atc._tcp for computers. At least I see that from running avahi-browse -art on the hotel network...

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Need a shell scripter to develop mac/ipad/iphone detection routine
« Reply #2 on: March 24, 2013, 06:06:00 pm »
mine however, do not show that.

-Thom

hari

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 2428
    • View Profile
    • ago control
Re: Need a shell scripter to develop mac/ipad/iphone detection routine
« Reply #3 on: March 24, 2013, 06:36:10 pm »
as possy said you should be able to detect apple devices via bonjour. That is saner than matching mac ranges..
rock your home - http://www.agocontrol.com home automation

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Need a shell scripter to develop mac/ipad/iphone detection routine
« Reply #4 on: March 24, 2013, 06:39:41 pm »
In the end, it does not matter, so long as it works most of the time. The plan here is to have the radars running on the md's, and if they detect anything, apple like, to fire a Device Detected event, which will cause the AirPlay Streamer to be installed on the target MD.

-Thom

Marie.O

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 3676
  • Wastes Life On LinuxMCE Since 2007
    • View Profile
    • My Home
Re: Need a shell scripter to develop mac/ipad/iphone detection routine
« Reply #5 on: March 24, 2013, 08:04:23 pm »
Why would you run it on the MDs? It should run on the core, and the core should take care of installing necessary packages.

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Need a shell scripter to develop mac/ipad/iphone detection routine
« Reply #6 on: March 24, 2013, 08:11:38 pm »
Because the player is on each MD.

-Thom

Armor Gnome

  • Guru
  • ****
  • Posts: 309
    • View Profile
Re: Need a shell scripter to develop mac/ipad/iphone detection routine
« Reply #7 on: March 26, 2013, 02:10:56 am »
Autodetection is smart.
Having a device picked up and configured automatically is a great experience.

It seems though after having watched syslog the last few days that there are quite a few jobs/radars/polls going on all the time to stay on-top of these new additions.

Does running something like this impact total network throughput?  I am at principle level understanding of network transmission and socket communications so perhaps I am only talking about a few bits through a 1000byte capable structure but with several HD movies traveling around etc... would this not slow things down?

The media update daemon has a user defined "on/off" via web-admin and a well documented console command.  Much like bluetooth pairing or z-wave inclusions, could radars such as this be built with search modes?  To make it easily accessible I could put down a list of radars/detection scripts and build a few pk_screens with checkboxes for on/off.  Standard 3:4. ui2 in 16x9, and whatever is needed for qt screens...

Would this be worthwhile?


I made a wiki!  Click here to check out my system.

Marie.O

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 3676
  • Wastes Life On LinuxMCE Since 2007
    • View Profile
    • My Home
Re: Need a shell scripter to develop mac/ipad/iphone detection routine
« Reply #8 on: March 26, 2013, 12:31:28 pm »
Because the player is on each MD.

Can't the core take care of setting up the necessary packages on each of the MDs?

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Need a shell scripter to develop mac/ipad/iphone detection routine
« Reply #9 on: March 26, 2013, 03:22:19 pm »
There is already infrastructure to detect devices on each computer. I am leveraging that.

It would be this:

1. mdns device loads.
2. mdns device scans, finds an apple via mdns...
3. mdns device sends a device detected on this computer of say, CAT:zeroconf_apple_device
4. plug and play plugin catches, matches to Airplay player template.
5. Airplay player installs. since there is a sister router plugin device in the related plugin section, the plugin is installed if needed.

This would take care of devices as media directors are installed, and would not need to have logic to crawl the database looking for new media directors, and keeping track of which ones have been installed, which ones haven't.

-Thom

Marie.O

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 3676
  • Wastes Life On LinuxMCE Since 2007
    • View Profile
    • My Home
Re: Need a shell scripter to develop mac/ipad/iphone detection routine
« Reply #10 on: March 26, 2013, 04:17:13 pm »
I was just thinking about some of the other radars. And iirc, they used to run on the MDs, but nowadays run on the core only.

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Need a shell scripter to develop mac/ipad/iphone detection routine
« Reply #11 on: March 26, 2013, 04:26:49 pm »
*nod* It's an odd spot to be in, it's either:

(1) run on the media directors, and follow the usual flow of device detection, or
(2) have the core do all the mdns device handling itself, and write logic specific for it.

-Thom

uplink

  • Administrator
  • Guru
  • *****
  • Posts: 192
  • Linux and LinuxMCE witchdoctor
    • View Profile
Re: Need a shell scripter to develop mac/ipad/iphone detection routine
« Reply #12 on: April 02, 2013, 05:53:55 pm »
So what you want is to create your device template, fill in the MAC address and let DHCP Plugin do its thing when the fruity gadgets request their IPs? Is that it?

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: Need a shell scripter to develop mac/ipad/iphone detection routine
« Reply #13 on: April 02, 2013, 06:08:16 pm »
if we can avoid having to keep mac address ranges, that would be great. The thought has crossed my mind to scan for Bonjour (Zeroconf) services, but I am having difficulty finding a consistent service I can BROWSE for, to find a mac.

-Thom

Marie.O

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 3676
  • Wastes Life On LinuxMCE Since 2007
    • View Profile
    • My Home
Re: Need a shell scripter to develop mac/ipad/iphone detection routine
« Reply #14 on: April 02, 2013, 07:03:06 pm »
The two hits I highlighted in the first post should work as a start. And if that needs to be extended, so be it...