0

I create a WI-FI AP with my phone(Phone A), then enable it successfully; then I use another phone(Phone B) to connect to the AP;

Now I want to know how I can get info of devices that are connecting to the AP created by Phone A;

It's better that I can listen for the event of a connection to the AP.

Who can help me ? or there're suggestions ?

Yin Young
  • 13
  • 3

1 Answers1

0

It seems no open APIs to do so. Here is a workaround, keep an eye on the file: /proc/net/arp You can test with this command: adb shell cat /proc/net/arp To get some result like this:

IP address       HW type     Flags       HW address            Mask     Device
192.168.43.83    0x1         0x2         80:c6:ab:4b:e9:4d     *        wlan0

This is the list of your DHCP clients that connected to your portable AP.

Robin
  • 10,052
  • 6
  • 31
  • 52
  • I get 2 addresses: 192.168.1.1 and 192.168.1.63, but Wifi Access Point is turned off, is that normal? – minipif Apr 09 '13 at 10:37
  • This is something like your own IP and route IP. The default LAN IP for portable AP should be some thing else. Did you try to start portable AP mode and connect some clients and then cat the file to see the list again? Or is there any difference for Flags/HWtype? – Robin Apr 09 '13 at 12:37
  • AP was off for weeks. `HW type` and `Flags` are the same. My guess is that `/proc/net/arp` holds an ASCII readable dump of the kernel ARP table used for address resolutions [(source)](http://www.tin.org/bin/man.cgi?section=5&topic=proc), that includes connected devices, but also any association of IP/MAC learnt from local network ARP messages. That would mean the workaround you described isn't a reliable way of detecting connected devices. – minipif Apr 09 '13 at 13:17
  • IMHO, you can manage the list of these devices and try to send ARP request to see if you can get the result. And from the change of this list you can tell if there is new device or removal of old device. – Robin Apr 09 '13 at 13:28