AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
![]() Below is part of my home automation code in python. ![]() If the iPhone is in very deep sleep 'nmap' does not always find the phone, so I have made it check 10 times before it says the phone is not home. In the end I used 'nslookup' to find the IP address for the iPhones (in case the IP address did change as they are dynamic (but they actually never do on my router)) and 'nmap' to detect if the iPhone is on the network. I have a home automation system that turns on the heating and hot water (via an arduino and RF module) when I or my partner are home (that is our iPhones are detectable on the home WiFi). I have tried many many different approaches. I got it to work on my mac fairly quickly, but had a lot of trouble getting it to work right on my PC. So I have been working on the same issue for about a year now. Compared to creating connections or other distance computation methods out there - this method conserves battery on both sides and keeps airwave pollution to a minimum. If it returns nothing - phone is not nearby or bluetooth is switched off. This will not create a connection - but just say hi to it. Then do sudo hcitool name mac_of_your_device in your favourite script to figure out if the iphone is nearby. Then sudo bluez-test-device trusted mac_of_your_device. ![]() Then connect to your device (make sure its searchable) as: sudo bluez-simple-agent hci0 mac_of_your_device and say yes on both sides. ![]() Figure out mac of your phone device by making it searchable and then do ( hcitool scan) on rPi. Install bluetooth dongle on rPi as: ( sudo aptitude install bluetooth bluez-utils bluez-compat). No distance computation unlike some fancy algorithms out there - just present/absent can be done with very little power consumption on rPi and iPhone. Once the phone screen sleeps - it is out of bounds on wifi! I bet this is in the interest of battery life.īluetooth dongle worked. Wifi scan might work for some devices, but iOS ones do not connect when screen is off! My iphone 6 could be detected with simple arp command (gives table of ip and mac numbers of connected devices on the same subnet) but this would happen only when phone screen is lighted up. Much hunting - learned quite a bit - no luck detecting other peoples devices without much of a low level wireless scan - Bluetooth works for iphone if both are your own devices:
0 Comments
Read More
Leave a Reply. |