feat(devicemanager): add selector-based device APIs, selectFeature helper, convenience discovery methods, and ESCL scan completion fallback

This commit is contained in:
2026-01-09 17:18:48 +00:00
parent d72ea96ec5
commit 82a99cdfb8
6 changed files with 224 additions and 6 deletions

View File

@@ -142,13 +142,28 @@ export class EsclProtocol {
/**
* Wait for scan job to complete and download the result
*
* Note: Many scanners (including Brother) don't start scanning until
* NextDocument is requested. The request triggers the scan and blocks
* until complete. We try direct download first, then fall back to polling.
*/
public async waitForScanComplete(
jobUri: string,
options: IScanOptions,
pollInterval: number = 500
): Promise<IScanResult> {
// Poll until job is complete
// Try direct download first - this triggers the scan on many scanners
// (including Brother) and blocks until the scan completes
try {
const result = await this.downloadScan(jobUri, options);
if (result.data.length > 0) {
return result;
}
} catch (err) {
// Direct download failed, fall back to polling
}
// Fall back to polling for scanners that need it
let attempts = 0;
const maxAttempts = 120; // 60 seconds max