Skip to content

Commit 8e77317

Browse files
committed
Use httpd namespace constants for port/service
Add an httpd namespace in httpd.h that defines constexpr kPort and kService which select alternate HTTP port/service on LINUX (kPortHttpAlt/kHttpAlt) and the standard ones otherwise. Update HttpDaemon to use httpd::kPort for network::tcp::Listen and httpd::kService for ServiceRecordAdd, enabling platform-specific port/service selection and removing hardcoded values.
1 parent b25a620 commit 8e77317

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

  • lib-remoteconfig/include/httpd

lib-remoteconfig/include/httpd/httpd.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,28 @@
4040
#include "../../lib-network/config/net_config.h"
4141
#include "firmware/debug/debug_debug.h"
4242

43+
namespace httpd {
44+
inline constexpr auto kPort =
45+
#if defined(LINUX)
46+
network::iana::Ports::kPortHttpAlt;
47+
#else
48+
network::iana::Ports::kPortHttp;
49+
#endif
50+
inline constexpr auto kService =
51+
#if defined(LINUX)
52+
network::apps::mdns::Services::kHttpAlt;
53+
#else
54+
network::apps::mdns::Services::kHttp;
55+
#endif
56+
} // namespace httpd
57+
4358
class HttpDaemon {
4459
public:
4560
HttpDaemon() {
4661
DEBUG_ENTRY();
4762
assert(is_listening_ == false);
4863

49-
is_listening_ = network::tcp::Listen(network::iana::Ports::kPortHttp, Data);
64+
is_listening_ = network::tcp::Listen(httpd::kPort, Data);
5065
assert(is_listening_ == true);
5166

5267
// IMPORTANT:
@@ -58,7 +73,7 @@ class HttpDaemon {
5873
new (&s_handle_request[i]) HttpDeamonHandleRequest(i);
5974
}
6075

61-
network::apps::mdns::ServiceRecordAdd(nullptr, network::apps::mdns::Services::kHttp);
76+
network::apps::mdns::ServiceRecordAdd(nullptr, httpd::kService);
6277

6378
DEBUG_EXIT();
6479
}

0 commit comments

Comments
 (0)