What's new
  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

To trace mobile MAC adress?

Bamsefar

Senior Member
Hi

In my home automation system I use a Fibaro HC2. Now I need to check if my mobile is home AND connected to the WiFi network.

I have a brand new Asus RT-AC87. I thought I install RMerlin firmware. What are my options to track if my mobile is connected to WiFi?

1) Is there any way I can write a script, on the AC87, that when my mobile gets an IP adress (from DHCP server) the script will call my Fibar HC2 API with a special HTTP request?

Or:

2) Can I from my HC2 somehow remote check which units are connected thru WiFi on th eAC87 thru some sort of web page, like the DDWRT firmware (Info.live.htm)?

Or:

3) Create a script, in AC87, that runs every 15 second that pings my mobile, and then calls HC2 API with a HTTP request?

The limits are: I can not send a ping from HC2 - I have no OS access at all, so I am clearly limited in what I can do inside my HC2. This is why I need more intelligence in the AC87 ;-)

Any ideas are welcome.
 
I don't know anything about home automation equipment, but in answer to your question 3); Yes that should be fairly straight forward.

1) Use the ASUS web interface to create IP reservations for your mobile and HC2 (assuming it uses DHCP) so that you know their IP addresses won't change.

2) Create a script that pings your mobile and if successful issue a "wget" command to the HC2.

3) Use "cru" to schedule a cron job to run your script each minute.
 
Thanks!

Anyone know if there is any way I can figure out which DHCP leases are used for the moment? It seems to be able on the web gui, so in theory I should be able to extract the same info within a script? Then I don't need to ping my mobile, just scan the list of active connections?
 
And it seems to be:

/var/lib/misc/dnsmasq.leases

Edit: well kind of - it lists the leases, however when someone disconnects the lease seems to be stuck... I need a list of active connections...
 
If you are only interested in wireless connections

wl -i eth1 assoclist (for 2.4 GHz)
wl -i eth2 assoclist (for 5 Ghz, but not sure if it works on the new 5 GHz hardware in the AC87)

will give you the list of active MAC addresses.


Also, google search 'dnsmasq man' for the dnsmasq documentation. dnsmasq can call a script whenever it hands out a DHCP address (you can configure with Merlin's scripting options).
 
Last edited:
And it seems to be:

/var/lib/misc/dnsmasq.leases

Edit: well kind of - it lists the leases, however when someone disconnects the lease seems to be stuck... I need a list of active connections...
The lease is not "stuck". DHCP's job is to hand out leases (and expire or renew them after a set period of time), not track whether the connection is in use. john9527's solution using "wl assoclist" is what you're after.
 
Very large thanks for your help and suggestions. I'll look into WL command - it works for 2.4 but as you wrote not for 5GHz, I'll look into the log to see if I can figure that one out.
 
wl is the command utility for Broadcom hardware.....maybe Merlin knows if there is an equivalent for the Quantenna hardware. I did a quick search and couldn't find anything.
 
I have not found anything either. However I did notice that the WEB GUI has what I am after under "Systemlogg - Wireless logg" (I guess, it is in Swedish here where I live so it could be translated incorrect - sorry!). How does one generate such a list?
 
On the RT-AC87U here is how to obtain a list of associated clients.

Code:
qcsapi_sockrpc get_count_assoc wifi0

This will tell you how many clients are associated. After that, you have to query the router for every client. So if you have a count of 2 clients:

Code:
qcsapi_sockrpc get_station_mac_addr wifi0 0
qcsapi_sockrpc get_station_mac_addr wifi0 1

This will return the MAC of associated clients 0 and 1 (the index starts at 0).
 
Knew the wizard would have the answer :D

That QTN userspace tool is the equivalent of BCM's wl command, with the added bonus that the client code is open source (unlike BCM where you have to guess by yourself). So you can get the list of commands from the source code, including a pretty good description as to what each command does.
 
I just would like to say: A very larg thanks to RMerlin, I have not written the script yet - however I now think I have all that is needed for my home automation to work with RT-AC87!

(And since Kong stoped develop R7000 DD-WRT I sort of changed from Netgear R7000 Kong version to RT-AC87 RMerlin version!)
 

Well, I can not read anything new in that - Kong did a good job, however he now has limited time to do so.

I also would like to point out that the firewall GUI part in DD_WRT does not support white lists (only allow what is on the whitelist - the opposit to blacklist, which only tells what is not allowed. I prefer white lists, so I know everything is off until I allow it). So just out of coincident the ASUSWRT firmware seems to offer white list....
 
Okay I now have a script that looks into the MAC adresses, however I get an error on the wget. So if anyone knows what I am doing wrong?

The script first:
Code:
#!/bin/sh

macadresser=`wl -i eth1 assoclist`

antal=`qcsapi_sockrpc get_count_assoc wifi0`

while [ $antal -gt 0 ]
do
  antal=`expr $antal - 1`
  macadresser="`qcsapi_sockrpc get_station_mac_addr wifi0 $antal`;$macadresser"
done

case "$macadresser" in
  *mac adress one*)
     if [ ! -f /tmp/HomeAutomation/Hemma ]
     then
       touch /tmp/HomeAutomation/Hemma
     fi
     ;;
  *mac adress two*)
     if [ ! -f /tmp/HomeAutomation/Hemma ]
     then
       touch /tmp/HomeAutomation/Hemma
     fi
     ;;
  *)
     if [ -f /tmp/HomeAutomation/Hemma ]
     then
       rm -f /tmp/HomeAutomation/Hemma
     fi
     ;;
esac

Then I started to test with wget:
Code:
wget http://192.168.1.131/api/callAction?deviceID=14&name=pressButton&arg1=3
and ended with:
wget: server returned error: HTTP/1.1 401 Unauthorized

So I need to add authorization somehow - does anyone know how?
Code:
wget --user=admin --password=xxx http://192.168.1.131/api/callAction?deviceID=14&name=pressButton&arg1=3
Code:
wget http://admin:xxx@192.168.1.131/api/callAction?deviceID=14&name=pressButton&arg1=3
Code:
wget admin:xxx@http://192.168.1.131/api/callAction?deviceID=14&name=pressButton&arg1=3
None of the above works - and I am googling, however I am either blind or just don't know what I am looking for...?
 
Last edited:

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Back
Top