22 * @file remoteconfig.cpp
33 *
44 */
5- /* Copyright (C) 2019-2025 by Arjan van Vught mailto:info@gd32-dmx.org
5+ /* Copyright (C) 2019-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
3535#include " remoteconfig.h"
3636#include " firmwareversion.h"
3737#include " hal.h"
38- #include " network .h"
38+ #include " network_udp .h"
3939#if !defined(CONFIG_REMOTECONFIG_MINIMUM)
4040#include " apps/mdns.h"
4141#include " dmxnode_nodetype.h"
4444#include " display.h"
4545#include " configstore.h"
4646#include " firmware/debug/debug_dump.h"
47- #include " firmware/debug/debug_debug.h"
47+ #include " firmware/debug/debug_debug.h"
4848
4949namespace remoteconfig ::udp
5050{
@@ -91,11 +91,24 @@ constexpr struct RemoteConfig::Commands RemoteConfig::kSet[] = {
9191 {&RemoteConfig::HandleDisplaySet, " display#" , 8 , true } //
9292};
9393
94- static constexpr char kOutput [static_cast <uint32_t >(remoteconfig::Output::LAST )][12 ] = {" DMX" , " RDM" , " Monitor" , " Pixel" , " TimeCode" , " OSC" , " Config" ,
95- " Stepper" , " Player" , " Art-Net" , " Serial" , " RGB Panel" , " PWM" };
94+ static constexpr char kOutput [static_cast <uint32_t >(remoteconfig::Output::LAST )][12 ] =
95+ {
96+ " DMX" ,
97+ " RDM" ,
98+ " Monitor" ,
99+ " Pixel" ,
100+ " TimeCode" ,
101+ " OSC" ,
102+ " Config" ,
103+ " Stepper" ,
104+ " Player" ,
105+ " Art-Net" ,
106+ " Serial" ,
107+ " RGB Panel" ,
108+ " PWM"
109+ };
96110
97- RemoteConfig::RemoteConfig (remoteconfig::Output output, uint32_t active_outputs)
98- : output_(output), active_outputs_(active_outputs)
111+ RemoteConfig::RemoteConfig (remoteconfig::Output output, uint32_t active_outputs) : output_(output), active_outputs_(active_outputs)
99112{
100113 DEBUG_ENTRY ();
101114
@@ -104,7 +117,7 @@ RemoteConfig::RemoteConfig(remoteconfig::Output output, uint32_t active_outputs)
104117 assert (s_this == nullptr );
105118 s_this = this ;
106119
107- network::iface::CopyMacAddressTo (s_list.mac_address );
120+ network::iface::CopyMacAddressTo (s_list.mac_address );
108121 s_list.output = static_cast <uint8_t >(output);
109122 s_list.active_outputs = static_cast <uint8_t >(active_outputs);
110123
@@ -143,7 +156,6 @@ RemoteConfig::~RemoteConfig()
143156 delete http_daemon_;
144157 }
145158#endif
146-
147159 network::apps::mdns::ServiceRecordDelete (network::apps::mdns::Services::kConfig );
148160#endif
149161
@@ -156,31 +168,31 @@ RemoteConfig::~RemoteConfig()
156168void RemoteConfig::SetDisplayName (const char * display_name)
157169{
158170 DEBUG_ENTRY ();
159-
171+
160172 char array[common::store::remoteconfig::kDisplayNameLength ];
161173
162- size_t len = strlen (display_name);
174+ size_t len = strlen (display_name);
163175 len = len > (common::store::remoteconfig::kDisplayNameLength - 1 ) ? common::store::remoteconfig::kDisplayNameLength - 1 : len;
164176 memcpy (reinterpret_cast <char *>(array), display_name, len);
165177
166178 for (uint32_t i = len; i < common::store::remoteconfig::kDisplayNameLength ; i++)
167179 {
168180 array[i] = ' \0 ' ;
169181 }
170-
171- ConfigStore::Instance ().RemoteConfigUpdateArray (&common::store::RemoteConfig::display_name, array, common::store::remoteconfig::kDisplayNameLength );
172182
173- DEBUG_EXIT ();
174- }
183+ ConfigStore::Instance ().RemoteConfigUpdateArray (&common::store::RemoteConfig::display_name, array, common::store::remoteconfig::kDisplayNameLength );
175184
176- namespace configstore
177- {
178- void SetFactoryDefaults ();
185+ DEBUG_EXIT ();
179186}
180187
181188void RemoteConfig::HandleFactory ()
182189{
183- configstore::SetFactoryDefaults ();
190+ DEBUG_ENTRY ();
191+
192+ ConfigStore::Instance ().Reset ();
193+ HandleReboot ();
194+
195+ DEBUG_EXIT ();
184196}
185197
186198void RemoteConfig::Input (const uint8_t * buffer, uint32_t size, uint32_t from_ip, [[maybe_unused]] uint16_t from_port)
@@ -301,7 +313,7 @@ void RemoteConfig::HandleList()
301313#if !defined(CONFIG_REMOTECONFIG_MINIMUM)
302314 const auto * const kNodeTypeName = dmxnode::GetNodeType (dmxnode::kNodeType );
303315#else
304- const auto * const kNodeTypeName = " Bootloader TFTP" ;
316+ const auto * const kNodeTypeName = " Bootloader TFTP" ;
305317#endif
306318
307319 if (display_name[0 ] != ' \0 ' )
0 commit comments