[SOLVED] Search through connected MAC addresses possible?



  • Is something like this possible?

    The idea is that known MAC addresses are queryable and I can trigger a http call  to set a status bit

    I have searching all day.. trying to find appropriate script commands to do something similar..

    this is what works on DD-WRT

    #!/bin/sh
    # seconds between checks
    WATCHDOG_SLEEP_SEC=2
    # MAC Address 1
    MAC_ADDRESS_1="[XX:XX:XX:XX:XX:XX]"
    # MAC Address 2
    MAC_ADDRESS_2="[YY:YY:YY:YY:YY:YY]"
    # Vera VSwitch 1 Device ID
    VSWITCH_1="[99]"
    # Vera VSwitch 2 Device ID
    VSWITCH_2="[100]"
    
    #This loop will check if a device is registered on the AP and send the on/off command to vera. 
    
    while sleep $WATCHDOG_SLEEP_SEC
    do
    if wl assoclist | grep -Fq $MAC_ADDRESS_1
    then
        #echo Device 1 user is in
        wget -qs "http://[YOUR_VERA_IP_ADDRESS]:3480/data_request?id=lu_action&output_format=xml&DeviceNum=$VSWITCH_1&serviceId=urn:upnp-org:serviceId:VSwitch1&action=SetTarget&newTargetValue=1"
    else
        #echo Device 1 user is out
        wget -qs "http://[YOUR_VERA_IP_ADDRESS]:3480/data_request?id=lu_action&output_format=xml&DeviceNum=$VSWITCH_1&serviceId=urn:upnp-org:serviceId:VSwitch1&action=SetTarget&newTargetValue=0"
    fi
    
    if wl assoclist | grep -Fq $MAC_ADDRESS_2
    then
        wget -qs "http://[YOUR_VERA_IP_ADDRESS]:3480/data_request?id=lu_action&output_format=xml&DeviceNum=$VSWITCH_2&serviceId=urn:upnp-org:serviceId:VSwitch1&action=SetTarget&newTargetValue=1"
    else
        wget -qs "http://[YOUR_VERA_IP_ADDRESS]:3480/data_request?id=lu_action&output_format=xml&DeviceNum=$VSWITCH_2&serviceId=urn:upnp-org:serviceId:VSwitch1&action=SetTarget&newTargetValue=0"
    fi
    
    done
    &
    

  • Banned

    Look at /usr/local/www/status_wireless.php, modify that above accordingly, run from cron.



  • Hi
    thanks very much for looking at this..

    I should add.. I am really trying to look up any device is connected.. not just wireless devices..

    So far I am playing with things like arp lookup and  also trying to see if I can vary this command to get what I want …  ifconfig vtnet0 | grep ether

    i thought I might get something back from this command
    arp -na  | grep -Fq e8:5a:8b:b6:71:5c

    but my inexperience is showing


  • Banned

    @konradwalsh:

    i thought I might get something back from this command
    arp -na  | grep -Fq e8:5a:8b:b6:71:5c

    but my inexperience is showing

    What's the problem with that? It works just fine - will return 0 on success, 1 on failure. You can see that with

    
    arp -na  | grep -Fq aa:bb:cc:ff:ee:ff; echo  $?
    
    

    arp -na  | grep -Fq is exactly what you need for the script as far as wired clients are concerned.



  • yes you are right… i didn't test that command thoroughly enough..

    thanks again