2.4 KiB
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
UniversalDeviceclass 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 logicfeature.scan.ts- Scanning via eSCL/SANE protocolsfeature.print.ts- Printing via IPP protocolfeature.playback.ts- Media playback (Sonos, AirPlay, Chromecast, DLNA)feature.volume.ts- Volume control (separate from playback)feature.power.ts- UPS/power monitoring via NUT/SNMPfeature.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 interfacesindex.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 protocolSaneProtocol- SANE network scanner protocolIppProtocol- IPP printer protocolSnmpProtocol- SNMP queriesNutProtocol- Network UPS Tools protocol
Type Notes
TScanFormatincludes 'tiff' (added for compatibility)IPrinterCapabilities(from index.ts) hasstring[]for sides/qualityIPrintCapabilities(from feature.interfaces.ts) has typed arrays