Combined Bluetooth + P2P pairing
Purpose
Demonstrate one screen that chains classic Bluetooth attachment and Wi‑Fi P2P bonding to stand up the primary phone↔glasses link.
Entry points
Navigate from:
ClassicBtActivityafter picking a deviceMainPhoneActivity“connect” shortcut
Sample screen:
com.rokid.phone.ui.BtWifiConnectActivity
Platform
- Phone
Main files
Flow
- Read route args to determine whether you need BT, P2P, or both this pass.
- If BT is required:
- Resolve the target with
BluetoothAdapter.getRemoteDevice(). - Call
connectToServer()for classic transport.
- Resolve the target with
- After BT succeeds:
- Persist the device record.
- If P2P still needed, call
sendConnectP2pRequest().
- Subscribe to
IWifiP2PClientListener, find aWifiP2pDevicewhose friendly name matches the active BT device, callconnectDevice(). - Update global linkage state on success.
Key SDK pieces
- Classic BT client connect API
- Wi‑Fi P2P peer discovery + attach
- Automated P2P connect request helper
Notes for developers
Why Bluetooth first, P2P second
Control-plane traffic and many status sync messages prefer the classic BT lane; large payloads and high bandwidth features lean on P2P. Establishing BT first keeps control messages stable while the data plane lights up.
How P2P peers are matched today
Implementation keys off display names:
DeviceLinkerManager.mConnectingBluetoothDevice?.nameWifiP2pDevice.deviceName
For production hardening, augment with stable hardware IDs.
Caveats
- Timeout handling moves the screen to failure if nothing completes in time.
- If phone Wi‑Fi is off, flow fails fast with a toast.
- Identical device names from different units are not handled robustly yet.