### Install AI Assistant Skills Scripts Source: https://wearables.developer.meta.com/docs/ai-assisted Run these shell scripts to install SDK knowledge configuration files for various AI coding tools. Use 'all' to install for all supported tools. ```shell ./install-skills.sh claude # Claude Code only ./install-skills.sh copilot # GitHub Copilot only ./install-skills.sh cursor # Cursor only ./install-skills.sh agents # AGENTS.md only ./install-skills.sh all # All tools ``` -------------------------------- ### Start a Session Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_session_session Starts the session and connects to the device. This is a fire-and-forget method; observe the session state for transitions and errors. ```kotlin session.start() ``` -------------------------------- ### Create and Start Device Session Source: https://wearables.developer.meta.com/docs/reference/ios_swift/dat/0.6/mwdatcore_devicesession Demonstrates how to create a DeviceSession using a device selector and then start the session to connect to the device. Observe the statePublisher for state changes. ```swift let session = try Wearables.shared.createSession(deviceSelector: myDeviceSelector) let stateObservation = session.statePublisher.sink { state in // Observe state changes print("Session state changed to: \(state)") } try session.start() // Session is now starting, observe statePublisher for DeviceSessionState.started ``` -------------------------------- ### Install Cursor CLI Source: https://wearables.developer.meta.com/docs/ai-assisted-cursor Install the Cursor SDK using the provided shell script. This is the primary method if you have cloned the SDK repository. ```bash ./install-skills.sh cursor ``` -------------------------------- ### start() Source: https://wearables.developer.meta.com/docs/reference/ios_swift/dat/0.6/mwdatcore_devicesession Initiates the connection to the wearable device. It performs validation checks and transitions the session state to 'starting'. If validation fails, the session remains 'idle' and an error is thrown. ```APIDOC ## start() Starts the session, connecting to the device. Validates that the device is available, compatible, and connected before transitioning to DeviceSessionState.starting. If validation fails, the session stays in DeviceSessionState.idle and the error is thrown, allowing the caller to retry later. Signature ```swift public func start() ``` Throws ``` -------------------------------- ### Install All Tool Configs Source: https://wearables.developer.meta.com/docs/ai-assisted-agents-md This command installs all available tool configurations, including AGENTS.md, for Android projects. It fetches a script that adds the necessary files. ```bash curl -sL https://raw.githubusercontent.com/facebook/meta-wearables-dat-android/main/install-skills.sh | bash -s -- all ``` -------------------------------- ### Install Copilot Skills Locally Source: https://wearables.developer.meta.com/docs/ai-assisted-github-copilot Run this command in your terminal to install Copilot skills if you have cloned the SDK repository locally. ```bash ./install-skills.sh copilot ``` -------------------------------- ### Create and Start a New Session Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_wearables Creates a new session for a device matching the provided selector. The session starts in the IDLE state and must be explicitly started using `session.start()`. Handles errors like no eligible devices or existing sessions. ```kotlin val session = Wearables.createSession(AutoDeviceSelector()).getOrElse { error -> showError(error.description) return } session.start() ``` -------------------------------- ### Stream Start Method Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_camera_stream Starts the stream, activating the camera and beginning the video streaming pipeline. Call this after obtaining a Stream from Session.addStream. ```kotlin abstract fun start(): DatResult ``` -------------------------------- ### Start iOS Stream Session with HFP Audio Source: https://wearables.developer.meta.com/docs/microphones-and-speakers This function demonstrates how to start a streaming session after ensuring the HFP audio session is configured. It includes a placeholder for coordinating HFP readiness before starting the stream. ```Swift func startStreamSessionWithAudio() async { // Set up the HFP audio session startAudioSession() // Instead of waiting for a fixed 2 seconds, use a state-based coordination that waits for HFP to be ready try? await Task.sleep(nanoseconds: 2 * NSEC_PER_SEC) // Start the stream session as usual await streamSession.start() } ``` -------------------------------- ### start Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_session_session Starts the session, connecting to the device resolved during Wearables.createSession. This method is sync fire-and-forget: it returns immediately and the connection proceeds in the background. Observe Session.state for DeviceSessionState.STARTING → DeviceSessionState.STARTED transitions, and Session.errors for failure details. Calling Session.start on a session that is not in DeviceSessionState.IDLE is a no-op. ```APIDOC ## start ### Description Starts the session, connecting to the device resolved during Wearables.createSession. This method is sync fire-and-forget: it returns immediately and the connection proceeds in the background. Observe Session.state for DeviceSessionState.STARTING → DeviceSessionState.STARTED transitions, and Session.errors for failure details. Calling Session.start on a session that is not in DeviceSessionState.IDLE is a no-op. ### Signature ```kotlin fun start() ``` ### Parameters None ### Request Example ```kotlin session.start() ``` ### Response This method does not return a value. Observe session state and errors for connection status. ``` -------------------------------- ### Install Claude Code via CLI Source: https://wearables.developer.meta.com/docs/ai-assisted-claude-code Use this command to install Claude Code if you have cloned the SDK repository. ```bash ./install-skills.sh claude ``` -------------------------------- ### Install AGENTS.md for iOS Source: https://wearables.developer.meta.com/docs/ai-assisted-agents-md Use this command to install the AGENTS.md configuration for iOS projects. It fetches a script that adds the necessary files. ```bash curl -sL https://raw.githubusercontent.com/facebook/meta-wearables-dat-ios/main/install-skills.sh | bash -s -- agents ``` -------------------------------- ### Install AGENTS.md for Android Source: https://wearables.developer.meta.com/docs/ai-assisted-agents-md Use this command to install the AGENTS.md configuration for Android projects. It fetches a script that adds the necessary files. ```bash curl -sL https://raw.githubusercontent.com/facebook/meta-wearables-dat-android/main/install-skills.sh | bash -s -- agents ``` -------------------------------- ### Install Cursor iOS Remote Source: https://wearables.developer.meta.com/docs/ai-assisted-cursor Install the Cursor SDK for iOS using a remote curl command. This method fetches the installation script from a GitHub repository. ```bash curl -sL https://raw.githubusercontent.com/facebook/meta-wearables-dat-ios/main/install-skills.sh | bash -s cursor ``` -------------------------------- ### Install Cursor Android Remote Source: https://wearables.developer.meta.com/docs/ai-assisted-cursor Install the Cursor SDK for Android using a remote curl command. This method fetches the installation script from a GitHub repository. ```bash curl -sL https://raw.githubusercontent.com/facebook/meta-wearables-dat-android/main/install-skills.sh | bash -s cursor ``` -------------------------------- ### Prompt Claude Code for Implementation Source: https://wearables.developer.meta.com/docs/ai-assisted-claude-code Example prompts demonstrating how to ask Claude Code for specific implementation details or test generation. ```text > How do I set up camera streaming in my Android app? > Write a test for my session lifecycle using MockDeviceKit ``` -------------------------------- ### Install Copilot Skills Remotely (Android) Source: https://wearables.developer.meta.com/docs/ai-assisted-github-copilot Use this curl command to install Copilot skills for Android development remotely. ```bash curl -sL https://raw.githubusercontent.com/facebook/meta-wearables-dat-android/main/install-skills.sh | bash -s copilot ``` -------------------------------- ### Install Android AI Assistant Skills Remotely Source: https://wearables.developer.meta.com/docs/ai-assisted Use this curl command to remotely install all AI assistant skills configurations for the Android SDK. Ensure you have curl installed. ```shell curl -sL https://raw.githubusercontent.com/facebook/meta-wearables-dat-android/main/install-skills.sh | bash ``` -------------------------------- ### Start a Camera Stream Source: https://wearables.developer.meta.com/docs/build-integration-ios Create a stream by adding it to an existing `DeviceSession`, and observe its state and display frames. Configuration options for resolution and frame rate are available. ```APIDOC ## Start a camera stream Create a stream by adding it to an existing `DeviceSession`, and observe its state and display frames. You can request resolution and frame rate control using `StreamSessionConfig`. Valid `frameRate` values are `2`, `7`, `15`, `24`, or `30` FPS. `resolution` can be set to: * `high`: 720 x 1280 pixels * `medium`: 504 x 896 pixels * `low`: 360 x 640 pixels `StreamSessionState` transitions through `stopping`, `stopped`, `waitingForDevice`, `starting`, `streaming`, and `paused`. Register callbacks to collect frames and state events. ```swift let config = StreamSessionConfig( videoCodec: VideoCodec.raw, resolution: StreamingResolution.low, frameRate: 24) guard let stream = try? session.addStream(config: config) else { return } let stateToken = stream.statePublisher.listen { state in Task { @MainActor in // Update your streaming UI state } } let frameToken = stream.videoFramePublisher.listen { frame in guard let image = frame.makeUIImage() else { return } Task { @MainActor in // Render the frame in your preview surface } } Task { await stream.start() } ``` Resolution and frame rate are constrained by the Bluetooth Classic connection between the user’s phone and their AI glasses. To manage limited bandwidth, an automatic ladder reduces quality as needed. It first lowers the resolution by one step (for example, from `high` to `medium`). If bandwidth remains constrained, it then reduces the frame rate (for example, 30 to 24), but never below 15 fps. The image delivered to your app may appear lower quality than expected, even when the resolution reports `high` or `medium`. This is due to per‑frame compression that adapts to available Bluetooth Classic bandwidth. Requesting a lower resolution, a lower frame rate, or both can yield higher visual quality with less compression loss. ``` -------------------------------- ### Start DeviceSession Monitoring Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_session_devicesession Initiates device monitoring and establishes connections when matching devices are available. The session transitions to STARTED upon connection and STOPPED upon disconnection. ```kotlin fun start() ``` -------------------------------- ### Install iOS AI Assistant Skills Remotely Source: https://wearables.developer.meta.com/docs/ai-assisted Use this curl command to remotely install all AI assistant skills configurations for the iOS SDK. Ensure you have curl installed. ```shell curl -sL https://raw.githubusercontent.com/facebook/meta-wearables-dat-ios/main/install-skills.sh | bash ``` -------------------------------- ### Install Claude Code for Android Source: https://wearables.developer.meta.com/docs/ai-assisted-claude-code Install Claude Code for Android integrations using curl to fetch and execute the installation script. ```bash curl -sL https://raw.githubusercontent.com/facebook/meta-wearables-dat-android/main/install-skills.sh | bash -s claude ``` -------------------------------- ### Install Claude Code for iOS Source: https://wearables.developer.meta.com/docs/ai-assisted-claude-code Install Claude Code for iOS integrations using curl to fetch and execute the installation script. ```bash curl -sL https://raw.githubusercontent.com/facebook/meta-wearables-dat-ios/main/install-skills.sh | bash -s claude ``` -------------------------------- ### DeviceSession.start Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_session_devicesession Starts monitoring for devices and establishes sessions when matching devices become available. This method begins monitoring the device availability through the configured DeviceSelector. ```APIDOC ## DeviceSession.start ### Description Starts monitoring for devices and establishes sessions when matching devices become available. This method begins monitoring the device availability through the configured DeviceSelector. ### Signature ``` fun start() ``` ``` -------------------------------- ### Start Claude Code in Project Directory Source: https://wearables.developer.meta.com/docs/ai-assisted-claude-code Execute this command in your project's root directory to launch Claude Code. ```bash claude ``` -------------------------------- ### Install Copilot Skills Remotely (iOS) Source: https://wearables.developer.meta.com/docs/ai-assisted-github-copilot Use this curl command to install Copilot skills for iOS development remotely. ```bash curl -sL https://raw.githubusercontent.com/facebook/meta-wearables-dat-ios/main/install-skills.sh | bash -s copilot ``` -------------------------------- ### DeviceSession Lifecycle Source: https://wearables.developer.meta.com/docs/reference/ios_swift/dat/0.6/mwdatcore_devicesession Illustrates the typical lifecycle of a DeviceSession, from creation to starting, attaching capabilities, and stopping. ```APIDOC ## DeviceSession Lifecycle 1. Create via `Wearables.shared.createSession(deviceSelector:)` 2. Observe statePublisher or stateStream() for state changes 3. Call start() to connect 4. Attach capabilities (e.g., `addStream()`) 5. Call stop() to disconnect (cascades to all attached capabilities) Sessions are not reusable — after reaching DeviceSessionState.stopped, create a new session via the factory. ``` -------------------------------- ### Start Wearables Registration Source: https://wearables.developer.meta.com/docs/build-integration-ios Initiate the registration process with the Meta AI app. This can be done at app startup or when the user enables wearables integration. Includes functions for starting and ending registration, and handling callbacks. ```swift func startRegistration() throws { try Wearables.shared.startRegistration() } ``` ```swift func startUnregistration() throws { try Wearables.shared.startUnregistration() } ``` ```swift func handleWearablesCallback(url: URL) async throws { _ = try await Wearables.shared.handleUrl(url) } ``` -------------------------------- ### Start Camera Stream with Configuration Source: https://wearables.developer.meta.com/docs/build-integration-ios Add a camera stream to an existing `DeviceSession` with specified video codec, resolution, and frame rate. Observe stream state and video frames. Bandwidth limitations may affect actual quality. ```swift let config = StreamSessionConfig( videoCodec: VideoCodec.raw, resolution: StreamingResolution.low, frameRate: 24) guard let stream = try? session.addStream(config: config) else { return } let stateToken = stream.statePublisher.listen { state in Task { @MainActor in // Update your streaming UI state } } ``` ```swift let frameToken = stream.videoFramePublisher.listen { frame in guard let image = frame.makeUIImage() else { return } Task { @MainActor in // Render the frame in your preview surface } } ``` ```swift Task { await stream.start() } ``` -------------------------------- ### Create Device Session with Auto Selector Source: https://wearables.developer.meta.com/docs/build-integration-ios Create a session with a Meta Wearable Device using `AutoDeviceSelector` for smart device selection. Start the session and observe its state changes. ```swift let deviceSelector = AutoDeviceSelector(wearables: wearables) let session = try wearables.createSession(deviceSelector: deviceSelector) let stateStream = session.stateStream() try session.start() for await state in stateStream { if state == .started { ... } else if state == .stopped { ... } } ``` -------------------------------- ### Create Session with Default AutoDeviceSelector Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_selectors_autodeviceselector Use the default AutoDeviceSelector to create a session with the first connected and compatible device. No additional setup is required. ```kotlin val session = Wearables.createSession(AutoDeviceSelector()) ``` -------------------------------- ### Start Video Streaming - StreamSession Source: https://wearables.developer.meta.com/docs/reference/ios_swift/dat/0.6/mwdatcamera_streamsession Starts video streaming from the device. Automatically connects when a device becomes available and publishes errors if the device is invalid. The session automatically stops when an error occurs or when the device session ends externally. ```swift public func start() ``` -------------------------------- ### Create Session with SpecificDeviceSelector Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_selectors_specificdeviceselector Demonstrates how to get a specific device from connected devices and create a session targeting it using SpecificDeviceSelector. This is useful when you need to ensure operations are directed to a particular device. ```kotlin // Get a specific device from the connected devices val devices = Wearables.devices.value val targetDevice = devices.firstOrNull { deviceId -> Wearables.devicesMetadata[deviceId]?.value?.name == "My Glasses" } // Create session targeting that specific device targetDevice?.let { device -> val session = Wearables.createSession( SpecificDeviceSelector(device) ) } ``` -------------------------------- ### Observe Device Session State Changes Source: https://wearables.developer.meta.com/docs/reference/ios_swift/dat/0.6/mwdatcore_devicesession Shows how to use stateStream() to create an AsyncStream for observing session state changes. It's recommended to create the stream before calling start() to capture initial transitions. ```swift let stateStream = session.stateStream() Task { for await state in stateStream { print("Session state changed to: \(state)") } } ``` -------------------------------- ### createSession Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_wearables Creates a new session for a device. If no compatible device is found or an active session already exists, an error is returned. The session starts in the IDLE state. ```APIDOC ## createSession ( deviceSelector ) ### Description Creates a new session for a device matching the provided selector. The device is resolved eagerly against the current Wearables.devices snapshot. If no connected and compatible device matches, SessionError.NO_ELIGIBLE_DEVICE is returned. If an active (non-stopped) session already exists SessionError.SESSION_ALREADY_EXISTS is returned. (singleton-per-device guarantee). The returned session starts in DeviceSessionState.IDLE. Call Session.start to begin connecting to the device. ### Example ```kotlin val session = Wearables.createSession(AutoDeviceSelector()).getOrElse { error -> showError(error.description) return } session.start() ``` ### Signature ```kotlin fun createSession(deviceSelector: DeviceSelector): DatResult ``` ### Parameters * `deviceSelector` (DeviceSelector) - The selector used to determine which device to connect to ### Returns `DatResult` - DatResult containing the Session on success, or SessionError on failure. ### Throws `WearablesException` - if SDK not initialized via Wearables.initialize ``` -------------------------------- ### Ask Copilot Chat SDK Questions (iOS) Source: https://wearables.developer.meta.com/docs/ai-assisted-github-copilot Example prompt for Copilot Chat to ask about requesting camera permissions in an iOS DAT app. ```text How do I request camera permissions in my iOS DAT app? ``` -------------------------------- ### Create a Device Session Source: https://wearables.developer.meta.com/docs/build-integration-android Use `createSession` to establish a connection with a Meta Wearable Device. `AutoDeviceSelector` can be used for automatic device selection, or `SpecificDeviceSelector` for manual selection via a UI. The session must be started after creation. ```kotlin val session = Wearables.createSession(AutoDeviceSelector()).getOrElse { showError(error.description) return } session.start() ``` -------------------------------- ### Ask SDK Questions with Cursor Chat Source: https://wearables.developer.meta.com/docs/ai-assisted-cursor Use Cursor Chat to query the SDK for information or assistance. This example shows a prompt for setting up a DAT session with camera streaming. ```plaintext Set up a DAT session with camera streaming and handle lifecycle events. ``` -------------------------------- ### Start a Camera Stream Source: https://wearables.developer.meta.com/docs/build-integration-android Add a camera stream to an active session using `addStream` with a `StreamConfiguration`. Observe video frames and state transitions via Kotlin coroutines. The stream automatically adjusts quality based on Bluetooth bandwidth, potentially reducing resolution or frame rate. ```kotlin fun start(deviceId: DeviceIdentifier) { val config = StreamConfiguration(videoQuality = VideoQuality.MEDIUM, frameRate = 24) val streamSession = session.addStream(config) scope.launch { streamSession.videoStream.collect { displayFrame(it) } } scope.launch { streamSession.state.collect { updateStreamUi(it) if (it == StreamSessionState.STOPPED) { stopStream() } } } } ``` -------------------------------- ### Manage Camera Permissions Source: https://wearables.developer.meta.com/docs/build-integration-ios Check the current status of camera permissions and request them if necessary before starting camera streams. Ensure permissions are granted for devices to appear in the `devicesStream`. ```swift var cameraStatus: PermissionStatus = .denied ... cameraStatus = try await wearables.checkPermissionStatus(.camera) ... ``` ```swift cameraStatus = try await wearables.requestPermission(.camera) ``` -------------------------------- ### stateStream() Source: https://wearables.developer.meta.com/docs/reference/ios_swift/dat/0.6/mwdatcore_devicesession Provides an AsyncStream to observe changes in the DeviceSession's state. It's recommended to create this stream before calling start() to capture all state transitions. ```APIDOC ## stateStream() Creates an `AsyncStream` for observing session state changes. Create the stream before calling start() to avoid missing the initial state transitions. Signature ```swift public func stateStream() -> AsyncStream ``` Returns `AsyncStream` ``` -------------------------------- ### Start AI Glasses Registration Source: https://wearables.developer.meta.com/docs/reference/ios_swift/dat/0.6/mwdatcore_wearablesinterface Initiates the registration process for AI glasses. This opens the Meta AI app for user completion and requires handling a callback URL. ```swift public func startRegistration() ``` -------------------------------- ### Power On Mock Device Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_mockdevice_api_mockdevice Powers on the mock device, simulating device startup. This method is abstract and must be implemented by concrete mock device classes. ```kotlin abstract fun powerOn() ``` -------------------------------- ### Initialize the SDK Source: https://wearables.developer.meta.com/docs/build-integration-ios Call `Wearables.configure()` once when your app launches to initialize the SDK. ```APIDOC ## Initialize the SDK Call `Wearables.configure()` once when your app launches. ```swift func configureWearables() { do { try Wearables.configure() } catch { assertionFailure("Failed to configure Wearables SDK: \(error)") } } ``` ``` -------------------------------- ### init(device:) Source: https://wearables.developer.meta.com/docs/reference/ios_swift/dat/0.6/mwdatcore_specificdeviceselector Creates a device selector that targets a specific device. ```APIDOC ## Constructor: init(device:) ### Description Creates a device selector that targets a specific device. ### Signature ```swift public init(device: DeviceIdentifier) ``` ### Parameters - **device** (DeviceIdentifier) - Required - The identifier of the device to always select. ``` -------------------------------- ### startRegistration Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_wearables Initiates the registration process with AI glasses, opening the Meta AI app for user completion. ```APIDOC ## startRegistration ( activity ) ### Description Initiates the registration process with AI glasses. This method opens the Meta AI app where the user completes the registration flow. When the user completes the flow, the result will be automatically processed and the registration state will be updated. The Wearables.registrationState will be updated throughout the registration process. ### Signature ```kotlin fun startRegistration(activity: Activity) ``` ### Parameters * `activity` (Activity) - The Android activity used to start the registration activity ### Throws `WearablesException` - if SDK not initialized via Wearables.initialize ``` -------------------------------- ### Set up Mock Device Kit Base Rule for Android Tests Source: https://wearables.developer.meta.com/docs/testing-mdk-android Create a reusable base rule or test class to configure Mock Device Kit, grant necessary permissions, and reset state before and after tests. ```kotlin import android.content.Context  import androidx.test.ext.junit.rules.ActivityScenarioRule  import androidx.test.platform.app.InstrumentationRegistry  import com.meta.wearable.dat.mockdevice.MockDeviceKit  import com.meta.wearable.dat.mockdevice.api.MockDeviceKitInterface  import org.junit.After  import org.junit.Before  import org.junit.Rule     open class MockDeviceKitTestCase(     private val activityClass: Class ) {     @get:Rule      val scenarioRule = ActivityScenarioRule(activityClass)     protected lateinit var mockDeviceKit: MockDeviceKitInterface      protected lateinit var targetContext: Context      @Before      open fun setUp() {         val instrumentation = InstrumentationRegistry.getInstrumentation()         targetContext = instrumentation.targetContext         mockDeviceKit = MockDeviceKit.getInstance(targetContext)         grantRuntimePermissions()     }     @After      open fun tearDown() {         mockDeviceKit.reset()     }     private fun grantRuntimePermissions() {         val packageName = targetContext.packageName         val shell = InstrumentationRegistry.getInstrumentation().uiAutomation         shell.executeShellCommand("pm grant $packageName android.permission.BLUETOOTH_CONNECT")         shell.executeShellCommand("pm grant $packageName android.permission.CAMERA")     } } ``` -------------------------------- ### initialize Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_wearables Initializes the Wearables SDK. This must be called before any other SDK functionality. ```APIDOC ## initialize ( context ) ### Description Initializes the Wearables SDK with the provided context. This method must be called before using any other SDK functionality. ### Signature ```kotlin fun initialize(context: Context): DatResult ``` ### Parameters * `context` (Context) - The Android context used to initialize the SDK ### Returns `DatResult` - Indicates success or failure of the initialization. ``` -------------------------------- ### DeviceSessionState Enum Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_session_devicesessionstate Represents the current state of a Meta Wearables device session. A device session manages the connection between the application and a specific Meta Wearables device. The session progresses through these states during its lifecycle: IDLE -> STARTING -> STARTED -> PAUSED -> STARTED (resumable) or STARTED -> STOPPING -> STOPPED (terminal). DeviceSessionState.STOPPED is a terminal state; a new session must be created via Wearables.createSession to re-establish the connection. Use Session.state to observe state transitions and respond to connectivity changes. ```APIDOC ## Enumeration: DeviceSessionState ### Description Represents the current state of a Meta Wearables device session. ### States - **IDLE**: The session has been created but Session.start has not yet been called. - **STARTING**: Session.start has been called and the session is connecting to the device. - **STARTED**: The session is active and connected to a Meta Wearables device. - **PAUSED**: The session is temporarily paused (e.g., device entered low-power mode). - **STOPPING**: Session.stop has been called and the session is cleaning up resources. - **STOPPED**: The session is inactive and not connected to any device. This is a terminal state — the session cannot be restarted. Create a new session via Wearables.createSession if needed. ### See Also - Session - Session.state - SessionState ``` -------------------------------- ### Create Session with Device Selectors Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_selectors_deviceselector Demonstrates how to create a session using both AutoDeviceSelector for automatic device selection and SpecificDeviceSelector for targeting a particular device by its identifier. Use AutoDeviceSelector when you want the SDK to pick the best available device. Use SpecificDeviceSelector when you need to target a known device. ```kotlin // Auto-select the best connected device val autoSelector = AutoDeviceSelector() val session = Wearables.createSession(autoSelector) // Target a specific device val deviceId = Wearables.devices.value.first() val specificSelector = SpecificDeviceSelector(deviceId) val session = Wearables.createSession(specificSelector) ``` -------------------------------- ### Stream State Property Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_camera_stream A StateFlow representing the current state of the streaming session. It transitions through states like STOPPED, STARTING, STARTED, STREAMING, STOPPING, and CLOSED. ```kotlin abstract val state: StateFlow ``` -------------------------------- ### startRegistration Source: https://wearables.developer.meta.com/docs/reference/ios_swift/dat/0.6/mwdatcore_wearablesinterface Initiates the registration process with AI glasses. This opens the Meta AI app for the user to complete the flow. A callback URL is provided upon completion, which must be passed to handleUrl(_:) to finalize registration. The registrationState property tracks the process. ```APIDOC ## startRegistration ### Description Initiates the registration process with AI glasses. This opens the Meta AI app for the user to complete the flow. A callback URL is provided upon completion, which must be passed to handleUrl(_:) to finalize registration. The registrationState property tracks the process. ### Signature ```swift public func startRegistration() ``` ``` -------------------------------- ### Initialize Wearables SDK Source: https://wearables.developer.meta.com/docs/build-integration-ios Call `Wearables.configure()` once when your app launches to initialize the SDK. Handle potential errors during configuration. ```swift func configureWearables() { do { try Wearables.configure() } catch { assertionFailure("Failed to configure Wearables SDK: \(error)") } } ``` -------------------------------- ### DeviceSessionState Enum Definition Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_session_devicesessionstate Represents the current state of a Meta Wearables device session. The session progresses through states like IDLE, STARTING, STARTED, PAUSED, STOPPING, and STOPPED. ```kotlin enum DeviceSessionState : Enum ``` -------------------------------- ### Simulate Device Donning Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_mockdevice_api_mockdevice Simulates putting on (donning) the device, triggering wear detection events. This method is abstract and must be implemented by concrete mock device classes. ```kotlin abstract fun don() ``` -------------------------------- ### Configure Mock Camera Feed and Capture Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_mockdevice_api_camera_mockcamerakit Set up a mock camera feed from a video file or the phone's front camera, and define the image to be returned on photo capture. This is useful for testing camera streaming and photo capture functionality. ```kotlin val glasses = mockKit.pairRaybanMeta() val cameraKit = glasses.services.camera // Set up video feed for streaming tests cameraKit.setCameraFeed(Uri.parse("content://test/video.mp4")) // Or stream from the phone's camera instead cameraKit.setCameraFeed(CameraFacing.FRONT) // Set up photo capture response cameraKit.setCapturedImage(Uri.parse("content://test/photo.jpg")) ``` -------------------------------- ### Initialize StreamSessionConfig with Parameters Source: https://wearables.developer.meta.com/docs/reference/ios_swift/dat/0.6/mwdatcamera_streamsessionconfig Creates a new stream session configuration with specified video codec, resolution, frame rate, and an option to skip app launch. Defaults to false for skipAppLaunch. ```swift public init( videoCodec: VideoCodec, resolution: StreamingResolution, frameRate: UInt, skipAppLaunch: Bool) ``` -------------------------------- ### Get Device Identifier Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_mockdevice_api_mockdevice Returns the device identifier for this mock device. This property is read-only. ```kotlin abstract val deviceIdentifier: DeviceIdentifier ``` -------------------------------- ### removeCapability(_:) Source: https://wearables.developer.meta.com/docs/reference/ios_swift/dat/0.6/mwdatcore_devicesession Removes a capability from the DeviceSession by its type. This operation is only valid when the session is in the 'started' state. ```APIDOC ## removeCapability(_:) Removes a capability from this session by type. The session must be in DeviceSessionState.started state. Signature ```swift public func removeCapability(_ type: T.Type) ``` Parameters `_ type: T.Type` The type of capability to remove. Throws ``` -------------------------------- ### Get Value or Null from DatResult Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_types_datresult Returns the contained value if this DatResult is a success, or null if it is a failure. ```kotlin fun getOrNull(): T? ``` -------------------------------- ### Get Exception or Null from DatResult Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_types_datresult Returns the Throwable exception if the DatResult is a failure, or null if it is a success. ```kotlin fun exceptionOrNull(): Throwable? ``` -------------------------------- ### StreamConfiguration Constructor Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_camera_types_streamconfiguration Initializes a new StreamConfiguration with specified video quality, frame rate, and compression settings. ```APIDOC ## StreamConfiguration Constructor ### Description Initializes a new StreamConfiguration with specified video quality, frame rate, and compression settings. ### Signature ```kotlin constructor(videoQuality: VideoQuality = VideoQuality.MEDIUM, frameRate: Int = 24, compressVideo: Boolean = false) ``` ### Parameters * **videoQuality** (VideoQuality) - Required - The video quality setting for the streaming session. * **frameRate** (Int) - Required - The frame rate for the streaming session. * **compressVideo** (Boolean) - Required - When true, the SDK skips decoding and delivers compressed HEVC buffers. When false (default), the SDK decodes internally and delivers YUV pixel buffers. ### Returns * **StreamConfiguration** - A new instance of StreamConfiguration. ``` -------------------------------- ### Get Default Value from DatResult Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_types_datresult Returns the contained value if this DatResult is a success, or the provided defaultValue if it is a failure. ```kotlin fun getOrDefault(defaultValue: T): T ``` -------------------------------- ### Get Value or Throw Exception from DatResult Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_types_datresult Returns the contained value if this DatResult is a success, or throws the contained exception if it is a failure. ```kotlin fun getOrThrow(): T ``` -------------------------------- ### Device Constructor Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_types_device Constructs a Device object with specified parameters for name, link state, device type, firmware info, and compatibility. ```kotlin constructor(name: String, linkState: LinkState = LinkState.DISCONNECTED, deviceType: DeviceType = DeviceType.UNKNOWN, firmwareInfo: String? = null, compatibility: DeviceCompatibility = DeviceCompatibility.COMPATIBLE) ``` -------------------------------- ### Get Device For Identifier - Swift Source: https://wearables.developer.meta.com/docs/reference/ios_swift/dat/0.6/mwdatcore_wearablesinterface Fetches the underlying Device object for a given DeviceIdentifier. Returns the Device object or nil if not found. ```swift public func deviceForIdentifier(_ identifier: DeviceIdentifier) -> Device? ``` -------------------------------- ### Simulate Device Doffing Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_mockdevice_api_mockdevice Simulates taking off (doffing) the device, triggering removal detection events. This method is abstract and must be implemented by concrete mock device classes. ```kotlin abstract fun doff() ``` -------------------------------- ### addCapability(_:) Source: https://wearables.developer.meta.com/docs/reference/ios_swift/dat/0.6/mwdatcore_devicesession Adds a capability to the DeviceSession. The capability will be stopped when the session stops. Only one capability of each type is allowed, and the session must be in the 'started' state. ```APIDOC ## addCapability(_:) Adds a capability to this session. Added capabilities will have Capability.stop() called on them when this session stops. Only one capability per type is allowed. The session must be in DeviceSessionState.started state. Signature ```swift public func addCapability(_ capability: some Capability) ``` Parameters `_ capability: some Capability` The capability to add. Throws ``` -------------------------------- ### Constructor Source: https://wearables.developer.meta.com/docs/reference/ios_swift/dat/0.6/mwdatcore_autodeviceselector Creates an auto device selector that monitors the given wearables interface for device changes. ```APIDOC ## Constructors **init** ( wearables ) Creates an auto device selector that monitors the given wearables interface for device changes. ### Signature ```swift public init( wearables: WearablesInterface) ``` ### Parameters * **wearables** (WearablesInterface) - Required - The wearables interface to monitor for available devices. ``` -------------------------------- ### Get Value or Compute with Failure Handler Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_types_datresult Returns the contained value if this DatResult is a success, or computes a value using the onFailure function if it is a failure. ```kotlin inline fun getOrElse(onFailure: (exception: Throwable) -> T): T ``` -------------------------------- ### Get Error or Null from DatResult Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_types_datresult Returns the error if the DatResult is a failure, or null if it is a success. The error type E is enforced by the type system. ```kotlin fun errorOrNull(): E? ``` -------------------------------- ### Initialize StreamSessionConfig with Default Settings Source: https://wearables.developer.meta.com/docs/reference/ios_swift/dat/0.6/mwdatcamera_streamsessionconfig Creates a new stream session configuration using default settings: raw video codec, medium resolution, deliver-all frame strategy, and 30 FPS. ```swift public init() ``` -------------------------------- ### DeviceSession.state Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_session_devicesession A StateFlow that provides the current state of this device session. The state indicates whether the session is currently connected to a device (STARTED) or not connected (STOPPED). ```APIDOC ## DeviceSession.state ### Description A StateFlow that provides the current state of this device session. The state indicates whether the session is currently connected to a device (`STARTED`) or not connected (`STOPPED`). ### Signature ``` val state: StateFlow ``` ``` -------------------------------- ### Initialize Wearables SDK Source: https://wearables.developer.meta.com/docs/build-integration-android Initialize the Wearables SDK once per process at application startup. Invoking other Wearables APIs before initialization will result in a `WearablesError.NOT_INITIALIZED` error. ```kotlin Wearables.initialize(context) ``` -------------------------------- ### Get Device Session State Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_wearables Retrieves the session state for a specific device as a StateFlow. This allows observing changes to the device's session state. ```kotlin Wearables.getDeviceSessionState(deviceIdentifier) ``` -------------------------------- ### Set up iOS Audio Session for Play and Record Source: https://wearables.developer.meta.com/docs/microphones-and-speakers This snippet configures the AVAudioSession to allow both playback and recording, enabling Bluetooth for audio routing. It should be set up before initiating audio streams. ```Swift // Set up the audio session let audioSession = AVAudioSession.sharedInstance() try audioSession.setCategory(.playAndRecord, mode: .default, options: [.allowBluetooth]) try audioSession.setActive(true, options: .notifyOthersOnDeactivation) ``` -------------------------------- ### Test Camera Streaming with Mock Device Kit Source: https://wearables.developer.meta.com/docs/testing-mdk-android Configure a mock camera feed for testing streaming logic. Assumes assets are located in `androidTest/assets`. ```kotlin @Test  fun testCameraStreaming() {     val device = mockDeviceKit.pairRaybanMeta()     prepareForStreaming(device)     val mockCameraKit = device.getCameraKit()     mockCameraKit.setCameraFeed(getAssetUri("test_video.mp4"))     // Assert on streaming state in your UI } ``` -------------------------------- ### MockDevice Interface Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_mockdevice_api_mockdevice The MockDevice interface simulates basic device operations for testing. It includes methods for power management and wear detection, and provides access to the device's identifier. ```APIDOC ## Interface MockDevice Mock interface to simulate basic device operations for testing purposes. This is the base interface for all mock device types in the MockDeviceKit. It provides fundamental device lifecycle operations like power control and wear state simulation. Use implementations like MockRaybanMeta for device-specific functionality. ### Properties * **deviceIdentifier** : DeviceIdentifier [Get] - Returns the device identifier for this mock device. ### Methods * **doff** () Simulates taking off (doffing) the device, triggering removal detection events. * **don** () Simulates putting on (donning) the device, triggering wear detection events. * **powerOff** () Powers off the mock device, simulating device shutdown. * **powerOn** () Powers on the mock device, simulating device startup. ``` -------------------------------- ### Stop DeviceSession Monitoring Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_session_devicesession Stops device monitoring and disconnects from any active device. The session state transitions to STOPPED. Automatic connections are disabled until start() is called again. ```kotlin fun stop() ``` -------------------------------- ### Get Active Device Stream Source: https://wearables.developer.meta.com/docs/reference/ios_swift/dat/0.6/mwdatcore_autodeviceselector Creates a stream that emits the identifier of the currently active device. This stream updates whenever the list of available devices changes. ```swift public func activeDeviceStream() -> AnyAsyncSequence ``` -------------------------------- ### Set up Mock Device Kit Base Test Case in XCTest Source: https://wearables.developer.meta.com/docs/testing-mdk-ios Create a reusable base rule or test class to configure Mock Device Kit, grant permissions, and reset state for iOS testing. ```swift import XCTest import MetaWearablesDAT @MainActor class MockDeviceKitTestCase: XCTestCase { private var mockDevice: MockRaybanMeta? private var cameraKit: MockCameraKit? override func setUp() async throws { try await super.setUp() try? Wearables.configure() mockDevice = MockDeviceKit.shared.pairRaybanMeta() cameraKit = mockDevice?.getCameraKit() } override func tearDown() async throws { MockDeviceKit.shared.pairedDevices.forEach { MockDeviceKit.shared.unpairDevice($0) } mockDevice = nil cameraKit = nil try await super.tearDown() } } ``` -------------------------------- ### Start AI Glasses Unregistration Source: https://wearables.developer.meta.com/docs/reference/ios_swift/dat/0.6/mwdatcore_wearablesinterface Initiates the unregistration process for AI glasses. This opens the Meta AI app for user completion and requires handling a callback URL. ```swift public func startUnregistration() ``` -------------------------------- ### Handle Session Errors with When Matching Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_types_sessionerror Demonstrates how to collect and handle session errors using a when statement. This approach ensures all possible error variants are addressed, providing specific user feedback or actions for common errors like device disconnection or power loss, and a generic fallback for others. ```kotlin session.errors.collect { error -> when (error) { SessionError.DEVICE_DISCONNECTED -> showReconnectPrompt() SessionError.DEVICE_POWERED_OFF -> showDeviceOffMessage() SessionError.SESSION_ENDED_BY_DEVICE -> showSessionEndedMessage() else -> showGenericError(error.description) } } ``` -------------------------------- ### Functions Source: https://wearables.developer.meta.com/docs/reference/ios_swift/dat/0.6/mwdatcore_autodeviceselector Creates a stream of active device changes. ```APIDOC ## Functions **activeDeviceStream** () Creates a stream of active device changes that updates whenever the device list changes. ### Signature ```swift public func activeDeviceStream() -> AnyAsyncSequence ``` ### Returns `AnyAsyncSequence` ``` -------------------------------- ### DatResult Example Usage Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_types_datresult Demonstrates how to use DatResult with generic DatError and with a narrowed error type. Includes type-safe error handling using onSuccess and onFailure callbacks. ```kotlin val result: DatResult = attestationClient.requestChallenge(request) ``` ```kotlin val result: DatResult = attestationClient.requestChallenge(request) ``` ```kotlin result .onSuccess { data -> println("Got: $data") } .onFailure { error, cause -> when (error) { AttestationError.TOKEN_NOT_CONFIGURED -> showConfigError() AttestationError.NETWORK_ERROR -> retryRequest() } } ``` ```kotlin result.onFailure { exception -> Log.e(TAG, "Failed", exception) } ``` -------------------------------- ### BaseCapability Constructor Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_session_basecapability Initializes a new instance of the BaseCapability class, attaching it to a parent session. ```APIDOC ## BaseCapability Constructor ### Description Initializes a new instance of the BaseCapability class. ### Signature ``` constructor(parentSession: Session) ``` ### Parameters * **parentSession** (Session) - Required - The session this capability is attached to. ``` -------------------------------- ### WearablesException setStackTrace Method Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_types_wearablesexception Sets the stack trace elements to be returned by getStackTrace(). This method should only be called by framework code that needs to restore a stack trace, for example, from a serialized representation. ```kotlin open fun setStackTrace(p0: Array) ``` -------------------------------- ### Create Session with Custom Device Ranking Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_selectors_autodeviceselector Create a session using AutoDeviceSelector with a custom ranking comparator. This allows prioritizing devices based on specific criteria, such as their name, when the current device disconnects or becomes incompatible. ```kotlin // Custom ranking: prefer devices by name val customRanking = Comparator { a, b -> a.name.compareTo(b.name) } val session = Wearables.createSession(AutoDeviceSelector(customRanking)) ``` -------------------------------- ### Add GitHub Packages Maven Repository Source: https://wearables.developer.meta.com/docs/build-integration-android Configure your app's Gradle repositories to include the GitHub Packages Maven repository for the Wearables Device Access Toolkit. Ensure your GITHUB_TOKEN is set either as an environment variable or in local.properties. ```kotlin val localProperties = Properties().apply { val localPropertiesPath = rootDir.toPath() / "local.properties" if (localPropertiesPath.exists()) { load(localPropertiesPath.inputStream()) } } dependencyResolutionManagement { ... repositories { ... maven { url = uri("https://maven.pkg.github.com/facebook/meta-wearables-dat-android") credentials { username = "" // not needed password = System.getenv("GITHUB_TOKEN") ?: localProperties.getProperty("github_token") } } } } ``` -------------------------------- ### Transcode Video to H.265 using FFmpeg Source: https://wearables.developer.meta.com/docs/mock-device-kit Use this FFmpeg command to transcode a video to the h265 format required for Android mock streaming. Ensure FFmpeg is installed and accessible in your environment. ```bash ffmpeg -hwaccel videotoolbox -i input_video.mp4 -c:v hevc_videotoolbox -c:a aac_at -tag:v hvc1 -vf "scale=540:960" output_video.mov ``` -------------------------------- ### Start AI Glasses Unregistration Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_wearables Initiates the unregistration process for AI glasses. This opens the Meta AI app to complete the flow. The SDK's registration state is updated automatically. ```kotlin Wearables.startUnregistration(activity) ``` -------------------------------- ### Start AI Glasses Registration Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_wearables Initiates the registration process for AI glasses. This opens the Meta AI app to complete the flow. The SDK's registration state is updated automatically. ```kotlin Wearables.startRegistration(activity) ``` -------------------------------- ### Observe Registration and Device Updates Source: https://wearables.developer.meta.com/docs/build-integration-ios Observe registration state and device updates using streams provided by the SDK. ```APIDOC ## Observe registration and device updates Observe registration and device updates. ```swift let wearables = Wearables.shared Task { for await state in wearables.registrationStateStream() { // Update your registration UI or model } } Task { for await devices in wearables.devicesStream() { // Update the list of available glasses } } ``` **Important:** A device will **not** appear in the `devicesStream` until the user has granted at least one permission (for example, camera) through the Meta AI app. If your `devicesStream` is empty after registration, ensure you are calling `wearables.requestPermission(.camera)`, as shown in Step 5 below. ``` -------------------------------- ### Add a Camera Stream to a Session Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_session_session Adds a camera streaming capability to an active session. Ensure the session is in the STARTED state before calling. Handles success by collecting frames and failure by showing an error. ```kotlin session.addStream( streamConfiguration = StreamConfiguration(videoQuality = VideoQuality.HIGH) ).fold( onSuccess = { stream -> stream.videoStream.collect { frame -> processFrame(frame) } }, onFailure = { error -> showError(error.description) } ) ``` -------------------------------- ### startUnregistration Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_wearables Initiates the unregistration process with AI glasses, opening the Meta AI app for user completion. ```APIDOC ## startUnregistration ( activity ) ### Description Initiates the unregistration process with AI glasses. This method opens the Meta AI app where the user completes the unregistration flow. When the user completes the flow, the result will be automatically processed and the registration state will be updated. The Wearables.registrationState will be updated throughout the unregistration process. ### Signature ```kotlin fun startUnregistration(activity: Activity) ``` ### Parameters * `activity` (Activity) - The Android activity used to start the registration activity ### Throws `WearablesException` - if SDK not initialized via Wearables.initialize ``` -------------------------------- ### WearablesInterface Properties Source: https://wearables.developer.meta.com/docs/reference/ios_swift/dat/0.6/mwdatcore_wearablesinterface Provides access to the list of currently available devices and the user's device registration state. Use 'devices' to get a list of DeviceIdentifier and 'registrationState' to check the current state. ```swift var devices: [DeviceIdentifier] { get } var registrationState: RegistrationState { get } ``` -------------------------------- ### Create DeviceSession Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_session_devicesession Creates a new DeviceSession instance. Requires a DeviceSelector to specify which devices to connect to. ```kotlin constructor(deviceSelector: DeviceSelector) ``` -------------------------------- ### Wearables.configure() Source: https://wearables.developer.meta.com/docs/reference/ios_swift/dat/0.6/mwdatcore_wearables Configures the Wearables Device Access Toolkit. This method must be called once before any other Wearables Device Access Toolkit functionality is used. ```APIDOC ## Wearables.configure() ### Description Configures the Wearables Device Access Toolkit with settings from the app bundle. This method must be called once before accessing shared or using any other Wearables Device Access Toolkit functionality. Subsequent calls will throw WearablesError.alreadyConfigured. ### Function Signature ```swift public static func configure() ``` ### Throws - `WearablesError.alreadyConfigured`: If the toolkit has already been configured. ### Usage ```swift do { try Wearables.configure() } catch { // Handle configuration error print("Error configuring Wearables: \(error)") } ``` ``` -------------------------------- ### addStream Source: https://wearables.developer.meta.com/docs/reference/android/dat/0.6/com_meta_wearable_dat_core_session_session Adds a camera streaming capability to this session. Creates and starts a video stream from the device connected to this session. Only one stream can exist per session. The stream must be added after the session reaches DeviceSessionState.STARTED. ```APIDOC ## addStream ### Description Adds a camera streaming capability to this session. Creates and starts a video stream from the device connected to this session. Only one stream can exist per session — calling this method when a stream is already attached returns SessionError.CAPABILITY_ALREADY_ADDED. The stream must be added after the session reaches DeviceSessionState.STARTED. Adding a stream to an idle session returns SessionError.SESSION_IDLE, and adding to a stopped session returns SessionError.SESSION_ALREADY_STOPPED. ### Signature ```kotlin fun Session.addStream(streamConfiguration: StreamConfiguration = StreamConfiguration()): DatResult ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **streamConfiguration** (StreamConfiguration) - Required - Configuration for the stream (video quality, frame rate) ### Request Example ```kotlin session.addStream( streamConfiguration = StreamConfiguration(videoQuality = VideoQuality.HIGH) ).fold( onSuccess = { stream -> stream.videoStream.collect { frame -> processFrame(frame) } }, onFailure = { error -> showError(error.description) } ) ``` ### Response #### Success Response (200) - **Stream** (Stream) - The added stream object. #### Error Response - **SessionError** (SessionError) - An error encountered during the operation. #### Response Example ```json { "stream": "..." } ``` ```