Skip to content

Commit 71cb1f1

Browse files
committed
Refactor OSC API naming & formatting
Apply consistent naming, formatting and minor API refactors across the OSC library: update copyright years to 2026; switch many constexpr identifiers to k-prefixed names and inline constexpr where appropriate; rename utility functions (e.g. GetPath, IsMatch) and adjust related callers; normalize namespace/brace/style and header comment formatting; tidy header guards comments; rename message constant keys to kParams/kStart/kStarted; replace network include with network_udp and adjust includes ordering; minor API/behavior-preserving changes in OSC client/server, blob, string, simple message/send and JSON parameter handling to match the new names and styles.
1 parent 1161f1a commit 71cb1f1

28 files changed

Lines changed: 432 additions & 801 deletions

gd32_emac_artnet_dmx_multi/firmware/main.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file main.cpp
33
*
44
*/
5-
/* Copyright (C) 2022-2025 by Arjan van Vught mailto:info@gd32-dmx.org
5+
/* Copyright (C) 2022-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
@@ -40,10 +40,8 @@
4040
#include "firmwareversion.h"
4141
#include "software_version.h"
4242

43-
namespace hal
44-
{
45-
void RebootHandler()
46-
{
43+
namespace hal {
44+
void RebootHandler() {
4745
Dmx::Get()->Blackout();
4846
ArtNetNode::Get()->Stop();
4947
}
@@ -71,8 +69,7 @@ int main() // NOLINT
7169
DmxNodeNode dmxnode_node;
7270
dmxnode_node.SetOutput(&dmx_send);
7371

74-
for (uint32_t port_index = 0; port_index < dmxnode::kMaxPorts; port_index++)
75-
{
72+
for (uint32_t port_index = 0; port_index < dmxnode::kMaxPorts; port_index++) {
7673
const auto kPortDirection = (dmxnode_node.GetPortDirection(port_index) == dmxnode::PortDirection::kOutput ? dmx::PortDirection::kOutput : dmx::PortDirection::kInput);
7774
dmx.SetPortDirection(port_index, kPortDirection, false);
7875
}
@@ -98,7 +95,7 @@ int main() // NOLINT
9895
displayudf_params.Load();
9996
displayudf_params.SetAndShow();
10097

101-
RemoteConfig remote_config( kIsRdmEnabled ? remoteconfig::Output::RDM : remoteconfig::Output::DMX, kActivePorts);
98+
RemoteConfig remote_config(kIsRdmEnabled ? remoteconfig::Output::RDM : remoteconfig::Output::DMX, kActivePorts);
10299

103100
display.TextStatus(DmxNodeMsgConst::START, console::Colours::kConsoleYellow);
104101

@@ -108,8 +105,7 @@ int main() // NOLINT
108105

109106
hal::WatchdogInit();
110107

111-
for (;;)
112-
{
108+
for (;;) {
113109
hal::WatchdogFeed();
114110
network::Run();
115111
dmxnode_node.Run();

gd32_emac_e131_dmx_multi/firmware/main.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file main.cpp
33
*
44
*/
5-
/* Copyright (C) 2022-2025 by Arjan van Vught mailto:info@gd32-dmx.org
5+
/* Copyright (C) 2022-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
@@ -44,10 +44,8 @@
4444
#include "firmwareversion.h"
4545
#include "software_version.h"
4646

47-
namespace hal
48-
{
49-
void RebootHandler()
50-
{
47+
namespace hal {
48+
void RebootHandler() {
5149
Dmx::Get()->Blackout();
5250
E131Bridge::Get()->Stop();
5351
}
@@ -75,8 +73,7 @@ int main() // NOLINT
7573
DmxNodeNode dmxnode_node;
7674
dmxnode_node.SetOutput(&dmx_send);
7775

78-
for (uint32_t port_index = 0; port_index < dmxnode::kMaxPorts; port_index++)
79-
{
76+
for (uint32_t port_index = 0; port_index < dmxnode::kMaxPorts; port_index++) {
8077
const auto kPortDirection = (dmxnode_node.GetPortDirection(port_index) == dmxnode::PortDirection::kOutput ? dmx::PortDirection::kOutput : dmx::PortDirection::kInput);
8178
dmx.SetPortDirection(port_index, kPortDirection, false);
8279
}
@@ -115,8 +112,7 @@ int main() // NOLINT
115112

116113
hal::WatchdogInit();
117114

118-
for (;;)
119-
{
115+
for (;;) {
120116
hal::WatchdogFeed();
121117
network::Run();
122118
dmxnode_node.Run();

lib-osc/include/json/oscclientparams.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file oscclientparams.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
@@ -33,10 +33,8 @@
3333
#include "json/json_key.h"
3434
#include "json/json_params_base.h"
3535

36-
namespace json
37-
{
38-
class OscClientParams : public JsonParamsBase<OscClientParams>
39-
{
36+
namespace json {
37+
class OscClientParams : public JsonParamsBase<OscClientParams> {
4038
public:
4139
OscClientParams();
4240

lib-osc/include/json/oscclientparamsconst.h

Lines changed: 31 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,39 @@
22
* @file oscclientparamsconst.h
33
*
44
*/
5-
/* Copyright (C) 2025 by Arjan van Vught mailto:info@gd32-dmx.org
6-
*
7-
* Permission is hereby granted, free of charge, to any person obtaining a copy
8-
* of this software and associated documentation files (the "Software"), to deal
9-
* in the Software without restriction, including without limitation the rights
10-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11-
* copies of the Software, and to permit persons to whom the Software is
12-
* furnished to do so, subject to the following conditions:
5+
/* Copyright (C) 2025-2026 by Arjan van Vught mailto:info@gd32-dmx.org
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
1313
14-
* The above copyright notice and this permission notice shall be included in
15-
* all copies or substantial portions of the Software.
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
1616
17-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23-
* THE SOFTWARE.
24-
*/
25-
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
2625

2726
#ifndef JSON_OSCCLIENTPARAMSCONST_H_
2827
#define JSON_OSCCLIENTPARAMSCONST_H_
2928

3029
#include "json/json_key.h"
3130

32-
namespace json
33-
{
34-
struct OscClientParamsConst
35-
{
36-
static constexpr char kFileName[] = "oscclient.json";
37-
38-
static constexpr json::SimpleKey kServerIp {
39-
"server_ip",
40-
9,
41-
Fnv1a32("server_ip", 9)
42-
};
43-
44-
static constexpr json::SimpleKey kPingDisable {
45-
"ping_disable",
46-
12,
47-
Fnv1a32("ping_disable", 12)
48-
};
49-
50-
static constexpr json::SimpleKey kPingDelay {
51-
"ping_delay",
52-
10,
53-
Fnv1a32("ping_delay", 10)
54-
};
31+
namespace json {
32+
struct OscClientParamsConst {
33+
static constexpr char kFileName[] = "oscclient.json";
34+
35+
static constexpr json::SimpleKey kServerIp{"server_ip", 9, Fnv1a32("server_ip", 9)};
36+
static constexpr json::SimpleKey kPingDisable{"ping_disable", 12, Fnv1a32("ping_disable", 12)};
37+
static constexpr json::SimpleKey kPingDelay{"ping_delay", 10, Fnv1a32("ping_delay", 10)};
5538

5639
static constexpr json::PortKey kCmd0{"cmd0", 4, Fnv1a32("cmd0", 4)};
5740
static constexpr json::PortKey kCmd1{"cmd1", 4, Fnv1a32("cmd1", 4)};
@@ -62,18 +45,10 @@ struct OscClientParamsConst
6245
static constexpr json::PortKey kCmd6{"cmd6", 4, Fnv1a32("cmd6", 4)};
6346
static constexpr json::PortKey kCmd7{"cmd7", 4, Fnv1a32("cmd7", 4)};
6447

65-
static constexpr json::PortKey kCmd[] =
66-
{
67-
kCmd0,
68-
kCmd1,
69-
kCmd2,
70-
kCmd3,
71-
kCmd4,
72-
kCmd5,
73-
kCmd6,
74-
kCmd7,
48+
static constexpr json::PortKey kCmd[] = {
49+
kCmd0, kCmd1, kCmd2, kCmd3, kCmd4, kCmd5, kCmd6, kCmd7,
7550
};
76-
51+
7752
static constexpr json::PortKey kLed0{"led0", 4, Fnv1a32("led0", 4)};
7853
static constexpr json::PortKey kLed1{"led1", 4, Fnv1a32("led1", 4)};
7954
static constexpr json::PortKey kLed2{"led2", 4, Fnv1a32("led2", 4)};
@@ -83,19 +58,10 @@ struct OscClientParamsConst
8358
static constexpr json::PortKey kLed6{"led6", 4, Fnv1a32("led6", 4)};
8459
static constexpr json::PortKey kLed7{"led7", 4, Fnv1a32("led7", 4)};
8560

86-
static constexpr json::PortKey kLed[] =
87-
{
88-
kLed0,
89-
kLed1,
90-
kLed2,
91-
kLed3,
92-
kLed4,
93-
kLed5,
94-
kLed6,
95-
kLed7,
61+
static constexpr json::PortKey kLed[] = {
62+
kLed0, kLed1, kLed2, kLed3, kLed4, kLed5, kLed6, kLed7,
9663
};
97-
9864
};
9965
} // namespace json
10066

101-
#endif // JSON_OSCCLIENTPARAMSCONST_H_
67+
#endif // JSON_OSCCLIENTPARAMSCONST_H_

lib-osc/include/json/oscparamsconst.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @file oscparamsconst.h
33
*/
4-
/* Copyright (C) 2025 by Arjan van Vught mailto:info@gd32-dmx.org
4+
/* Copyright (C) 2025-2026 by Arjan van Vught mailto:info@gd32-dmx.org
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -27,11 +27,9 @@
2727

2828
#include "json/json_key.h"
2929

30-
namespace json
31-
{
32-
struct OscParamsConst
33-
{
34-
static constexpr json::SimpleKey kIncomingPort {
30+
namespace json {
31+
struct OscParamsConst {
32+
static constexpr json::SimpleKey kIncomingPort {
3533
"incoming_port",
3634
13,
3735
Fnv1a32("incoming_port", 13)

lib-osc/include/json/oscserverparams.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file oscserverparams.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
@@ -33,10 +33,8 @@
3333
#include "json/json_key.h"
3434
#include "json/json_params_base.h"
3535

36-
namespace json
37-
{
38-
class OscServerParams : public JsonParamsBase<OscServerParams>
39-
{
36+
namespace json {
37+
class OscServerParams : public JsonParamsBase<OscServerParams> {
4038
public:
4139
OscServerParams();
4240

lib-osc/include/json/oscserverparamsconst.h

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -28,40 +28,15 @@
2828

2929
#include "json/json_key.h"
3030

31-
namespace json
32-
{
33-
struct OscServerParamsConst
34-
{
31+
namespace json {
32+
struct OscServerParamsConst {
3533
static constexpr char kFileName[] = "oscserver.json";
3634

37-
static constexpr json::SimpleKey kPath
38-
{
39-
"path",
40-
4,
41-
Fnv1a32("path", 4)
42-
};
43-
44-
static constexpr json::SimpleKey kPathInfo
45-
{
46-
"path_info",
47-
9,
48-
Fnv1a32("path_info", 9)
49-
};
50-
51-
static constexpr json::SimpleKey kPathBlackout
52-
{
53-
"path_blackout",
54-
13,
55-
Fnv1a32("path_blackout", 13)
56-
};
57-
58-
static constexpr json::SimpleKey kTransmission
59-
{
60-
"partial_transmission",
61-
19,
62-
Fnv1a32("partial_transmission", 19)
63-
};
35+
static constexpr json::SimpleKey kPath{"path", 4, Fnv1a32("path", 4)};
36+
static constexpr json::SimpleKey kPathInfo{"path_info", 9, Fnv1a32("path_info", 9)};
37+
static constexpr json::SimpleKey kPathBlackout{"path_blackout", 13, Fnv1a32("path_blackout", 13)};
38+
static constexpr json::SimpleKey kTransmission{"partial_transmission", 19, Fnv1a32("partial_transmission", 19)};
6439
};
6540
} // namespace json
6641

67-
#endif // JSON_OSCSERVERPARAMSCONST_H_
42+
#endif // JSON_OSCSERVERPARAMSCONST_H_

0 commit comments

Comments
 (0)