# Android Node Project Log

## 2026-03-11

### CRITICAL: Gateway is ME (Lisa)
- The gateway IS running on this machine (Lisa)
- I can APPROVE nodes myself using: `openclaw nodes approve <node-id>`
- No need to wait for Stefy or external approval!

### Gateway IP Configuration
- **Emulator → Host**: Use 10.0.2.2 (emulator's special IP for host machine)
- **Real phone via USB**: Use 192.168.42.115 (laptop's USB IP)
- **Real phone via VPN**: Use 192.168.69.1 (phone's VPN IP)
- Port: 18789

### Node ID vs Client ID
- There's NO special "cli" client - it's just an Android device node
- The node connects to the gateway (me) with:
  - **node.id**: Generated hash from RSA public key (device fingerprint)
  - **client.id**: Just "android" or whatever string
  - **token**: The global pairing token initially

### Issue: Firewall was blocking port 18789
- FIXED: Removed iptables rule blocking TCP port 18789
- Now the Android app can actually reach the gateway

### Code Changes Made
1. **Hardcoded gateway config** (NodeService.kt):
   - IP: 10.0.2.2 (emulator's host)
   - port: 18789
   - token: 415fa3c21b7ef06f22aff571697d88c59c2dc67737681267
   - nodeId: android-node (temporary)

2. **Pairing flow implemented**:
   - App sends connect request → gets rejected → sends pairing request
   - Retry logic in NodeService reconnects after rejection
   - Gateway receives pairing request → I can approve it!

### Current Status (2026-03-11 18:05)
- Build: Working ✅
- Install: Working ✅
- Device Identity: PERSISTENT (RSA key pair in SharedPreferences) ✅
- Device ID: 6a19599727bd964992898ac4251a9e08c52ae4740d2b0c927c11dc5d424a92bf ✅
- Firewall: FIXED (removed block on port 18789) ✅
- Next: Rebuild APK with 10.0.2.2 IP, install, wait for pairing request, approve it

### How Pairing Works
1. App connects with token → Gateway rejects (device not registered)
2. App sends node.pair.request → Appears in `openclaw nodes pending`
3. I run `openclaw nodes approve <node-id>` → Device is registered
4. App reconnects → Now accepted!

### Files Modified
- `app/src/main/java/com/nexlab/openclaw/node/data/remote/NodeClient.kt` - Device identity persistence + pairing request
- `app/src/main/java/com/nexlab/openclaw/node/service/NodeService.kt` - Hardcoded config + retry logic
