bind composite discovery and add emulated POS895

Epson printers answer ENPC and POS895/POS896 answer SPRT; only the
composite discovery service sees both. Wire CompositeDiscoveryService
(wrapping DiscoveryService + SprtDiscoveryService) into production DI,
and add a 576px emulated POS895 (127.0.0.4) alongside the existing
TM-U220II/TM-T30III emulation entries so receipt layouts can be
checked without hardware.

Claude-Session: https://claude.ai/code/session_01E6N3P4nSZLtp4BC2LXVref
This commit is contained in:
EugeneTes
2026-09-03 12:26:56 +02:00
parent ca773610ad
commit 9680ab0ad3

View File

@@ -53,17 +53,19 @@ public class PrintServerBootstrapper
{
["127.0.0.2"] = ("emulation/u220.html", 0x13, 258),
["127.0.0.3"] = ("emulation/t30.html", 0x01, 384),
["127.0.0.4"] = ("emulation/pos895.html", 0x20, 576),
};
var discovery = new PreconfiguredDiscoveryService();
discovery.AddPrinter("127.0.0.2", "TM-U220II");
discovery.AddPrinter("127.0.0.3", "TM-T30III");
discovery.AddPrinter("127.0.0.4", "POS895");
_kernel.Bind<IDiscoveryService>().ToConstant(discovery).InSingletonScope();
_kernel.Bind<IPrinterFactory>().ToMethod(ctx =>
new EmulationPrinterFactory(emulationConfigs, ctx.Kernel.Get<ILogger>()));
Console.WriteLine("Emulation mode enabled: 127.0.0.2 (TM-U220II), 127.0.0.3 (TM-T30III)");
Console.WriteLine("Emulation mode enabled: 127.0.0.2 (TM-U220II), 127.0.0.3 (TM-T30III), 127.0.0.4 (POS895)");
}
else
{
@@ -74,7 +76,19 @@ public class PrintServerBootstrapper
//discovery.AddPrinter("192.168.1.124", "TM-T30III");
//_kernel.Bind<IDiscoveryService>().ToConstant(discovery).InSingletonScope();\
_kernel.Bind<IDiscoveryService>().To<DiscoveryService>().InSingletonScope();
// Epson printers answer ENPC; POS895/POS896 answer SPRT. Both broadcast
// on UDP 3289, but only the composite sees them all.
_kernel.Bind<IDiscoveryService>().ToMethod(ctx =>
{
var logger = ctx.Kernel.Get<ILogger>();
return new CompositeDiscoveryService(
new IDiscoveryService[]
{
new DiscoveryService(logger),
new SprtDiscoveryService(logger)
},
logger);
}).InSingletonScope();
_kernel.Bind<IPrinterFactory>().To<EpsonPrinterFactory>();
}
_kernel.Bind<IPrintJobSource, SignalRPrintJobSource>().To<SignalRPrintJobSource>().InSingletonScope();