mady4ever / android-testhotspot

Android HotSpot Api and much more.
57 stars 37 forks source link

[Question] It is possible to check connected clients #3

Open luispereira opened 7 years ago

luispereira commented 7 years ago

Hi, I was wondering if it is possible to know when a client is connected to the hotspot, by a listener or a broadcast.

ParagRKadam commented 7 years ago

I too have the same question. Along with that I would also want to know whether is it possible to get the list of all the client devices not only connected to the hotspot but also available within hotspot range.

luispereira commented 7 years ago

Hi @ParagRKadam, until now I could only see that there is a file which is updated with all the clients, but is not 100% updated (meaning that might exists clients on the file which are no longer connected). This file does not require any additional permission to access it. This file is a on /proc/net/arp. There is also another file, which is available for rooted devices which is updated every time a client connects and disconnects on /data/misc/dhcp/dnsmasq.leases

ParagRKadam commented 7 years ago

If you want to get the list of connected clients then you should use this library -> https://github.com/nickrussler/Android-Wifi-Hotspot-Manager-Class /proc/net/arp has the list all the current and previous clients as you said hence it does not suit my usecase and root is not an option hence i cannot use the file /data/misc/dhcp/dnsmasq.leases.

luispereira commented 7 years ago

Hi @ParagRKadam, you cannot know clients in range which are not connected. However, you can force all connected clients to respond by udp wifi broadcast.