Add UVC device name configuration and update device name retrieval logic

This commit is contained in:
PhosphorosVR
2025-09-05 19:36:09 +02:00
parent 4ed397ca2d
commit 8138ffa36d
5 changed files with 28 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
#include "UVCStream.hpp"
#include <cstdio> // for snprintf
#include <string>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
// no deps on main globals here; handover is performed in main before calling setup when needed
@@ -12,7 +13,21 @@ extern "C"
const char *get_uvc_device_name()
{
return deviceConfig->getMDNSConfig().hostname.c_str();
// Prefer explicit UVC name from Kconfig, fallback to mDNS hostname when empty
static std::string cached_name;
if (cached_name.empty())
{
const char *cfg_name = CONFIG_GENERAL_UVC_NAME;
if (cfg_name && cfg_name[0] != '\0')
{
cached_name = cfg_name;
}
else
{
cached_name = deviceConfig->getMDNSConfig().hostname;
}
}
return cached_name.c_str();
}
const char *get_serial_number(void)