mirror of
https://github.com/MrUnknownDE/OpenIris-ESPIDF.git
synced 2026-04-18 22:13:45 +02:00
Add support for setting a custom device name and per-board serial number for UVC
This commit is contained in:
@@ -3,6 +3,30 @@ constexpr int UVC_MAX_FRAMESIZE_SIZE(75 * 1024);
|
||||
|
||||
static const char *UVC_STREAM_TAG = "[UVC DEVICE]";
|
||||
|
||||
extern "C" {
|
||||
static char serial_number_str[13];
|
||||
|
||||
const char *get_uvc_device_name() {
|
||||
return deviceConfig->getMDNSConfig().hostname.c_str();
|
||||
}
|
||||
|
||||
const char *get_serial_number(void) {
|
||||
if (serial_number_str[0] == '\0') {
|
||||
uint8_t mac_address[6];
|
||||
esp_err_t result = esp_efuse_mac_get_default(mac_address);
|
||||
if (result != ESP_OK) {
|
||||
ESP_LOGE(UVC_STREAM_TAG, "Failed to get MAC address of the board, returning default serial number");
|
||||
return CONFIG_TUSB_SERIAL_NUM;
|
||||
}
|
||||
|
||||
sniprintf(serial_number_str, sizeof(serial_number_str), "%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
mac_address[0], mac_address[1], mac_address[2], mac_address[3], mac_address[4], mac_address[5]
|
||||
);
|
||||
}
|
||||
return serial_number_str;
|
||||
}
|
||||
}
|
||||
|
||||
static esp_err_t UVCStreamHelpers::camera_start_cb(uvc_format_t format, int width, int height, int rate, void *cb_ctx)
|
||||
{
|
||||
(void)cb_ctx;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#ifndef UVCSTREAM_HPP
|
||||
#define UVCSTREAM_HPP
|
||||
#include "esp_timer.h"
|
||||
#include "esp_mac.h"
|
||||
#include "esp_camera.h"
|
||||
#include <CameraManager.hpp>
|
||||
#include <StateManager.hpp>
|
||||
@@ -13,6 +14,18 @@
|
||||
// we need access to the camera manager
|
||||
// in order to update the frame settings
|
||||
extern std::shared_ptr<CameraManager> cameraHandler;
|
||||
extern std::shared_ptr<ProjectConfig> deviceConfig;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
const char *get_uvc_device_name();
|
||||
const char *get_serial_number(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
// we also need a way to inform the rest of the system of what's happening
|
||||
extern QueueHandle_t eventQueue;
|
||||
|
||||
Reference in New Issue
Block a user