Skip to content

Commit 77345a5

Browse files
committed
Refactor remoteconfig content and misc fixes
Large refactor of the remoteconfig HTTP content pipeline and several small fixes: - Reworked lib-remoteconfig content generation (generate_content.cpp): added structured feature guards, supported extensions table, helper functions, safer file handling, and rebuilt content header assembly. Renamed struct fields and constants to snake_case/k-prefixed names and switched to inline constexpr kHttpContent. Replaced http::contentTypes with http::ContentTypes and updated casts. Added pixeltype.json.h asset and include guards for pixel content. - Updated content includes (includes.h, content.h) to match new naming/style and added conditional pixel includes. - Minor code cleanups: made ToValue/FromValue constexpr and added static_asserts in utils_enum.h; use GetTypeName/GetMapName in pixel show display; removed stray blank line in tcp.cpp pragma block. - Build/make: added CONFIG_HTTPD_OPTIMIZE_O2 define for multiple GD32 boards in Board.mk. - Bumped copyright years and expanded license header where applicable. Also removed/adjusted some obsolete http source/header files as part of the reorganization.
1 parent c7b713e commit 77345a5

20 files changed

Lines changed: 725 additions & 626 deletions

File tree

common/include/common/utils/utils_enum.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file utils_enum.h
33
*
44
*/
5-
/* Copyright (C) 2025 by Arjan van Vught mailto:info@gd32-dmx.org
5+
/* Copyright (C) 2025-2026 by Arjan van Vught mailto:info@gd32-dmx.org
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy
88
* of this software and associated documentation files (the "Software"), to deal
@@ -30,19 +30,20 @@
3030

3131
namespace common
3232
{
33-
3433
/// Converts an enum class value to its underlying integer type.
35-
template <typename Enum>
36-
inline auto ToValue(Enum e) noexcept {
34+
template <typename Enum> constexpr auto ToValue(Enum e) noexcept -> std::underlying_type_t<Enum>
35+
{
36+
static_assert(std::is_enum_v<Enum>);
3737
return static_cast<std::underlying_type_t<Enum>>(e);
3838
}
3939

4040
/// Converts an integer value to the corresponding enum class value.
41-
template <typename Enum>
42-
inline Enum FromValue(std::underlying_type_t<Enum> value) noexcept {
41+
template <typename Enum> constexpr Enum FromValue(std::underlying_type_t<Enum> value) noexcept
42+
{
43+
static_assert(std::is_enum_v<Enum>);
4344
return static_cast<Enum>(value);
4445
}
4546

4647
} // namespace common
4748

48-
#endif // COMMON_UTILS_UTILS_ENUM_H_
49+
#endif // COMMON_UTILS_UTILS_ENUM_H_

common/include/firmware/pixeldmx/show.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* display.h
33
*
44
*/
5-
/* Copyright (C) 2025 by Arjan van Vught mailto:info@gd32-dmx.org
5+
/* Copyright (C) 2025-2026 by Arjan van Vught mailto:info@gd32-dmx.org
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy
88
* of this software and associated documentation files (the "Software"), to deal
@@ -41,8 +41,8 @@ inline void Show(uint32_t line, pixelpatterns::Pattern pattern = pixelpatterns::
4141
assert(display != nullptr);
4242

4343
display->ClearEndOfLine();
44-
display->Printf(line, "%s:%d G%d %s", pixel::GetType(configuration.GetType()), configuration.GetCount(), configuration.GetGroupingCount(),
45-
pixel::GetMap(configuration.GetMap()));
44+
display->Printf(line, "%s:%d G%d %s", pixel::GetTypeName(configuration.GetType()), configuration.GetCount(), configuration.GetGroupingCount(),
45+
pixel::GetMapName(configuration.GetMap()));
4646
display->ClearLine(8); // Status line
4747

4848
if (pattern != pixelpatterns::Pattern::kNone)

common/make/gd32/Board.mk

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,7 @@ endif
2222
ifeq ($(strip $(BOARD)),BOARD_GD32F207RG)
2323
MCU=GD32F207RG
2424
DEFINES+=-DCONFIG_STORE_USE_SPI
25-
endif
26-
27-
ifeq ($(strip $(BOARD)),BOARD_GD32F303CB)
28-
MCU=GD32F303CB
29-
DEFINES+=-DCONFIG_STORE_USE_ROM
30-
DEFINES+=-DNO_EMAC
25+
DEFINES+=-DCONFIG_HTTPD_OPTIMIZE_O2
3126
endif
3227

3328
ifeq ($(strip $(BOARD)),BOARD_GD32F303RC)
@@ -39,18 +34,22 @@ endif
3934
ifeq ($(strip $(BOARD)),BOARD_GD32F407RE)
4035
MCU=GD32F407RE
4136
DEFINES+=-DCONFIG_STORE_USE_SPI
37+
DEFINES+=-DCONFIG_HTTPD_OPTIMIZE_O2
4238
endif
4339

4440
ifeq ($(strip $(BOARD)),BOARD_GD32F450VI)
4541
MCU=GD32F450VI
42+
DEFINES+=-DCONFIG_HTTPD_OPTIMIZE_O2
4643
endif
4744

4845
ifeq ($(strip $(BOARD)),BOARD_16X4U_PIXEL)
4946
MCU=GD32F450VI
47+
DEFINES+=-DCONFIG_HTTPD_OPTIMIZE_O2
5048
endif
5149

5250
ifeq ($(strip $(BOARD)),BOARD_GD32F470VG)
5351
MCU=GD32F470VG
52+
DEFINES+=-DCONFIG_HTTPD_OPTIMIZE_O2
5453
endif
5554

5655
ifeq ($(strip $(BOARD)),BOARD_GD32F207C_EVAL)
@@ -71,16 +70,19 @@ endif
7170
ifeq ($(strip $(BOARD)),BOARD_BW_OPIDMX4)
7271
BOARD_DMX=4
7372
DEFINES+=-DCONFIG_STORE_USE_SPI
73+
DEFINES+=-DCONFIG_HTTPD_OPTIMIZE_O2
7474
endif
7575

7676
ifeq ($(strip $(BOARD)),BOARD_DMX3)
7777
BOARD_DMX=3
7878
DEFINES+=-DCONFIG_STORE_USE_SPI
79+
DEFINES+=-DCONFIG_HTTPD_OPTIMIZE_O2
7980
endif
8081

8182
ifeq ($(strip $(BOARD)),BOARD_DMX4)
82-
DEFINES+=-DCONFIG_STORE_USE_SPI
8383
BOARD_DMX=4
84+
DEFINES+=-DCONFIG_STORE_USE_SPI
85+
DEFINES+=-DCONFIG_HTTPD_OPTIMIZE_O2
8486
endif
8587

8688
ifdef BOARD_DMX

lib-network/src/core/tcp.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
#if defined(DEBUG_NET_TCP)
4747
#undef NDEBUG
4848
#endif
49-
5049
#pragma GCC diagnostic push
5150
#if (__GNUC__ < 10)
5251
#pragma GCC diagnostic ignored "-Wconversion"

lib-remoteconfig/http/content/content.h

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,90 +2,95 @@
22
#define CONTENT_H_
33

44
#include <cstdint>
5-
65
#include "httpd/httpd.h"
7-
86
#if !defined (CONFIG_HTTP_HTML_NO_DMX) && (defined(OUTPUT_DMX_SEND) || defined(OUTPUT_DMX_SEND_MULTI))
9-
# include "dmx.js.h"
7+
#include "dmx.js.h"
108
#endif /* !defined (CONFIG_HTTP_HTML_NO_DMX) && (defined(OUTPUT_DMX_SEND) || defined(OUTPUT_DMX_SEND_MULTI)) */
119
#if !defined (CONFIG_HTTP_HTML_NO_RTC) && !defined (DISABLE_RTC)
12-
# include "rtc.html.h"
10+
#include "rtc.html.h"
1311
#endif /* !defined (CONFIG_HTTP_HTML_NO_RTC) && !defined (DISABLE_RTC) */
1412
#include "static.js.h"
1513
#include "styles.css.h"
1614
#include "index.js.h"
1715
#include "date.js.h"
1816
#if defined (NODE_SHOWFILE)
19-
# include "showfile.html.h"
17+
#include "showfile.html.h"
2018
#endif /* (NODE_SHOWFILE) */
2119
#include "default.js.h"
2220
#if !defined (CONFIG_HTTP_HTML_NO_RTC) && !defined (DISABLE_RTC)
23-
# include "rtc.js.h"
21+
#include "rtc.js.h"
2422
#endif /* !defined (CONFIG_HTTP_HTML_NO_RTC) && !defined (DISABLE_RTC) */
2523
#if !defined (CONFIG_HTTP_HTML_NO_RDM) && defined (RDM_CONTROLLER)
26-
# include "rdm.js.h"
24+
#include "rdm.js.h"
2725
#endif /* !defined (CONFIG_HTTP_HTML_NO_RDM) && defined (RDM_CONTROLLER) */
2826
#if !defined (CONFIG_HTTP_HTML_NO_TIME)
29-
# include "time.js.h"
27+
#include "time.js.h"
3028
#endif /* !defined (CONFIG_HTTP_HTML_NO_TIME) */
29+
#if !defined (CONFIG_HTTP_HTML_NO_PIXEL) && (defined(OUTPUT_DMX_PIXEL) || defined(OUTPUT_DMX_PIXEL_MULTI))
30+
#include "pixeltype.json.h"
31+
#endif /* !defined (CONFIG_HTTP_HTML_NO_PIXEL) && (defined(OUTPUT_DMX_PIXEL) || defined(OUTPUT_DMX_PIXEL_MULTI)) */
3132
#if !defined (CONFIG_HTTP_HTML_NO_RDM) && defined (RDM_CONTROLLER)
32-
# include "rdm.html.h"
33+
#include "rdm.html.h"
3334
#endif /* !defined (CONFIG_HTTP_HTML_NO_RDM) && defined (RDM_CONTROLLER) */
3435
#include "index.html.h"
3536
#if defined (NODE_SHOWFILE)
36-
# include "showfile.js.h"
37+
#include "showfile.js.h"
3738
#endif /* (NODE_SHOWFILE) */
3839
#if !defined (CONFIG_HTTP_HTML_NO_TIME)
39-
# include "time.html.h"
40+
#include "time.html.h"
4041
#endif /* !defined (CONFIG_HTTP_HTML_NO_TIME) */
4142
#if !defined (CONFIG_HTTP_HTML_NO_DMX) && (defined(OUTPUT_DMX_SEND) || defined(OUTPUT_DMX_SEND_MULTI))
42-
# include "dmx.html.h"
43+
#include "dmx.html.h"
4344
#endif /* !defined (CONFIG_HTTP_HTML_NO_DMX) && (defined(OUTPUT_DMX_SEND) || defined(OUTPUT_DMX_SEND_MULTI)) */
4445

4546
struct FilesContent {
46-
const char *pFileName;
47-
const char *pContent;
48-
const uint32_t nContentLength;
49-
const http::contentTypes contentType;
47+
const char *file_name;
48+
const char *content;
49+
uint32_t content_length;
50+
http::ContentTypes content_type;
5051
};
5152

52-
static constexpr struct FilesContent HttpContent[] = {
53+
inline constexpr struct FilesContent kHttpContent[] = {
5354
#if !defined (CONFIG_HTTP_HTML_NO_DMX) && (defined(OUTPUT_DMX_SEND) || defined(OUTPUT_DMX_SEND_MULTI))
54-
{ "dmx.js", dmx_js, 1357, static_cast<http::contentTypes>(2) },
55+
{ "dmx.js", dmx_js, 1357, static_cast<http::ContentTypes>(2) },
5556
#endif /* !defined (CONFIG_HTTP_HTML_NO_DMX) && (defined(OUTPUT_DMX_SEND) || defined(OUTPUT_DMX_SEND_MULTI)) */
5657
#if !defined (CONFIG_HTTP_HTML_NO_RTC) && !defined (DISABLE_RTC)
57-
{ "rtc.html", rtc_html, 1013, static_cast<http::contentTypes>(0) },
58+
{ "rtc.html", rtc_html, 1013, static_cast<http::ContentTypes>(0) },
5859
#endif /* !defined (CONFIG_HTTP_HTML_NO_RTC) && !defined (DISABLE_RTC) */
59-
{ "static.js", static_js, 1252, static_cast<http::contentTypes>(2) },
60-
{ "styles.css", styles_css, 409, static_cast<http::contentTypes>(1) },
61-
{ "index.js", index_js, 1168, static_cast<http::contentTypes>(2) },
62-
{ "date.js", date_js, 716, static_cast<http::contentTypes>(2) },
60+
{ "static.js", static_js, 1252, static_cast<http::ContentTypes>(2) },
61+
{ "styles.css", styles_css, 409, static_cast<http::ContentTypes>(1) },
62+
{ "index.js", index_js, 1168, static_cast<http::ContentTypes>(2) },
63+
{ "date.js", date_js, 716, static_cast<http::ContentTypes>(2) },
6364
#if defined (NODE_SHOWFILE)
64-
{ "showfile.html", showfile_html, 1386, static_cast<http::contentTypes>(0) },
65+
{ "showfile.html", showfile_html, 1386, static_cast<http::ContentTypes>(0) },
6566
#endif /* (NODE_SHOWFILE) */
66-
{ "default.js", default_js, 261, static_cast<http::contentTypes>(2) },
67+
{ "default.js", default_js, 261, static_cast<http::ContentTypes>(2) },
6768
#if !defined (CONFIG_HTTP_HTML_NO_RTC) && !defined (DISABLE_RTC)
68-
{ "rtc.js", rtc_js, 843, static_cast<http::contentTypes>(2) },
69+
{ "rtc.js", rtc_js, 843, static_cast<http::ContentTypes>(2) },
6970
#endif /* !defined (CONFIG_HTTP_HTML_NO_RTC) && !defined (DISABLE_RTC) */
7071
#if !defined (CONFIG_HTTP_HTML_NO_RDM) && defined (RDM_CONTROLLER)
71-
{ "rdm.js", rdm_js, 1001, static_cast<http::contentTypes>(2) },
72+
{ "rdm.js", rdm_js, 1001, static_cast<http::ContentTypes>(2) },
7273
#endif /* !defined (CONFIG_HTTP_HTML_NO_RDM) && defined (RDM_CONTROLLER) */
7374
#if !defined (CONFIG_HTTP_HTML_NO_TIME)
74-
{ "time.js", time_js, 402, static_cast<http::contentTypes>(2) },
75+
{ "time.js", time_js, 402, static_cast<http::ContentTypes>(2) },
7576
#endif /* !defined (CONFIG_HTTP_HTML_NO_TIME) */
77+
#if !defined (CONFIG_HTTP_HTML_NO_PIXEL) && (defined(OUTPUT_DMX_PIXEL) || defined(OUTPUT_DMX_PIXEL_MULTI))
78+
{ "pixeltype.json", pixeltype_json, 1665, static_cast<http::ContentTypes>(3) },
79+
#endif /* !defined (CONFIG_HTTP_HTML_NO_PIXEL) && (defined(OUTPUT_DMX_PIXEL) || defined(OUTPUT_DMX_PIXEL_MULTI)) */
7680
#if !defined (CONFIG_HTTP_HTML_NO_RDM) && defined (RDM_CONTROLLER)
77-
{ "rdm.html", rdm_html, 1142, static_cast<http::contentTypes>(0) },
81+
{ "rdm.html", rdm_html, 1142, static_cast<http::ContentTypes>(0) },
7882
#endif /* !defined (CONFIG_HTTP_HTML_NO_RDM) && defined (RDM_CONTROLLER) */
79-
{ "index.html", index_html, 669, static_cast<http::contentTypes>(0) },
83+
{ "index.html", index_html, 669, static_cast<http::ContentTypes>(0) },
8084
#if defined (NODE_SHOWFILE)
81-
{ "showfile.js", showfile_js, 1425, static_cast<http::contentTypes>(2) },
85+
{ "showfile.js", showfile_js, 1425, static_cast<http::ContentTypes>(2) },
8286
#endif /* (NODE_SHOWFILE) */
8387
#if !defined (CONFIG_HTTP_HTML_NO_TIME)
84-
{ "time.html", time_html, 599, static_cast<http::contentTypes>(0) },
88+
{ "time.html", time_html, 599, static_cast<http::ContentTypes>(0) },
8589
#endif /* !defined (CONFIG_HTTP_HTML_NO_TIME) */
8690
#if !defined (CONFIG_HTTP_HTML_NO_DMX) && (defined(OUTPUT_DMX_SEND) || defined(OUTPUT_DMX_SEND_MULTI))
87-
{ "dmx.html", dmx_html, 538, static_cast<http::contentTypes>(0) },
91+
{ "dmx.html", dmx_html, 538, static_cast<http::ContentTypes>(0) },
8892
#endif /* !defined (CONFIG_HTTP_HTML_NO_DMX) && (defined(OUTPUT_DMX_SEND) || defined(OUTPUT_DMX_SEND_MULTI)) */
8993
};
9094

95+
9196
#endif /* CONTENT_H_ */

0 commit comments

Comments
 (0)