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

डिवाइस विवरण पाएँ

AIBuds डिवाइस पर अभी उपलब्ध जानकारी पढ़ें। Device details, device object की properties के रूप में मिलते हैं; कोई एक getDeviceDetails request या DeviceDetails result model नहीं है।

Identity, firmware, connection और advertisement जानकारी के लिए DeviceConvertible उपयोग करें। डिवाइस DeviceInfoAPI के अनुरूप भी हो तो battery status, बताई गई capabilities, hardware configuration, language setting, call status, storage information और media counts पढ़ सकते हैं।

पहले की आवश्यकताएँ

डिवाइस विवरण पढ़ने से पहले:

  • Scan, stored-device या connection workflow से DeviceConvertible instance पाएँ।
  • नवीनतम device-reported values चाहिए हों तो डिवाइस के connected और ready होने की प्रतीक्षा करें।
  • SDK या डिवाइस से value मिलने तक optional properties को unavailable मानें।

:::info मौजूदा snapshot इन properties को पढ़ने पर Bluetooth command नहीं भेजा जाता। Values SDK का मौजूदा snapshot हैं और discovery data, persisted device data या active connection के दौरान मिली जानकारी से आ सकते हैं। :::

API संदर्भ

फ्रेमवर्क

AIBuds.xcframework

Import

SDK उपयोग करने वाली files में main framework import करें:

Swift
import AIBuds

प्रोटोकॉल

Device details दो protocols से मिलते हैं। DeviceConvertible base device snapshot देता है। जुड़ा डिवाइस support करे तो DeviceInfoAPI अतिरिक्त device-information properties देता है।

Swift
/// Defines the persistent identity and capabilities of an AIBuds device.
protocol DeviceConvertible: NSObjectProtocol, NSSecureCoding

/// The protocol for device information related API.
protocol DeviceInfoAPI: DeviceAPI

प्रॉपर्टीज़

Base device प्रॉपर्टीज़

ये properties DeviceConvertible के माध्यम से उपलब्ध हैं।

श्रेणीPropertiesविवरण
Identityname, uuid, bluetoothName, macAddress, productSDK को अभी ज्ञात device name और identifiers।
HardwaredeviceModel, deviceSerialNum, formatedProjNumberसमर्थित डिवाइस द्वारा दी गई optional values।
FirmwarefirmwareVersion, formatedFirmwareVersion, coProcessorFirmwareVersionformatedFirmwareVersion Demo में उपयोग होने वाली display-oriented main firmware string है।
ConnectionconnectionState, deviceState, isConnectedAndReady, isBusy, lastConnectTimeLive device state पर निर्भर होने से पहले isConnectedAndReady जाँचें।
BindingbindUserId, userBindTime, isAlreadyUnbind, shouldAutoReconnectWhenAppLaunchSDK द्वारा रखी गई binding और reconnection state।
AdvertisementadvertisementDataString, advertisementRawData, manufacturerData, manufacturerHexDataString, timestampOfAdvertisementDataसबसे हाल में मिले advertisement data से निकली values।
Presentationthumbnail, screenName, customContentHost app UI में उपयोग की जा सकने वाली optional values।

डिवाइस जानकारी की properties

DeviceInfoAPI conformance की पुष्टि के बाद ये अतिरिक्त snapshot values उपलब्ध होती हैं।

Propertyप्रकारविवरण
batteryStatusInfoBatteryStatusModel?डिवाइस के battery components की real-time जानकारी।
deviceCapabilitiesDeviceCapabilities?डिवाइस द्वारा बताई गई normalized capability flags; valid जानकारी मिलने तक nil
hardwareConfigurationDeviceHardwareConfigurationडिवाइस द्वारा बताई गई physical input hardware और on-device guidance requirements।
languageSettingDeviceLanguageडिवाइस की मौजूदा भाषा।
supportedLanguages[NSNumber]डिवाइस द्वारा supported raw DeviceLanguage values।
callStatusCallStatusमौजूदा call status।
storageInfoStorageInfoModel?उपयोग हुई और खाली storage, MB में।
mediaCountInfoMediaCountInfoModel?Photo, video और audio file counts।
isSupportAdjustRecordDurationBoolMaximum recording duration configure की जा सकती है या नहीं।
aiSolutionCapabilitiesAIBudsAISolutionCapabilitiesडिवाइस द्वारा बताई गई AI capabilities।
coprocessorModelCoprocessorModelडिवाइस का co-processor model।
imageEnhancementPostProcessingAlgorithmImageEnhancementPostProcessingAlgorithmडिवाइस द्वारा बताया गया मौजूदा image-enhancement post-processing algorithm; default .general
recommendedMaxVideoRecordingDurationOptions[NSNumber]सुझाए गए maximum video-recording duration विकल्प, मिनट में; default [1, 3, 9, 12]
recommendedMaxAudioRecordingDurationOptions[NSNumber]सुझाए गए maximum audio-recording duration विकल्प, मिनट में; default [30, 60, 120]
minimumBatteryLevelForMediaOperationsIntPhoto, video, audio और file transfer के लिए minimum battery percentage; default 30। OTA के नियम अलग हैं।

सामान्य status values

batteryStatusInfo में product द्वारा supported कोई भी component हो सकता है:

BatteryComponentअर्थ
.glassचश्मे का मुख्य भाग
.leftEarbud / .rightEarbudबायाँ या दायाँ earbud
.chargingCaseचार्जिंग केस
.mainSpeaker / .sideSpeakerMain या side speaker
.headphonesकान को ढकने वाले हेडफ़ोन
.unknownComponent unavailable या पहचाना नहीं गया

TWS, spatial audio, multipoint, ANC, on-device voice assistant, bass engine, live streaming, Ximalaya और factory-test chirp उपलब्ध कराने का निर्णय deviceCapabilities fields से लें। इन सुविधाओं का अनुमान केवल product से न लगाएँ। nil का अर्थ है कि valid capability जानकारी अभी नहीं मिली है; इसका अर्थ सभी सुविधाओं का unsupported होना नहीं है।

hardwareConfiguration बताता है कि product को कैसे चलाया जा सकता है:

Propertyअर्थ
hasTouchInputTouch input surface मौजूद है।
hasPhysicalButtonInputPhysical button input मौजूद है।
requiresOnDeviceVoiceAssistantGuidanceHost app को on-device voice assistant उपयोग करने की guidance देनी चाहिए।

callStatus, CallStatus उपयोग करता है:

Valueअर्थ
.notInCallकोई call active नहीं है।
.ringingIncoming call की ring बज रही है।
.inCallCall active है।
.threeWayRingingसमर्थित होने पर three-way call की ring बज रही है।
.aiChatडिवाइस मौजूदा call-channel activity को AI conversation बताता है।
.unknownCall state unavailable या पहचानी नहीं गई।

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

डिवाइस विवरण पढ़ें

ये examples SDK Demo के DeviceInfoDetailsController जैसा तरीका अपनाते हैं: पहले base device properties पढ़ें, फिर उपलब्ध होने पर DeviceInfoAPI properties जोड़ें।

Swift
import AIBuds

typealias DeviceDetail = (label: String, value: String)

func formattedDate(_ date: Date?, unavailable: String) -> String {
    guard let date else { return unavailable }

    let formatter = DateFormatter()
    formatter.dateStyle = .medium
    formatter.timeStyle = .medium
    return formatter.string(from: date)
}

func deviceDetails(for device: DeviceConvertible) -> [DeviceDetail] {
    let unavailable = "N/A"
    var details: [DeviceDetail] = [
        ("Device Name", device.name),
        ("UUID", device.uuid.uuidString),
        ("Bluetooth Name", device.bluetoothName ?? unavailable),
        ("MAC Address", device.macAddress ?? unavailable),
        ("Product", String(describing: device.product)),
        ("Device Model", device.deviceModel ?? unavailable),
        ("Serial Number", device.deviceSerialNum ?? unavailable),
        ("Firmware Version", device.formatedFirmwareVersion ?? unavailable),
        ("Co-processor Firmware", device.coProcessorFirmwareVersion ?? unavailable),
        ("Project Number", device.formatedProjNumber ?? unavailable),
        ("Last Connection", formattedDate(device.lastConnectTime, unavailable: unavailable)),
        ("Auto Reconnect", device.shouldAutoReconnectWhenAppLaunch ? "Yes" : "No"),
        ("Advertisement Data", device.advertisementDataString ?? unavailable),
        ("Manufacturer Data", device.manufacturerHexDataString ?? unavailable),
        (
            "Advertisement Timestamp",
            formattedDate(device.timestampOfAdvertisementData, unavailable: unavailable)
        ),
        ("Screen Name", device.screenName ?? unavailable),
        ("Custom Content", device.customContent ?? unavailable),
    ]

    guard let info = device as? DeviceInfoAPI else {
        return details
    }

    let supportedLanguages = info.supportedLanguages
        .compactMap { DeviceLanguage(rawValue: $0.intValue) }
        .map { String(describing: $0) }
        .joined(separator: ", ")

    details.append(contentsOf: [
        ("Battery Status", info.batteryStatusInfo?.description ?? unavailable),
        ("Device Capabilities", info.deviceCapabilities?.description ?? unavailable),
        ("Hardware Configuration", info.hardwareConfiguration.description),
        ("Language", String(describing: info.languageSetting)),
        ("Supported Languages", supportedLanguages.isEmpty ? unavailable : supportedLanguages),
        ("Call Status", String(describing: info.callStatus)),
        ("Storage", info.storageInfo?.description ?? unavailable),
        ("Media Count", info.mediaCountInfo?.description ?? unavailable),
        ("Adjustable Recording Duration", info.isSupportAdjustRecordDuration ? "Yes" : "No"),
        ("AI Capabilities", String(describing: info.aiSolutionCapabilities)),
        ("Co-processor Model", String(describing: info.coprocessorModel)),
        (
            "Image Enhancement",
            String(describing: info.imageEnhancementPostProcessingAlgorithm)
        ),
        ("Recommended Video Duration Options", info.recommendedMaxVideoRecordingDurationOptions.description),
        ("Recommended Audio Duration Options", info.recommendedMaxAudioRecordingDurationOptions.description),
        ("Minimum Media Battery", "\(info.minimumBatteryLevelForMediaOperations)%"),
    ])

    return details
}

Returned rows को ऐप के view model और localization से render करें। Demo table view उपयोग करता है और enum values को localized display strings में बदलता है।

Storage या media जानकारी refresh करें

storageInfo और mediaCountInfo snapshot properties हैं। Screen को नवीनतम value चाहिए तो पहले update request करें और operation सफल होने के बाद संबंधित property पढ़ें।

Swift
guard let info = device as? DeviceInfoAPI else { return }

info.requestQueryStorageInfo { success, error in
    guard success else {
        print(error?.localizedDescription ?? "Storage query failed")
        return
    }

    print(info.storageInfo?.description ?? "Storage information is unavailable")
}

Swift में requestQueryMediaCountInfo(_:) या Objective-C में requestQueryMediaCountInfoWithCompletion: उपयोग करके mediaCountInfo refresh करें।

Error handling

Property access स्वयं asynchronous error नहीं देता। Explicit refresh operations failures को completion handlers से बताते हैं। Unavailable जानकारी को इस तरह संभालें:

  1. Live values चाहिए हों तो device.isConnectedAndReady जाँचें।
  2. DeviceInfoAPI properties पढ़ने से पहले protocol conformance की पुष्टि करें।
  3. यह माने बिना optional properties संभालें कि हर model हर value देगा; nil वाले deviceCapabilities को unsupported नहीं बल्कि unknown मानें।
  4. Advertisement fields को सबसे हाल में मिला advertisement snapshot मानें।
  5. Storage या media-count query जैसे explicit refresh operations में success और error संभालें।

बेहतर तरीके

  1. Protocol conformance जाँचें: Extended properties पढ़ने से पहले DeviceInfoAPI support की पुष्टि करें।

  2. Reported values से features तय करें: Product name या hard-coded limits के बजाय deviceCapabilities की normalized flags, recommended recording durations और minimumBatteryLevelForMediaOperations उपयोग करें।

  3. Values को snapshot मानें: यह न मानें कि हर property एक ही समय refresh हुई है।

  4. Optional values संभालें: काल्पनिक fallback data बनाने के बजाय unavailable state दिखाएँ।

  5. ज़रूरत पर ही refresh करें: Screen को current values चाहिए हों तभी storage और media-count query methods उपयोग करें।

  6. Display values localize करें: Products, languages, call status और अन्य enums को user-facing localized text में बदलें।

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

  • Device capabilities और उपलब्ध fields product तथा firmware के अनुसार बदलते हैं। DeviceProduct.headphones over-ear headphones product को और BatteryComponent.headphones उसकी battery entry को दर्शाता है।
  • supportedLanguages में NSNumber values होती हैं, जो DeviceLanguage.rawValue से map होती हैं।
  • StorageInfoModel, usedSpaceInMB और freeSpaceInMB देता है।
  • MediaCountInfoModel, photoCount, videoCount और audioCount देता है।
  • UI को अलग-अलग values चाहिए हों तो description parse करने के बजाय model properties उपयोग करें।