Skip to content

feat: implement NodeApi and DataApi for WearOS support#3517

Open
chaudl113 wants to merge 2 commits into
microg:masterfrom
chaudl113:feat/wearable-api-impl
Open

feat: implement NodeApi and DataApi for WearOS support#3517
chaudl113 wants to merge 2 commits into
microg:masterfrom
chaudl113:feat/wearable-api-impl

Conversation

@chaudl113
Copy link
Copy Markdown

Partial fix for #2843

Summary

Replace stubs in NodeApiImpl and DataApiImpl with working implementations using the existing pattern (same approach as MessageApiImpl).

Changes

NodeApiImpl

  • getLocalNode() - get local device node info via WearableServiceImpl
  • getConnectedNodes() - list connected wearable nodes
  • addListener() - register for node change events (NODE_CHANGED)
  • removeListener() - unregister listener

DataApiImpl

  • getDataItem() - fetch single data item by URI
  • getDataItems() - fetch all data items or filter by URI
  • putDataItem() - create/update data item with PutDataRequest
  • deleteDataItems() - remove data items by URI
  • getFdForAsset() - get file descriptor for asset (by digest)
  • addListener()/removeListener() - data change listeners

Architecture

Both implementations delegate to WearableServiceImpl via GmsConnector.call(), which already has working implementations for all these operations. This follows the same pattern used by MessageApiImpl.sendMessage().

Testing

  • All API methods now return proper results instead of throwing
  • Node discovery works with existing NodeDatabaseHelper
  • Data operations use existing DataItemRecord storage
  • Listeners registered via IWearableListener proxy

Next Steps (Phase 2-4)

  • Implement CompanionDeviceManager pairing flow
  • Add Bluetooth/WiFi transport layer
  • Implement notification sync via MessageApi
  • Add WearOS companion app integration

chaudl113 added 2 commits May 31, 2026 09:16
Replace UnsupportedOperationException stubs with working implementations
using the GmsConnector pattern (same as MessageApiImpl).

NodeApiImpl:
- getLocalNode() - get local device node info
- getConnectedNodes() - list connected wearable nodes
- addListener() - register for node change events
- removeListener() - unregister listener

DataApiImpl:
- getDataItem() - fetch single data item by URI
- getDataItems() - fetch all data items or by URI
- putDataItem() - create/update data item
- deleteDataItems() - remove data items
- getFdForAsset() - get file descriptor for asset
- addListener/removeListener - data change listeners

Both delegate to WearableServiceImpl via GmsConnector.call(),
which already has working implementations for all these operations.

Partial fix for microg#2843
Phase 2 - Transport Layer:

WearableConnection:
- TCP socket connection with read/write threads
- RootMessage protocol encoding/decoding
- Thread-safe message queue for writes
- Connection lifecycle management

SocketConnectionThread:
- TCP server listening on port 5601 (WearOS standard)
- Single connection management
- Accept loop with graceful shutdown

ServerMessageListener:
- Base listener for wearable protocol messages
- Connect/Disconnect handshake handling
- Heartbeat response
- Connection lifecycle callbacks

These classes implement the transport layer that WearableImpl
expects for communicating with WearOS devices.

Partial fix for microg#2843
@chaudl113
Copy link
Copy Markdown
Author

Phase 2 Update - Transport Layer

Added TCP transport layer for WearOS device communication:

WearableConnection

  • TCP socket with read/write threads
  • RootMessage protocol encode/decode via Wire
  • Thread-safe message queue
  • Connection lifecycle management

SocketConnectionThread

  • TCP server on port 5601 (WearOS standard)
  • Single connection management
  • Accept loop with graceful shutdown

ServerMessageListener

  • Connect/Disconnect handshake
  • Heartbeat response
  • Connection lifecycle callbacks

Summary (Phase 1 + 2)

  • ✅ NodeApi implementation (getLocalNode, getConnectedNodes, addListener)
  • ✅ DataApi implementation (getDataItem, putDataItem, deleteDataItems, getFdForAsset)
  • ✅ MessageApi already implemented (sendMessage)
  • ✅ TCP transport layer (port 5601)
  • ✅ Protocol handshake (Connect/Disconnect)
  • ✅ Heartbeat keep-alive

Next (Phase 3)

  • CompanionDeviceManager pairing UI
  • Notification sync via MessageApi
  • Media controls relay

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