When you travel to a place with no cellular data or Wi‑Fi, a quick way to exchange photos, documents, or even small videos between Android phones is Wi‑Fi Direct. The feature works like a tiny ad‑hoc Wi‑Fi network – no router, no internet, just a direct link between devices. The downside is that Android’s built‑in UI creates a temporary group that disappears as soon as the screen turns off or the device reboots. This tutorial shows how to turn that fleeting connection into a persistent mesh that survives reboots and can be used by any number of phones in the same area.
By default, Android’s Wi‑Fi Direct implementation works like this:
For a one‑off file transfer that’s fine, but if you want a mesh – a small network that stays up for hours, lets several phones join, and survives a quick reboot – you need a persistent group. Persistent groups are stored in the Wi‑Fi Direct stack and can be re‑instantiated automatically.
wpa_cli command used for persistence.C:\adb on Windows or ~/adb on macOS/Linux).cd /path/to/adb
adb version to confirm the tool is recognized.adb devices
XXXXXXXXXXXX device. If you see unauthorized, check the phone for the debugging dialog.Android’s Wi‑Fi Direct stack is driven by wpa_supplicant. The wpa_cli utility can issue commands to that daemon. We’ll ask it to create a persistent group.
adb shell
su
su, just press Enter. The command still works because wpa_cli is world‑readable.wpa_cli
p2p_group_add persistent
p2p-wlan0-0. That is the interface name of the new group.quit and then leave the ADB shell with exit.At this point the system has stored a group definition (SSID, passphrase, owner MAC) in its internal database. The next time Wi‑Fi Direct is turned on, Android can re‑instantiate the same group without user interaction.
By default the device that runs p2p_group_add becomes the Group Owner (GO). If you want a different phone to act as GO, you can create the group on that phone instead, or you can force the role with the p2p_go_intent parameter (values 0‑15, higher means stronger desire to be GO).
wpa_cli prompt:
p2p_set persistent 15
p2p_group_add persistent
15 value tells the stack that this device strongly prefers to be GO.If you later decide to change the GO, simply delete the existing persistent group and recreate it on the new device (see Step 9).
adb shell
wpa_cli list_networks
p2p-wlan0-0 (or similar) and the SSID that looks like DIRECT-xx-DeviceName.wpa_cli get_network 0 ssid
If the network shows up, Android has stored it as a persistent entry.
Android does not automatically re‑activate a persistent group when the Wi‑Fi radio powers back on. To make the mesh truly persistent, we’ll add a small automation that runs the p2p_group_add persistent command each time the device boots.
Because we have no root, we rely on the Tasker app (free trial version works) to launch an ADB‑like shell command via the Run Shell action. Tasker can execute commands as the user shell, which has permission to talk to wpa_cli.
wpa_cli p2p_group_add persistentwpa_cli status to confirm the group is up.Tasker’s Run Shell works because the wpa_cli binary is world‑executable. If a particular OEM disables it, you can fall back to a manual ADB command (see Step 9).
Once the persistent group is active, any Android device that supports Wi‑Fi Direct can join. The built‑in Files (or My Files) app on most phones already includes a “Share via Wi‑Fi Direct” option.
Because the group stays alive, you can repeat step 1 as many times as you need without re‑creating the connection each time.
Wi‑Fi Direct groups are limited to a handful of peers (usually up to 8). To expand the mesh, you can create multiple persistent groups on the same device, each with a different SSID. Devices can hop between groups, effectively forming a larger ad‑hoc network.
adb shell "wpa_cli set_network 0 ssid \"\"MyMesh-2\"\""
wpa_cli p2p_group_add persistent again. A second interface (e.g., p2p-wlan0-1) will be created.Remember that each group consumes its own slice of the Wi‑Fi radio, so having many groups simultaneously can increase power draw.
Settings (or the Wi‑Fi Direct UI) is set to Don’t optimize. On Android 9+, go to Settings → Battery → Battery optimization → All apps → Settings → Don’t optimize.adb shell dumpsys wifi p2p. If the address is randomized, disable “MAC randomization” for Wi‑Fi Direct in Settings → Network & internet → Wi‑Fi → Advanced → MAC address type → Phone MAC.wpa_cli. Install the Termux app, then run apt update && apt install wpa-supplicant. After installation, you can invoke wpa_cli from the Termux shell, and the same commands work.android.permission.ACCESS_FINE_LOCATION permission to Tasker, because Wi‑Fi Direct scans are considered location‑related.Once you have a reliable mesh, you can extend its capabilities:
Simple HTTP Server) on the Group Owner. Other phones can browse the server’s address (usually 192.168.49.1) to download multiple files at once.Meshenger (open‑source on F-Droid).adb shell
wpa_cli.
list_networks
0).remove_network 0
After removal, the device will revert to the standard temporary Wi‑Fi Direct behaviour.
By following the steps above you now have a persistent Wi‑Fi Direct mesh that survives reboots, can host multiple peers, and lets you transfer files without any internet connection. The combination of ADB, wpa_cli, and a lightweight automation app like Tasker gives you full control while keeping the device unrooted and safe.
Feel free to experiment with multiple groups, local servers, or even a small offline chat system – the mesh is a versatile foundation for any situation where connectivity is limited but direct device‑to‑device communication is essential.









