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

कैमरा फ़र्मवेयर अपडेट

Camera OTA, supported डिवाइस के camera module में चल रहे firmware को update करता है। यह डिवाइस के main firmware update से अलग है।

Host app compatible local camera firmware package देता है। इसके बाद SDK पूरा upgrade workflow coordinate करता है: device hotspot configure करना, Camera OTA mode में जाना, local HTTP server शुरू करना, firmware URL डिवाइस को भेजना, package transfer करना और camera firmware flash करना। वर्तमान operation दिखाने के लिए stage callbacks उपयोग करें और final completion handler को authoritative upgrade result मानें।

Animated workflow

Camera OTA delivery path

Local package host-side validation से SDK orchestration, transfer और flashing के बाद authoritative final result तक पहुँचता है।

Host app

Package जाँचें

Integrity, camera-model compatibility और readable local path जाँचें।

SDK + डिवाइस

Hotspot कॉन्फ़िगर करें

Camera OTA workflow के लिए device network तैयार करें।

डिवाइस

OTA Mode में जाएँ

Camera module को firmware update mode में बदलें।

SDK

Hotspot से जुड़ें

Staged update session के लिए उपलब्ध SSID से जुड़ें।

SDK

HTTP Server शुरू करें

चुना local firmware package डिवाइस को उपलब्ध कराएँ।

SDK → डिवाइस

Firmware URL भेजें

डिवाइस द्वारा माँगा जाने वाला local HTTP URL भेजें।

Progress phase

Firmware Transfer करें

डिवाइस के firmware bytes download करते समय package serve करें।

.transferring · 0...100
Progress phase

Firmware Flash करें

Camera module transferred firmware लिखता है। बीच में न रोकें।

.flashing · 0...100
Authoritative result

Final Completion

Upgrade result के लिए transfer progress नहीं, final callback उपयोग करें।

Authoritative result के लिए final completion callback का अनुसरण करें।

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

  • डिवाइस जुड़ा हो और DeviceCameraOtaAPI को conform करता हो।
  • Local firmware path readable हो और package camera hardware से मेल खाता हो।
  • App device hotspot से जुड़ सके, local network access कर सके और local HTTP server उपलब्ध रख सके।
  • Media import, Camera OTA या अन्य hotspot workflows को एक साथ चलने से रोकें।

AI की सहायता से लागू करें

AI से बनाएँ

इस वर्कफ़्लो को AI से लागू करें

आधिकारिक “AIBuds कैमरा फ़र्मवेयर अपडेट करें” स्किल से वर्कफ़्लो को अपने ऐप के अनुसार लागू करें।

https://docs-aibuds.github.io/hi/skills/update-aibuds-camera-firmware को पढ़ें और निर्देशों का पालन करें। इस स्किल से “AIBuds कैमरा फ़र्मवेयर अपडेट करें” को इस iOS प्रोजेक्ट में लागू करें और परिणाम सत्यापित करें।
आधिकारिक स्किल देखें

API संदर्भ

Framework

AIBuds.xcframework

Import

Swift
import AIBuds
import AIBudsFoundation

प्रोटोकॉल

DeviceCameraOtaAPI protocol DeviceAPI से inherit होता है और अभी पूरे Camera OTA workflow के लिए एक instance method देता है।

इंस्टेंस मेथड

Swift
/// Start camera OTA upgrade.
///
/// - Parameters:
///   - filePath: The readable local path of the camera firmware file.
///   - configureHotspotStartingHandler: Called when hotspot configuration starts.
///   - hotspotConfigureCompletionHandler: Called when hotspot configuration completes.
///     - success: `true` if configuration succeeded; otherwise `false`.
///     - error: The failure information, or `nil` if configuration succeeded.
///   - enterCameraOtaModeStartingHandler: Called when entry into camera OTA mode starts.
///   - enterCameraOtaModeCompletedHandler: Called when entry into camera OTA mode completes.
///     - success: `true` if the device entered OTA mode; otherwise `false`.
///     - error: The failure information, or `nil` if entry succeeded.
///   - waitingForHotspotOpenHandler: Called while waiting for the device hotspot to open.
///   - connectDeviceHotspotStartingHandler: Called when connecting to the device hotspot starts.
///     - ssid: The SSID of the device hotspot.
///   - deviceHotspotConnectCompletionHandler: Called when the hotspot connection completes.
///     - success: `true` if the connection succeeded; otherwise `false`.
///     - error: The failure information, or `nil` if the connection succeeded.
///   - httpServerStartingHandler: Called when the local HTTP server is starting.
///   - httpServerStartCompletionHandler: Called when the HTTP server start attempt completes.
///     - success: `true` if the server started; otherwise `false`.
///     - error: The failure information, or `nil` if the server started.
///   - sendingFirmwareUrlHandler: Called before sending the firmware URL to the device.
///     - firmwareUrl: The local HTTP URL that will be sent.
///   - firmwareUrlSendCompletionHandler: Called when firmware URL delivery completes.
///     - success: `true` if the URL was sent; otherwise `false`.
///     - error: The failure information, or `nil` if delivery succeeded.
///   - startCompletionHandler: Called when the Camera OTA start command completes.
///     - success: `true` if the update started; otherwise `false`.
///     - error: The failure information, or `nil` if the update started.
///   - fileTransferStartedHandler: Called when firmware transfer starts.
///   - fileTransferCompletedHandler: Called when firmware transfer completes.
///   - waitingForFlashingHandler: Called while the device is preparing to flash.
///   - flashingStartedHandler: Called when firmware flashing starts.
///   - flashingCompletedHandler: Called when firmware flashing completes.
///   - phaseProgressHandler: Reports progress for transfer and flashing.
///     - phase: `.transferring` or `.flashing`.
///     - progress: The phase progress in the range `0...100`.
///   - completionHandler: Called when the complete Camera OTA workflow finishes.
///     - success: `true` if the upgrade succeeded; otherwise `false`.
///     - error: The failure information, or `nil` if the upgrade succeeded.
func startCameraOta(
    withFilePath filePath: String,
    configureHotspotStartingHandler: AIBudsCameraOtaConfigureHotspotStartingHandler?,
    hotspotConfigureCompletionHandler: AIBudsCameraOtaHotspotConfigureCompletionHandler?,
    enterCameraOtaModeStartingHandler: AIBudsEnterCameraOtaModeStartingHandler?,
    enterCameraOtaModeCompletedHandler: AIBudsEnterCameraOtaModeCompletionHandler?,
    waitingForHotspotOpenHandler: AIBudsCameraOtaStartingToWaitForHotspotOpenHandler?,
    connectDeviceHotspotStartingHandler: AIBudsCameraOtaConnectDeviceHotspotStartingHandler?,
    deviceHotspotConnectCompletionHandler: AIBudsCameraOtaDeviceHotspotConnectCompletionHandler?,
    httpServerStartingHandler: AIBudsCameraOtaHttpServerStartingHandler?,
    httpServerStartCompletionHandler: AIBudsCameraOtaHttpServerStartCompletionHandler?,
    sendingFirmwareUrlHandler: AIBudsCameraOtaSendingFirmwareUrlHandler?,
    firmwareUrlSendCompletionHandler: AIBudsCameraOtaFirmwareUrlSendCompletionHandler?,
    startCompletionHandler: AIBudsCameraOtaStartCompletionHandler?,
    fileTransferStartedHandler: AIBudsCameraOtaFileTransferStartedHandler?,
    fileTransferCompletedHandler: AIBudsCameraOtaFileTransferCompletedHandler?,
    waitingForFlashingHandler: AIBudsCameraOtaWaitingForFlashingHandler?,
    flashingStartedHandler: AIBudsCameraOtaFlashingStartedHandler?,
    flashingCompletedHandler: AIBudsCameraOtaFlashingCompletedHandler?,
    phaseProgressHandler: AIBudsCameraOtaPhaseProgressHandler?,
    completionHandler: AIBudsCameraOtaCompletionHandler?
)

API Reference में startCameraOta देखें।

रिटर्न वैल्यू

यह method सीधे value नहीं लौटाती। Startup, stage transitions, progress और final result दिए गए handlers से मिलते हैं।

Workflow के चरण

ये Camera OTA workflow की callback stages हैं। ये CameraOtaProgressPhase की values नहीं हैं।

Stageसंबंधित handlers
Hotspot configure करेंconfigureHotspotStartingHandler, hotspotConfigureCompletionHandler
Camera OTA mode में जाएँenterCameraOtaModeStartingHandler, enterCameraOtaModeCompletedHandler
Device hotspot से जुड़ेंwaitingForHotspotOpenHandler, connectDeviceHotspotStartingHandler, deviceHotspotConnectCompletionHandler
Local HTTP server शुरू करेंhttpServerStartingHandler, httpServerStartCompletionHandler
Firmware URL भेजेंsendingFirmwareUrlHandler, firmwareUrlSendCompletionHandler
Update शुरू करेंstartCompletionHandler
Firmware transfer करेंfileTransferStartedHandler, fileTransferCompletedHandler
तैयारी और flashwaitingForFlashingHandler, flashingStartedHandler, flashingCompletedHandler
पूरा करेंcompletionHandler

Progress के चरण

CameraOtaProgressPhase में ठीक दो public values हैं। Report की गई phase के लिए progress argument 0 से 100 तक integer है।

SwiftObjective-CRaw valueअर्थ
.transferringAIBudsCameraOtaProgressPhaseTransferring1Firmware file transfer progress।
.flashingAIBudsCameraOtaProgressPhaseFlashing2Camera firmware update progress।

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

उदाहरण SDK Demo के सभी callbacks बनाए रखते हैं। Production code में UI को main queue पर update करें।

Swift
guard let cameraOtaDevice = device as? DeviceCameraOtaAPI else {
    print("Camera OTA is not supported")
    return
}

cameraOtaDevice.startCameraOta(
    withFilePath: filePath,
    configureHotspotStartingHandler: {
        print("Configuring device hotspot")
    },
    hotspotConfigureCompletionHandler: { success, error in
        print(
            success
                ? "Hotspot configured"
                : "Hotspot configuration failed: \(error?.localizedDescription ?? "Unknown error")")
    },
    enterCameraOtaModeStartingHandler: {
        print("Entering Camera OTA mode")
    },
    enterCameraOtaModeCompletedHandler: { success, error in
        print(
            success
                ? "Camera OTA mode ready"
                : "Could not enter Camera OTA mode: \(error?.localizedDescription ?? "Unknown error")"
        )
    },
    waitingForHotspotOpenHandler: {
        print("Waiting for device hotspot")
    },
    connectDeviceHotspotStartingHandler: { ssid in
        print("Connecting to \(ssid)")
    },
    deviceHotspotConnectCompletionHandler: { success, error in
        print(
            success
                ? "Device hotspot connected"
                : "Hotspot connection failed: \(error?.localizedDescription ?? "Unknown error")")
    },
    httpServerStartingHandler: {
        print("Starting local HTTP server")
    },
    httpServerStartCompletionHandler: { success, error in
        print(
            success
                ? "HTTP server ready"
                : "HTTP server failed: \(error?.localizedDescription ?? "Unknown error")")
    },
    sendingFirmwareUrlHandler: { firmwareURL in
        print("Sending firmware URL: \(firmwareURL)")
    },
    firmwareUrlSendCompletionHandler: { success, error in
        print(
            success
                ? "Firmware URL sent"
                : "URL delivery failed: \(error?.localizedDescription ?? "Unknown error")")
    },
    startCompletionHandler: { success, error in
        print(
            success
                ? "Camera OTA started"
                : "Camera OTA could not start: \(error?.localizedDescription ?? "Unknown error")")
    },
    fileTransferStartedHandler: {
        print("Firmware transfer started")
    },
    fileTransferCompletedHandler: {
        print("Firmware transfer completed")
    },
    waitingForFlashingHandler: {
        print("Waiting for flashing")
    },
    flashingStartedHandler: {
        print("Firmware flashing started")
    },
    flashingCompletedHandler: {
        print("Firmware flashing completed")
    },
    phaseProgressHandler: { phase, progress in
        switch phase {
        case .transferring:
            print("Transfer: \(progress)%")
        case .flashing:
            print("Flashing: \(progress)%")
        }
    },
    completionHandler: { success, error in
        if success {
            print("Camera OTA completed successfully")
        } else {
            print("Camera OTA failed: \(error?.localizedDescription ?? "Unknown error")")
        }
    }
)

त्रुटि प्रबंधन

Camera OTA errors AIBudsSDK.CameraOtaErrorDomain और SdkCameraOtaErrorCode उपयोग करते हैं। Public enum local file validation, network/hotspot failures, task lifecycle failures, OTA-mode entry failures और firmware-URL delivery failures को cover करता है।

Codesसामान्य स्थिति
unknown, networkRequestFailed, networkTimeoutSDK error को अधिक स्पष्ट classify नहीं कर पाता या network activity विफल होती है।
cameraOtaFileNotFound, invalidCameraOtaFile, cameraOtaTaskCreateFailedDueToFileNotFoundचुना local firmware path नहीं मिलता या package invalid है।
hotspotDisconnectedDuringTransfer, invalidHotspotConfigDevice hotspot भरोसेमंद रूप से उपयोग नहीं हो सकता।
stageTwoTimeout, interruptedByShutdownOrLowBatteryFlashing पूरा होने के पास रुकती है या डिवाइस update रोकता है।
cameraOtaTaskAlreadyRunningदूसरा Camera OTA task active है।
4003...4009Device connection, timeout, hotspot setup, OTA-mode entry, HTTP serving या URL delivery के दौरान task विफल होता है।
5001...5010Command, storage, permission, channel या state condition के कारण डिवाइस OTA-mode entry या firmware-URL delivery अस्वीकार करता है।

Generic update error के बजाय विफल workflow stage दिखाएँ। Flashing शुरू होने के बाद automatically retry, disconnect, shut down या दूसरा hotspot workflow शुरू न करें। SDK अभी authoritative retry boundaries तय नहीं करता; दूसरा package देने से पहले device recovery state और camera firmware version जाँचें।

सर्वोत्तम अभ्यास

  1. API call करने से पहले local file का अस्तित्व जाँचें; package authenticity और camera-model compatibility host product की जिम्मेदारी है।
  2. Media File Import, Camera OTA या अन्य hotspot workflows को साथ चलने से रोकें।
  3. Final completion तक app active और local HTTP server reachable रखें।
  4. Callbacks दूसरी queue पर आ सकते हैं, इसलिए UI updates main queue पर भेजें।
  5. startCompletionHandler को OTA operation शुरू होने का result मानें, final upgrade success नहीं।
  6. completionHandler को final result मानें और reconnect होने के बाद camera firmware state verify करें।

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

  • Camera OTA local firmware path उपयोग करता है; SDK remote update service query या package download नहीं करता।
  • phaseProgressHandler केवल transfer और flashing progress report करता है। अन्य workflow stages अपने callbacks उपयोग करते हैं।
  • Transfer के लिए progress 100 होना final Camera OTA result नहीं है; इसके बाद flashing और final completion आते हैं।
  • Safe automatic retry behavior अभी public SDK contract में defined नहीं है।