Files
devicemanager/readme.hints.md

2.4 KiB

Device Manager - Implementation Notes

Architecture Overview

The device manager supports two architectures:

Legacy Architecture (Still Supported)

  • Separate device classes: Scanner, Printer, Speaker, SnmpDevice, UpsDevice, DlnaRenderer, DlnaServer
  • Type-specific collections in DeviceManager
  • Type-based queries: getScanners(), getPrinters(), getSpeakers()

New Universal Device Architecture

  • Single UniversalDevice class with composable features
  • Features are capabilities that can be attached to any device
  • Supports multifunction devices naturally (e.g., printer+scanner)

Key Files

Features (ts/features/)

  • feature.abstract.ts - Base Feature class with connection management and retry logic
  • feature.scan.ts - Scanning via eSCL/SANE protocols
  • feature.print.ts - Printing via IPP protocol
  • feature.playback.ts - Media playback (Sonos, AirPlay, Chromecast, DLNA)
  • feature.volume.ts - Volume control (separate from playback)
  • feature.power.ts - UPS/power monitoring via NUT/SNMP
  • feature.snmp.ts - SNMP queries

Device (ts/device/)

  • device.classes.device.ts - UniversalDevice class with feature management

Interfaces (ts/interfaces/)

  • feature.interfaces.ts - All feature-related types and interfaces
  • index.ts - Re-exports feature interfaces

Feature Types

type TFeatureType =
  | 'scan' | 'print' | 'fax' | 'copy'
  | 'playback' | 'volume' | 'power' | 'snmp'
  | 'dlna-render' | 'dlna-serve';

DeviceManager Feature API

// Query by features
dm.getDevicesWithFeature('scan');           // Devices with scan feature
dm.getDevicesWithFeatures(['scan', 'print']); // Devices with ALL features
dm.getDevicesWithAnyFeature(['playback', 'volume']); // Devices with ANY feature

// Manage universal devices
dm.addUniversalDevice(device);
dm.addFeatureToDevice(deviceId, feature);
dm.removeFeatureFromDevice(deviceId, featureType);

Protocol Implementations

  • EsclProtocol - eSCL/AirScan scanner protocol
  • SaneProtocol - SANE network scanner protocol
  • IppProtocol - IPP printer protocol
  • SnmpProtocol - SNMP queries
  • NutProtocol - Network UPS Tools protocol

Type Notes

  • TScanFormat includes 'tiff' (added for compatibility)
  • IPrinterCapabilities (from index.ts) has string[] for sides/quality
  • IPrintCapabilities (from feature.interfaces.ts) has typed arrays