Skip to content

Commit

Permalink
Initial commit multiple HTTP connections
Browse files Browse the repository at this point in the history
(cherry picked from commit 9a627827bf4800b6c27555dcf56ecf3a77187822)
  • Loading branch information
richardapeters committed Dec 4, 2024
1 parent 8441fde commit 16bf54d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
12 changes: 10 additions & 2 deletions postmaster/instantiations/HttpServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,18 @@ namespace main_
HttpServer::HttpServer(services::ConnectionFactory& connectionFactory, services::ConfigurationStoreAccess<infra::BoundedString>& hostname,
services::ConfigurationStoreAccess<infra::BoundedString>& attributes, services::ConfigurationStoreAccess<infra::BoundedString>& password,
application::Authentication& authentication, application::PostmasterDiscovery& postmasterDiscovery,
UartCreator& uartProgrammerCreator, UartCreator& uartExternalCreator, hal::Flash& upgradeFlash, hal::Reset& reset, const infra::Function<void(bool open, services::IPAddress address)>& reporter, const infra::Function<void(bool receiving)>& receivingTarget, const infra::Function<void(bool receiving)>& receivingSelf, hal::GpioPin& resetTarget, hal::GpioPin& boot0)
const infra::Function<void(bool open, services::IPAddress address)>& reporter, const infra::Function<void(bool receiving)>& receivingTarget, const infra::Function<void(bool receiving)>& receivingSelf)
: HttpServerFrontEnd(connectionFactory, hostname, attributes, password, authentication, reporter, receivingTarget, receivingSelf)
, discovery("discovery", postmasterDiscovery)
{
server.AddPage(discovery);
}

HttpServerSingleConnection::HttpServerSingleConnection(services::ConnectionFactory& connectionFactory, services::ConfigurationStoreAccess<infra::BoundedString>& hostname,
services::ConfigurationStoreAccess<infra::BoundedString>& attributes, services::ConfigurationStoreAccess<infra::BoundedString>& password,
application::Authentication& authentication, application::PostmasterDiscovery& postmasterDiscovery,
UartCreator& uartProgrammerCreator, UartCreator& uartExternalCreator, hal::Flash& upgradeFlash, hal::Reset& reset, const infra::Function<void(bool open, services::IPAddress address)>& reporter, const infra::Function<void(bool receiving)>& receivingTarget, const infra::Function<void(bool receiving)>& 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" }
Expand All @@ -25,6 +34,5 @@ namespace main_
server.AddPage(targetUartExternal.page);
server.AddPage(targetUartEchoProgrammer.page);
server.AddPage(targetUartEchoExternal.page);
server.AddPage(discovery);
}
}
12 changes: 11 additions & 1 deletion postmaster/instantiations/HttpServer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,24 @@ namespace main_
: public HttpServerFrontEnd
{
HttpServer(services::ConnectionFactory& connectionFactory, services::ConfigurationStoreAccess<infra::BoundedString>& hostname,
services::ConfigurationStoreAccess<infra::BoundedString>& attributes, services::ConfigurationStoreAccess<infra::BoundedString>& password,
application::Authentication& authentication, application::PostmasterDiscovery& postmasterDiscovery,
const infra::Function<void(bool open, services::IPAddress address)>& reporter, const infra::Function<void(bool receiving)>& receivingTarget, const infra::Function<void(bool receiving)>& receivingSelf);

application::HttpPageDiscovery discovery;
};

struct HttpServerSingleConnection
: public HttpServer
{
HttpServerSingleConnection(services::ConnectionFactory& connectionFactory, services::ConfigurationStoreAccess<infra::BoundedString>& hostname,
services::ConfigurationStoreAccess<infra::BoundedString>& attributes, services::ConfigurationStoreAccess<infra::BoundedString>& password,
application::Authentication& authentication, application::PostmasterDiscovery& postmasterDiscovery,
UartCreator& uartProgrammerCreator, UartCreator& uartExternalCreator, hal::Flash& upgradeFlash, hal::Reset& reset, const infra::Function<void(bool open, services::IPAddress address)>& reporter, const infra::Function<void(bool receiving)>& receivingTarget, const infra::Function<void(bool receiving)>& receivingSelf, hal::GpioPin& resetTarget, hal::GpioPin& boot0);

UartCreator& uartProgrammerCreator;
UartCreator& uartExternalCreator;

application::HttpPageDiscovery discovery;
application::AuthenticatedHttpPage::WithPage<application::HttpPageFirmware> selfFirmwarePage;
main_::SelfProgrammer selfProgrammer;

Expand Down
2 changes: 1 addition & 1 deletion postmaster/prototype_win/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 16bf54d

Please sign in to comment.