कैमरा फ़र्मवेयर अपडेट
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 मानें।
Camera OTA delivery path
Local package host-side validation से SDK orchestration, transfer और flashing के बाद authoritative final result तक पहुँचता है।
आवश्यक शर्तें
- डिवाइस जुड़ा हो और
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 से लागू करें
आधिकारिक “AIBuds कैमरा फ़र्मवेयर अपडेट करें” स्किल से वर्कफ़्लो को अपने ऐप के अनुसार लागू करें।
https://docs-aibuds.github.io/hi/skills/update-aibuds-camera-firmware को पढ़ें और निर्देशों का पालन करें। इस स्किल से “AIBuds कैमरा फ़र्मवेयर अपडेट करें” को इस iOS प्रोजेक्ट में लागू करें और परिणाम सत्यापित करें।API संदर्भ
Framework
AIBuds.xcframework
Import
- Swift
- Objective-C
import AIBuds
import AIBudsFoundation#import <AIBuds/AIBuds-Swift.h>
#import <AIBuds/AIBuds.h>प्रोटोकॉल
DeviceCameraOtaAPI protocol DeviceAPI से inherit होता है और अभी पूरे Camera OTA workflow के लिए एक instance method देता है।
इंस्टेंस मेथड
- Swift
- Objective-C
/// 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?
)/// Start camera OTA upgrade from a local firmware path.
///
/// - Parameters:
/// - filePath: The readable local path of the camera firmware file.
/// - configureHotspotStartingHandler: Called when hotspot configuration starts.
/// - hotspotConfigureCompletionHandler: Returns configuration success and error.
/// - enterCameraOtaModeStartingHandler: Called when entry into camera OTA mode starts.
/// - enterCameraOtaModeCompletedHandler: Returns OTA-mode entry success and error.
/// - waitingForHotspotOpenHandler: Called while waiting for the device hotspot to open.
/// - connectDeviceHotspotStartingHandler: Returns the device hotspot SSID.
/// - deviceHotspotConnectCompletionHandler: Returns hotspot connection success and error.
/// - httpServerStartingHandler: Called when the local HTTP server is starting.
/// - httpServerStartCompletionHandler: Returns HTTP server start success and error.
/// - sendingFirmwareUrlHandler: Returns the local firmware URL before it is sent.
/// - firmwareUrlSendCompletionHandler: Returns URL delivery success and error.
/// - startCompletionHandler: Returns Camera OTA start success and error.
/// - fileTransferStartedHandler: Called when firmware transfer starts.
/// - fileTransferCompletedHandler: Called when firmware transfer completes.
/// - waitingForFlashingHandler: Called while the device prepares to flash.
/// - flashingStartedHandler: Called when firmware flashing starts.
/// - flashingCompletedHandler: Called when firmware flashing completes.
/// - phaseProgressHandler: Returns `Transferring` or `Flashing` and progress from `0` to `100`.
/// - completionHandler: Returns final upgrade success and error.
- (void)startCameraOtaWithFilePath:(NSString *_Nonnull)filePath
configureHotspotStartingHandler:(AIBudsCameraOtaConfigureHotspotStartingHandler _Nullable)
configureHotspotStartingHandler
hotspotConfigureCompletionHandler:
(AIBudsCameraOtaHotspotConfigureCompletionHandler _Nullable)
hotspotConfigureCompletionHandler
enterCameraOtaModeStartingHandler:
(AIBudsEnterCameraOtaModeStartingHandler _Nullable)enterCameraOtaModeStartingHandler
enterCameraOtaModeCompletedHandler:
(AIBudsEnterCameraOtaModeCompletionHandler _Nullable)enterCameraOtaModeCompletedHandler
waitingForHotspotOpenHandler:
(AIBudsCameraOtaStartingToWaitForHotspotOpenHandler _Nullable)
waitingForHotspotOpenHandler
connectDeviceHotspotStartingHandler:
(AIBudsCameraOtaConnectDeviceHotspotStartingHandler _Nullable)
connectDeviceHotspotStartingHandler
deviceHotspotConnectCompletionHandler:
(AIBudsCameraOtaDeviceHotspotConnectCompletionHandler _Nullable)
deviceHotspotConnectCompletionHandler
httpServerStartingHandler:
(AIBudsCameraOtaHttpServerStartingHandler _Nullable)httpServerStartingHandler
httpServerStartCompletionHandler:
(AIBudsCameraOtaHttpServerStartCompletionHandler _Nullable)
httpServerStartCompletionHandler
sendingFirmwareUrlHandler:
(AIBudsCameraOtaSendingFirmwareUrlHandler _Nullable)sendingFirmwareUrlHandler
firmwareUrlSendCompletionHandler:
(AIBudsCameraOtaFirmwareUrlSendCompletionHandler _Nullable)
firmwareUrlSendCompletionHandler
startCompletionHandler:
(AIBudsCameraOtaStartCompletionHandler _Nullable)startCompletionHandler
fileTransferStartedHandler:
(AIBudsCameraOtaFileTransferStartedHandler _Nullable)fileTransferStartedHandler
fileTransferCompletedHandler:
(AIBudsCameraOtaFileTransferCompletedHandler _Nullable)fileTransferCompletedHandler
waitingForFlashingHandler:
(AIBudsCameraOtaWaitingForFlashingHandler _Nullable)waitingForFlashingHandler
flashingStartedHandler:
(AIBudsCameraOtaFlashingStartedHandler _Nullable)flashingStartedHandler
flashingCompletedHandler:
(AIBudsCameraOtaFlashingCompletedHandler _Nullable)flashingCompletedHandler
phaseProgressHandler:
(AIBudsCameraOtaPhaseProgressHandler _Nullable)phaseProgressHandler
completionHandler:
(AIBudsCameraOtaCompletionHandler _Nullable)completionHandler;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 |
| तैयारी और flash | waitingForFlashingHandler, flashingStartedHandler, flashingCompletedHandler |
| पूरा करें | completionHandler |
Progress के चरण
CameraOtaProgressPhase में ठीक दो public values हैं। Report की गई phase के लिए progress argument 0 से 100 तक integer है।
| Swift | Objective-C | Raw value | अर्थ |
|---|---|---|---|
.transferring | AIBudsCameraOtaProgressPhaseTransferring | 1 | Firmware file transfer progress। |
.flashing | AIBudsCameraOtaProgressPhaseFlashing | 2 | Camera firmware update progress। |
उपयोग के उदाहरण
उदाहरण SDK Demo के सभी callbacks बनाए रखते हैं। Production code में UI को main queue पर update करें।
- Swift
- Objective-C
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")")
}
}
)id<AIBudsDeviceCameraOtaAPI> cameraOtaDevice = (id<AIBudsDeviceCameraOtaAPI>)self.device;
if (![cameraOtaDevice conformsToProtocol:@protocol(AIBudsDeviceCameraOtaAPI)]) {
NSLog(@"Camera OTA is not supported");
return;
}
[cameraOtaDevice startCameraOtaWithFilePath:filePath
configureHotspotStartingHandler:^{
NSLog(@"Configuring device hotspot");
}
hotspotConfigureCompletionHandler:^(BOOL success, NSError *_Nullable error) {
NSLog(@"%@", success ? @"Hotspot configured" : error.localizedDescription);
}
enterCameraOtaModeStartingHandler:^{
NSLog(@"Entering Camera OTA mode");
}
enterCameraOtaModeCompletedHandler:^(BOOL success, NSError *_Nullable error) {
NSLog(@"%@", success ? @"Camera OTA mode ready" : error.localizedDescription);
}
waitingForHotspotOpenHandler:^{
NSLog(@"Waiting for device hotspot");
}
connectDeviceHotspotStartingHandler:^(NSString *_Nonnull ssid) {
NSLog(@"Connecting to %@", ssid);
}
deviceHotspotConnectCompletionHandler:^(BOOL success, NSError *_Nullable error) {
NSLog(@"%@", success ? @"Device hotspot connected" : error.localizedDescription);
}
httpServerStartingHandler:^{
NSLog(@"Starting local HTTP server");
}
httpServerStartCompletionHandler:^(BOOL success, NSError *_Nullable error) {
NSLog(@"%@", success ? @"HTTP server ready" : error.localizedDescription);
}
sendingFirmwareUrlHandler:^(NSString *_Nonnull firmwareUrl) {
NSLog(@"Sending firmware URL: %@", firmwareUrl);
}
firmwareUrlSendCompletionHandler:^(BOOL success, NSError *_Nullable error) {
NSLog(@"%@", success ? @"Firmware URL sent" : error.localizedDescription);
}
startCompletionHandler:^(BOOL success, NSError *_Nullable error) {
NSLog(@"%@", success ? @"Camera OTA started" : error.localizedDescription);
}
fileTransferStartedHandler:^{
NSLog(@"Firmware transfer started");
}
fileTransferCompletedHandler:^{
NSLog(@"Firmware transfer completed");
}
waitingForFlashingHandler:^{
NSLog(@"Waiting for flashing");
}
flashingStartedHandler:^{
NSLog(@"Firmware flashing started");
}
flashingCompletedHandler:^{
NSLog(@"Firmware flashing completed");
}
phaseProgressHandler:^(AIBudsCameraOtaProgressPhase phase, NSInteger progress) {
if (phase == AIBudsCameraOtaProgressPhaseTransferring) {
NSLog(@"Transfer: %ld%%", (long)progress);
} else if (phase == AIBudsCameraOtaProgressPhaseFlashing) {
NSLog(@"Flashing: %ld%%", (long)progress);
}
}
completionHandler:^(BOOL success, NSError *_Nullable error) {
NSLog(@"%@", success ? @"Camera OTA completed successfully" : error.localizedDescription);
}];त्रुटि प्रबंधन
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, networkTimeout | SDK error को अधिक स्पष्ट classify नहीं कर पाता या network activity विफल होती है। |
cameraOtaFileNotFound, invalidCameraOtaFile, cameraOtaTaskCreateFailedDueToFileNotFound | चुना local firmware path नहीं मिलता या package invalid है। |
hotspotDisconnectedDuringTransfer, invalidHotspotConfig | Device hotspot भरोसेमंद रूप से उपयोग नहीं हो सकता। |
stageTwoTimeout, interruptedByShutdownOrLowBattery | Flashing पूरा होने के पास रुकती है या डिवाइस update रोकता है। |
cameraOtaTaskAlreadyRunning | दूसरा Camera OTA task active है। |
4003...4009 | Device connection, timeout, hotspot setup, OTA-mode entry, HTTP serving या URL delivery के दौरान task विफल होता है। |
5001...5010 | Command, 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 जाँचें।
सर्वोत्तम अभ्यास
- API call करने से पहले local file का अस्तित्व जाँचें; package authenticity और camera-model compatibility host product की जिम्मेदारी है।
- Media File Import, Camera OTA या अन्य hotspot workflows को साथ चलने से रोकें।
- Final completion तक app active और local HTTP server reachable रखें।
- Callbacks दूसरी queue पर आ सकते हैं, इसलिए UI updates main queue पर भेजें।
startCompletionHandlerको OTA operation शुरू होने का result मानें, final upgrade success नहीं।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 नहीं है।