Package 

Class WatchSessionRelay


  • 
    public final class WatchSessionRelay
    
                        

    Phone-side relay that drives a session on a companion Wear OS watch over the Wearable Data Layer.

    • startSession sends a start_session command to every connected node.

    • The watch's engine streams events back on EVENT_PATH.

    • The returned Flow completes when the watch reports a terminal event (session_summary or session_error).

    The phone computes nothing here — the watch owns the session and this only carries commands out and events in.

    This logic previously lived only inside the cross-platform session plugin's Android module, which declares no maven-publish — so it was compiled into a plugin AAR that nothing could depend on. A native Android host, and synheart-core-kotlin, therefore had no way to run a watch session at all, even though the implementation existed and worked. It belongs here, with the rest of the session SDK, and that plugin should consume it rather than carry its own copy.

    The callback API it had there is replaced with a Flow; the Data Layer behaviour is otherwise unchanged, including the message paths, which the companion watch app already listens on.

    • Constructor Detail

      • WatchSessionRelay

        WatchSessionRelay(Context context)
    • Method Detail

      • status

         final WatchStatus status()

        Connectivity snapshot.

        Never throws: a Data Layer query failing is a disconnected watch, not an error the caller can act on, so it reports WatchStatus.reachable false while keeping supported honest about whether the transport exists.

      • hrSamples

         final Flow<WatchHrSample> hrSamples()

        Heart-rate samples the watch measured.

        Separate from startSession's event flow, and independent of it: the watch owns the sensor, and its readings are the phone's only biosignal source in this arrangement — the phone has no PPG. A host forwards these into the engine so HSI has physiology to work with; without that the five canonical axes stay at zero confidence no matter how long the watch measures.

        Emits whenever a sample arrives, session or not. Nothing here interprets the values.

      • startSession

         final Flow<SessionEvent> startSession(SessionConfig config)

        Start a session on the watch and stream its events.

        The flow registers the Data Layer listener before sending the command, so an event cannot be missed between the two. It completes on the watch's terminal event, and unregisters on completion or cancellation.

        Emits a SessionErrorEvent rather than throwing when no node is connected: a watch going out of range is an ordinary runtime condition that a caller renders, not an exception.

      • stopSession

         final Unit stopSession(String sessionId)

        Ask the watch to stop a session.

        Best-effort and silent on failure: the watch also stops on its own duration timer, so a dropped stop command ends the session late rather than leaving it running forever.