diff --git a/postmaster/instantiations/HttpServer.cpp b/postmaster/instantiations/HttpServer.cpp index ad9fc29..ef19c54 100644 --- a/postmaster/instantiations/HttpServer.cpp +++ b/postmaster/instantiations/HttpServer.cpp @@ -5,9 +5,18 @@ namespace main_ HttpServer::HttpServer(services::ConnectionFactory& connectionFactory, services::ConfigurationStoreAccess& hostname, services::ConfigurationStoreAccess& attributes, services::ConfigurationStoreAccess& password, application::Authentication& authentication, application::PostmasterDiscovery& postmasterDiscovery, - UartCreator& uartProgrammerCreator, UartCreator& uartExternalCreator, hal::Flash& upgradeFlash, hal::Reset& reset, const infra::Function& reporter, const infra::Function& receivingTarget, const infra::Function& receivingSelf, hal::GpioPin& resetTarget, hal::GpioPin& boot0) + const infra::Function& reporter, const infra::Function& receivingTarget, const infra::Function& receivingSelf) : HttpServerFrontEnd(connectionFactory, hostname, attributes, password, authentication, reporter, receivingTarget, receivingSelf) , discovery("discovery", postmasterDiscovery) + { + server.AddPage(discovery); + } + + HttpServerSingleConnection::HttpServerSingleConnection(services::ConnectionFactory& connectionFactory, services::ConfigurationStoreAccess& hostname, + services::ConfigurationStoreAccess& attributes, services::ConfigurationStoreAccess& password, + application::Authentication& authentication, application::PostmasterDiscovery& postmasterDiscovery, + UartCreator& uartProgrammerCreator, UartCreator& uartExternalCreator, hal::Flash& upgradeFlash, hal::Reset& reset, const infra::Function& reporter, const infra::Function& receivingTarget, const infra::Function& receivingSelf, hal::GpioPin& resetTarget, hal::GpioPin& boot0) + : HttpServer(connectionFactory, hostname, attributes, password, authentication, postmasterDiscovery, reporter, receivingTarget, receivingSelf) , uartProgrammerCreator(uartProgrammerCreator) , uartExternalCreator(uartExternalCreator) , selfFirmwarePage{ authentication, "firmware/self" } @@ -25,6 +34,5 @@ namespace main_ server.AddPage(targetUartExternal.page); server.AddPage(targetUartEchoProgrammer.page); server.AddPage(targetUartEchoExternal.page); - server.AddPage(discovery); } } diff --git a/postmaster/instantiations/HttpServer.hpp b/postmaster/instantiations/HttpServer.hpp index 562d963..2013dd0 100644 --- a/postmaster/instantiations/HttpServer.hpp +++ b/postmaster/instantiations/HttpServer.hpp @@ -14,6 +14,17 @@ namespace main_ : public HttpServerFrontEnd { HttpServer(services::ConnectionFactory& connectionFactory, services::ConfigurationStoreAccess& hostname, + services::ConfigurationStoreAccess& attributes, services::ConfigurationStoreAccess& password, + application::Authentication& authentication, application::PostmasterDiscovery& postmasterDiscovery, + const infra::Function& reporter, const infra::Function& receivingTarget, const infra::Function& receivingSelf); + + application::HttpPageDiscovery discovery; + }; + + struct HttpServerSingleConnection + : public HttpServer + { + HttpServerSingleConnection(services::ConnectionFactory& connectionFactory, services::ConfigurationStoreAccess& hostname, services::ConfigurationStoreAccess& attributes, services::ConfigurationStoreAccess& password, application::Authentication& authentication, application::PostmasterDiscovery& postmasterDiscovery, UartCreator& uartProgrammerCreator, UartCreator& uartExternalCreator, hal::Flash& upgradeFlash, hal::Reset& reset, const infra::Function& reporter, const infra::Function& receivingTarget, const infra::Function& receivingSelf, hal::GpioPin& resetTarget, hal::GpioPin& boot0); @@ -21,7 +32,6 @@ namespace main_ UartCreator& uartProgrammerCreator; UartCreator& uartExternalCreator; - application::HttpPageDiscovery discovery; application::AuthenticatedHttpPage::WithPage selfFirmwarePage; main_::SelfProgrammer selfProgrammer; diff --git a/postmaster/prototype_win/Main.cpp b/postmaster/prototype_win/Main.cpp index c212059..e7868ba 100644 --- a/postmaster/prototype_win/Main.cpp +++ b/postmaster/prototype_win/Main.cpp @@ -148,7 +148,7 @@ int main() static GpioPinStub resetTarget; static GpioPinStub boot0; static application::Authentication authentication{ passwordAccess, randomDataGenerator }; - static main_::HttpServer httpServer{ networkAdapter.ConnectionFactory(), hostnameAccess, attributesAccess, passwordAccess, authentication, mdnsDiscovery.discovery, serialCreator, serialCreator, flash, reset, [](bool open, services::IPAddress address) {}, [](bool receiving) {}, [](bool receiving) {}, resetTarget, boot0 }; + static main_::HttpServerSingleConnection httpServer{ networkAdapter.ConnectionFactory(), hostnameAccess, attributesAccess, passwordAccess, authentication, mdnsDiscovery.discovery, serialCreator, serialCreator, flash, reset, [](bool open, services::IPAddress address) {}, [](bool receiving) {}, [](bool receiving) {}, resetTarget, boot0 }; static main_::EchoServer echoServer{ networkAdapter.ConnectionFactory(), serialCreator, 1235 }; static main_::SingleConnectionLink link(httpServer.server, echoServer.listener);