मुख्य कंटेंट तक स्किप करें

Operation mapping देखें

Device operations और उन्हें assigned device functions की mapping पढ़ें।

आवश्यक शर्तें

  • Device connected और ready हो
  • Device DevicePhysicalOperationsAPI support करता हो

API Reference

Framework

AIBuds.xcframework

Import

Swift
import AIBuds

Protocol की घोषणा

Mapping DevicePhysicalOperationsAPI की property के रूप में expose होती है।

Swift
/// The protocol for device physical operations API.
protocol DevicePhysicalOperationsAPI: DeviceAPI {
    /// Physical operations with functions mapping
    /// - Returns: A dictionary mapping physical operation identifiers to function identifiers.
    ///
    /// The dictionary is structured as follows:
    /// - Keys: Physical operation identifiers. Defined in ``DeviceOperation``.
    /// - Values: Function identifiers. Defined in ``DeviceFunction``.
    var physicalOperationsMapping: [NSNumber: NSNumber]? { get }
}

उपलब्ध properties

PropertyTypeविवरण
physicalOperationsMapping[NSNumber: NSNumber]?हर DeviceOperation raw value को DeviceFunction raw value से map करता है।

Return value

यह read-only optional property है, asynchronous query method नहीं।

उपयोग के उदाहरण

Swift
import AIBuds

guard let device = device as? DevicePhysicalOperationsAPI else {
    print("Device does not support physical-operation mapping")
    return
}

guard let mapping = device.physicalOperationsMapping else {
    print("Mapping is unavailable")
    return
}

for (operationValue, functionValue) in mapping {
    let operation = DeviceOperation(rawValue: operationValue.intValue)
    let function = DeviceFunction(rawValue: functionValue.intValue)
    print("\(String(describing: operation)) → \(String(describing: function))")
}

Error handling

Property में completion handler नहीं है। Unsupported protocol conformance, nil mapping और known enum case में initialize न होने वाले raw values संभालें।

बेहतर तरीके

  1. Values को enum raw values मानें: Keys और values को DeviceOperation और DeviceFunction से convert करें।
  2. Missing entries का अनुमान न लगाएँ: जो operation नहीं मिला, उसे supported न मानें।
  3. Assignment के बाद UI refresh करें: Device mapping update करता हो तो सफल assignment के बाद property दोबारा पढ़ें।

ध्यान देने योग्य बातें

  • SDK Demo इस property को सीधे पढ़ता है और display के लिए entries को operation raw value से sort करता है।
  • Property Result callback या KeyMapping model उपयोग नहीं करती।