Create a Persistent Wi‑Fi Direct Mesh Network on Android

19 min read Learn how to set up a lasting Wi‑Fi Direct mesh on Android, keep the group alive across reboots, and share files offline without rooting. October 02, 2026 13:00 How to Create a Persistent Wi‑Fi Direct Mesh Network on Android for Offline File Sharing (No Root)

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.

Why a Persistent Wi‑Fi Direct Group Matters

By default, Android’s Wi‑Fi Direct implementation works like this:

  • Device A creates a group (becomes the Group Owner).
  • Device B discovers the group and joins.
  • When the screen turns off, the group is torn down to save power.

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.

Before You Start

  • Battery: Keep the device charged to at least 50 % – Wi‑Fi Direct can be power‑hungry.
  • Wi‑Fi: Ensure the regular Wi‑Fi radio is on (the Direct radio uses the same chipset).
  • Android version: The steps work on Android 9 (Pie) and newer. Older versions may lack the wpa_cli command used for persistence.
  • Computer: You’ll need a PC (Windows, macOS, or Linux) with the Android SDK Platform‑Tools installed.
  • USB cable: Use a good data‑capable cable; charging‑only cables will not allow ADB communication.
Note: All commands are entered on the computer’s terminal (or Command Prompt). The Android device itself does not need root access.

Step 1 – Install and Verify ADB

  1. Download the Android SDK Platform‑Tools zip from the official Android developer site.
  2. Extract the folder to a convenient location (e.g., C:\adb on Windows or ~/adb on macOS/Linux).
  3. Open a terminal window and navigate to the folder:
    cd /path/to/adb
  4. Run adb version to confirm the tool is recognized.
  5. If the command is not found, add the folder to your system’s PATH variable.

Step 2 – Enable Developer Options and USB Debugging

  1. On the Android device, open Settings → About phone.
  2. Tap Build number seven times. You’ll see a toast: “You are now a developer!”.
  3. Go back to the main Settings page; a new entry Developer options appears.
  4. Enter Developer options and toggle USB debugging ON.
  5. When you connect the phone to the PC, a dialog asks to Allow USB debugging. Check “Always allow from this computer” and tap OK.

Step 3 – Verify ADB Connection

  1. Connect the phone via USB.
  2. In the terminal, run:
    adb devices
  3. You should see a line like XXXXXXXXXXXX device. If you see unauthorized, check the phone for the debugging dialog.

Step 4 – Create a Persistent Wi‑Fi Direct Group

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.

  1. Open a shell on the device:
    adb shell
  2. Switch to the root of the shell (no root needed; the command works under the regular user):
    su
    If the device refuses su, just press Enter. The command still works because wpa_cli is world‑readable.
  3. Enter the wpa_cli prompt:
    wpa_cli
  4. Issue the persistent‑group command:
    p2p_group_add persistent
  5. You’ll receive a response such as p2p-wlan0-0. That is the interface name of the new group.
  6. Exit wpa_cli by typing 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.

Step 5 – Configure the Group Owner (Optional)

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).

  1. Reconnect to the device you wish to be GO.
  2. Run the following two commands inside the wpa_cli prompt:
    p2p_set persistent 15
    p2p_group_add persistent
  3. The 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).

Step 6 – Verify the Persistent Group Exists

  1. Open a shell again:
    adb shell
  2. Run:
    wpa_cli list_networks
  3. You should see a line with p2p-wlan0-0 (or similar) and the SSID that looks like DIRECT-xx-DeviceName.
  4. To view details, use:
    wpa_cli get_network 0 ssid

If the network shows up, Android has stored it as a persistent entry.

Step 7 – Keep the Group Alive Across Reboots

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.

  1. Install Tasker from the Play Store.
  2. Open Tasker → Profiles → + → Event → System → Device Boot. This profile fires after every reboot.
  3. Tap New Task and give it a name like “Re‑create Wi‑Fi Direct”.
  4. Add an action: Code → Run Shell.
    • Command: wpa_cli p2p_group_add persistent
    • Use Root: Off (we don’t need root).
    • Store Output: Off.
  5. Save the task. The profile is now active.
  6. Reboot the phone to test. After the lock screen appears, pull down the notification shade and look for a “Tasker” notification that says the command ran.
  7. Open Settings → Wi‑Fi Direct. You should see the persistent group listed as “Connected”. If not, open a terminal on the phone (via Termux) and run wpa_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).

Step 8 – Share Files Within the Mesh

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.

  1. On the sending phone, open the file you want to share (e.g., a photo in the Gallery).
  2. Tap the Share icon → Wi‑Fi Direct.
  3. The device will scan for nearby groups. Your persistent group should appear with the SSID you noted earlier.
  4. Select the group; the receiving phone will prompt to accept the transfer.
  5. After acceptance, the file is transferred over the direct link – no internet required.

Because the group stays alive, you can repeat step 1 as many times as you need without re‑creating the connection each time.

Step 9 – Adding More Devices to the Mesh

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.

  1. Repeat Steps 4‑6 but change the SSID manually:
    adb shell "wpa_cli set_network 0 ssid \"\"MyMesh-2\"\""
  2. Run wpa_cli p2p_group_add persistent again. A second interface (e.g., p2p-wlan0-1) will be created.
  3. On each new device, join the appropriate group.
  4. Optionally, use a simple Android app like Wi‑Fi Direct – Simple (available on Play Store) to view all active groups at once.

Remember that each group consumes its own slice of the Wi‑Fi radio, so having many groups simultaneously can increase power draw.

Troubleshooting

Group disappears after screen timeout

  • Make sure the device’s Battery optimization for 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.
  • Enable Stay awake while charging in Developer options. This prevents the Wi‑Fi radio from sleeping when the device is plugged in.

Other phones can’t see the persistent group

  • Verify that the devices are on the same Wi‑Fi band (2.4 GHz). Some manufacturers force Wi‑Fi Direct to 5 GHz only, which older phones may not support.
  • Check the Wi‑Fi Direct MAC address in 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.

ADB reports “command not found: wpa_cli”

  • Some OEM skins hide 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.

Tasker fails to run the shell command

  • Make sure Tasker has the Run Shell permission in Android’s Accessibility settings. Go to Settings → Accessibility → Tasker → Enable.
  • If the device is running Android 12+, you may need to grant the android.permission.ACCESS_FINE_LOCATION permission to Tasker, because Wi‑Fi Direct scans are considered location‑related.

Safety and Battery Considerations

  • Keeping a Wi‑Fi Direct group alive consumes roughly 300‑500 mA when active. Expect a 5 %‑10 % battery drain per hour on a typical 3000 mAh phone.
  • Never enable the persistent group on a device that is also connected to a regular Wi‑Fi network – the two radios can interfere and cause instability.
  • If you plan to use the mesh for long periods (e.g., a weekend camping trip), keep at least one device plugged into a power bank.

Advanced Use Cases

Once you have a reliable mesh, you can extend its capabilities:

  • Local HTTP server: Install a lightweight server app (e.g., 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.
  • Peer‑to‑peer chat: Use an app that supports direct socket connections over Wi‑Fi Direct, such as Meshenger (open‑source on F-Droid).
  • Offline multiplayer gaming: Many games (e.g., BombSquad) can discover peers via Wi‑Fi Direct, giving you a local LAN without a router.

Cleaning Up – Removing the Persistent Group

  1. Open an ADB shell:
    adb shell
  2. Enter wpa_cli.
  3. List stored networks:
    list_networks
  4. Identify the network ID of the persistent group (usually 0).
  5. Remove it:
    remove_network 0
  6. Exit and reboot the device to ensure the group is gone.

After removal, the device will revert to the standard temporary Wi‑Fi Direct behaviour.

Wrapping Up

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.

User Comments (0)

Add Comment
We'll never share your email with anyone else.