Skip to content

Conversation

lollerfirst
Copy link
Contributor

@lollerfirst lollerfirst commented Sep 15, 2025

Description

bridge different local BLE meshes using a long-range WFD connection.
WFD neighbor is treated as just another peer in the mesh.

@lollerfirst lollerfirst marked this pull request as draft September 15, 2025 13:35
- Unified broadcast includes Wi‑Fi
- Visible Wi‑Fi Direct start/missing-permission logs
- Runtime permission request on toggle
- Wi‑Fi Direct connection manager with overlap handshake, single-link, INVITED hold, WPS PBC, timeout 5s
- Prefer Android_* peers; stop discovery before connect; ensure GO visibility
- Delegates wired through UnifiedConnectionManager/BluetoothMeshService
- Debug settings: enable, prefer unicast, overlap threshold

fix that doesn't work

WFD: break mutual INVITED and timeouts with strict MAC-based election & invitation gating

- Normalize MACs; hard-gate connect() until my/peer MAC known
- GO accept-only: ensure/create group and cancel any pending connect
- INVITATION_RECEIVED handler: accept if client by MAC; decline+ensure if GO
- Mutual INVITED tie-break: GO cancels; CLIENT continues
- Backoff remains for ERROR/BUSY; no role flip on TIMEOUT
- Added debug logs for decisions; hold after INVITED to avoid churn
- UI: add Force GO and Clear Persistent Groups buttons (placeholder logs)

fix build issues

WFD logs: emit DebugSettingsManager messages for election gating and mutual-invite decisions; fix receiver registration for Android 14}

Debug UI: add Wi‑Fi Direct status row (active, linkId, myP2pMac, last decision/candidate/error); update manager to publish status events}

Add Wi‑Fi Direct status state in DebugSettingsManager; publish active/myMac/decisions; show status row in DebugSettingsSheet}

Debug UI: add WifiDirectStatus state + setters in DebugSettingsManager; wire WFD status row references; fix unresolved references in WifiDirectConnectionManager and DebugSettingsSheet. Build now succeeds.

WFD: proactively request local P2P device info after discoverPeers/requestPeers; add requestMyDeviceInfo() (reflection on requestDeviceInfo) and call before peer election to learn myP2pMac ASAP.

WFD: after each discoverPeers and before election (requestPeersAndMaybeConnect), call requestMyDeviceInfo() to populate myP2pMac ASAP; implement requestMyDeviceInfo() using reflection on requestDeviceInfo (API29+) with fallback to requestPeers.

fix

Debug: add Wi‑Fi Direct role override (AUTO/GO/CLIENT)
- Prefs: persist wifi_direct_role_override
- DebugSettingsManager: StateFlow + setter setWifiDirectRoleOverride
- UI: role override chips in DebugSettingsSheet
- WifiDirectConnectionManager: respect override in preferGo(), iAmGoFor(), and election/connect flow; allow force GO even if local MAC unknown; keep GO accept-only behavior
- Visible system messages for override decisions

fix

WFD: unblock connection establishment
- Remove gating on local P2P MAC (myP2pMac) before initiating connect
- Always accept INVITATION_RECEIVED; cancel our own connect to break mutual-invite
- In peer selection, stop using MAC-based GO decision; attempt connect when AVAILABLE and not on backoff
- Keep backoff, timeout, and discovery-stop before connect
Note: overlap handshake is unchanged and will be fixed next.

WFD: fast recovery after TCP drop
- In readerLoop finally, query current P2P connection and:
  * If group formed and GO: restart one-shot server accept
  * If group formed and Client: reconnect TCP to GO address
  * Else: trigger discoverPeersOnce() and scheduleRescan()
- Clear attempted map to remove suppression after drop

WFD: remove all GO/Client forcing and flipping
- Delete preferGo() and iAmGoFor(); remove MAC-based election and role override usage
- Do not set groupOwnerIntent; let Android negotiate roles
- Do not ensure group as GO; ensureGroupVisibility() no-ops except removing stale group
- Always accept invites and cancel our own connect to break mutual INVITED
- Keep fast-recovery after TCP drop}

WFD: increase connect timeout to 20s; keep role-neutral flow
- Some Android stacks need >5s from INVITED to CONNECTION_CHANGED
- No explicit accept APIs exist; connect() on INVITATION_RECEIVED is correct way to accept

WFD: be tolerant to INVITED state without explicit INVITATION_RECEIVED
- Do not cancel our connect on seeing peers in INVITED (apps may not get the broadcast)
- Keep short hold to avoid busy-loop; let framework complete negotiation or our connect proceed
- This addresses repeated 5s/20s timeouts when INVITATION_RECEIVED is missed

WFD: after INVITED hold, proactively initiate connect if still stuck
- Many OEM stacks keep reporting INVITED for persistent groups; we try a fresh connect() after 4s grace
- Keeps role-neutral behavior and avoids deadlock when INVITATION_RECEIVED broadcast is missed

WFD: fix handshake sequencing and robustness
- Run overlap-gate handshake BEFORE starting reader; only attach link on success
- Add HANDSHAKE_TIMEOUT (5s) and temporary socket read timeout during handshake
- Handshake now returns Boolean; drop link on timeout or high overlap
- If app starts with existing P2P connection, attachSocket path will immediately run handshake and drop if necessary
- INVITED handling: after brief hold, proactively connect if stuck}

WFD: increase connect timeout to 30s; do not cancel when invited by an already-invited peer
- Some frameworks take >20s; 30s reduces spurious timeouts
- Avoid canceling our connect when peer shows INVITED; hold then proceed/connect if stuck

WFD: proactively attach when already CONNECTED; bind client socket to P2P network
- After start() and each peer scan, requestConnectionInfo if any peer is CONNECTED
- In connectToHost, try binding socket to the P2P ConnectivityManager Network before connect
- This avoids routing via wrong default network and should fix Connection Timed Out despite valid GO IP

fixes and remove mistakenly tracked build logs

remove more logs
…MessageType) at top; replace fully qualified references in WifiDirectConnectionManager
…log handshake; idempotent GO server; multi-port bind/dial; per-socket P2P binding with local addr bind; staged client retries; diagnostic network logs
…dialPrep diagnostics; GO: multi-port bind. Add interface-level P2P fallbacks and logs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant