mirror of
https://github.com/MrUnknownDE/OpenIris-ESPIDF.git
synced 2026-04-17 13:33:44 +02:00
Add 'get_who_am_i' command and related configurations for device identification
This commit is contained in:
@@ -26,7 +26,8 @@ std::unordered_map<std::string, CommandType> commandTypeMap = {
|
||||
{"set_led_duty_cycle", CommandType::SET_LED_DUTY_CYCLE},
|
||||
{"get_led_duty_cycle", CommandType::GET_LED_DUTY_CYCLE},
|
||||
{"get_serial", CommandType::GET_SERIAL},
|
||||
{"get_led_current", CommandType::GET_LED_CURRENT},
|
||||
{"get_led_current", CommandType::GET_LED_CURRENT},
|
||||
{"get_who_am_i", CommandType::GET_WHO_AM_I},
|
||||
};
|
||||
|
||||
std::function<CommandResult()> CommandManager::createCommand(const CommandType type, std::string_view json) const
|
||||
@@ -107,6 +108,9 @@ std::function<CommandResult()> CommandManager::createCommand(const CommandType t
|
||||
case CommandType::GET_LED_CURRENT:
|
||||
return [this]
|
||||
{ return getLEDCurrentCommand(this->registry); };
|
||||
case CommandType::GET_WHO_AM_I:
|
||||
return [this]
|
||||
{ return getInfoCommand(this->registry); };
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ enum class CommandType
|
||||
GET_LED_DUTY_CYCLE,
|
||||
GET_SERIAL,
|
||||
GET_LED_CURRENT,
|
||||
GET_WHO_AM_I,
|
||||
};
|
||||
|
||||
class CommandManager
|
||||
|
||||
@@ -248,3 +248,14 @@ CommandResult getLEDCurrentCommand(std::shared_ptr<DependencyRegistry> registry)
|
||||
return CommandResult::getErrorResult("Monitoring disabled");
|
||||
#endif
|
||||
}
|
||||
|
||||
CommandResult getInfoCommand(std::shared_ptr<DependencyRegistry> /*registry*/)
|
||||
{
|
||||
const char* who = CONFIG_GENERAL_WHO_AM_I;
|
||||
const char* ver = CONFIG_GENERAL_Version;
|
||||
// Ensure non-null strings
|
||||
if (!who) who = "";
|
||||
if (!ver) ver = "";
|
||||
auto result = std::format("{{ \"who_am_i\": \"{}\", \"version\": \"{}\" }}", who, ver);
|
||||
return CommandResult::getSuccessResult(result);
|
||||
}
|
||||
|
||||
@@ -25,4 +25,7 @@ CommandResult getDeviceModeCommand(std::shared_ptr<DependencyRegistry> registry)
|
||||
CommandResult getSerialNumberCommand(std::shared_ptr<DependencyRegistry> registry);
|
||||
|
||||
// Monitoring
|
||||
CommandResult getLEDCurrentCommand(std::shared_ptr<DependencyRegistry> registry);
|
||||
CommandResult getLEDCurrentCommand(std::shared_ptr<DependencyRegistry> registry);
|
||||
|
||||
// General info
|
||||
CommandResult getInfoCommand(std::shared_ptr<DependencyRegistry> registry);
|
||||
@@ -38,6 +38,18 @@ menu "OpenIris: General Configuration"
|
||||
and any Bluetooth memory (if present on the SoC) should be left released. This can
|
||||
reduce power consumption when operating solely in UVC mode or without networking.
|
||||
|
||||
config GENERAL_WHO_AM_I
|
||||
string "Who am I (device identifier)"
|
||||
default "OpenIris"
|
||||
help
|
||||
A human-readable product or device identifier exposed via the get_info command.
|
||||
|
||||
config GENERAL_Version
|
||||
string "Firmware version"
|
||||
default "0.0.0"
|
||||
help
|
||||
A firmware version string exposed via the get_info command.
|
||||
|
||||
endmenu
|
||||
|
||||
menu "OpenIris: Camera Configuration"
|
||||
|
||||
@@ -574,6 +574,8 @@ CONFIG_ENV_GPIO_OUT_RANGE_MAX=48
|
||||
CONFIG_GENERAL_INCLUDE_UVC_MODE=y
|
||||
CONFIG_GENERAL_STARTUP_DELAY=30
|
||||
CONFIG_GENERAL_ENABLE_WIRELESS=y
|
||||
CONFIG_GENERAL_WHO_AM_I="facefocusvr_face"
|
||||
CONFIG_GENERAL_Version="0.0.1"
|
||||
# end of OpenIris: General Configuration
|
||||
|
||||
#
|
||||
|
||||
@@ -573,6 +573,7 @@ CONFIG_ENV_GPIO_OUT_RANGE_MAX=48
|
||||
# CONFIG_GENERAL_INCLUDE_UVC_MODE is not set
|
||||
# CONFIG_START_IN_UVC_MODE is not set
|
||||
# CONFIG_GENERAL_STARTUP_DELAY is not set
|
||||
CONFIG_GENERAL_Version="0.0.1"
|
||||
# end of OpenIris: General Configuration
|
||||
|
||||
#
|
||||
|
||||
@@ -60,4 +60,11 @@ CONFIG_LED_EXTERNAL_PWM_FREQ=20000
|
||||
CONFIG_LED_EXTERNAL_PWM_DUTY_CYCLE=50
|
||||
CONFIG_CAMERA_USB_XCLK_FREQ=23000000
|
||||
CONFIG_GENERAL_INCLUDE_UVC_MODE=y
|
||||
CONFIG_START_IN_UVC_MODE=y
|
||||
CONFIG_START_IN_UVC_MODE=y
|
||||
CONFIG_MONITORING_LED_CURRENT=y
|
||||
CONFIG_MONITORING_LED_ADC_GPIO=3
|
||||
CONFIG_MONITORING_LED_GAIN=11
|
||||
CONFIG_MONITORING_LED_SHUNT_MILLIOHM=22000
|
||||
CONFIG_MONITORING_LED_SAMPLES=10
|
||||
CONFIG_MONITORING_LED_INTERVAL_MS=500
|
||||
CONFIG_GENERAL_WHO_AM_I="facefocusvr_eye"
|
||||
@@ -60,4 +60,11 @@ CONFIG_LED_EXTERNAL_PWM_FREQ=20000
|
||||
CONFIG_LED_EXTERNAL_PWM_DUTY_CYCLE=100
|
||||
CONFIG_CAMERA_USB_XCLK_FREQ=23000000
|
||||
CONFIG_GENERAL_INCLUDE_UVC_MODE=y
|
||||
CONFIG_START_IN_UVC_MODE=y
|
||||
CONFIG_START_IN_UVC_MODE=y
|
||||
CONFIG_MONITORING_LED_CURRENT=y
|
||||
CONFIG_MONITORING_LED_ADC_GPIO=3
|
||||
CONFIG_MONITORING_LED_GAIN=11
|
||||
CONFIG_MONITORING_LED_SHUNT_MILLIOHM=22000
|
||||
CONFIG_MONITORING_LED_SAMPLES=10
|
||||
CONFIG_MONITORING_LED_INTERVAL_MS=500
|
||||
CONFIG_GENERAL_WHO_AM_I="facefocusvr_face"
|
||||
@@ -52,4 +52,6 @@ CONFIG_LED_EXTERNAL_PWM_DUTY_CYCLE=100
|
||||
CONFIG_LED_EXTERNAL_GPIO=1
|
||||
CONFIG_CAMERA_USB_XCLK_FREQ=23000000
|
||||
CONFIG_GENERAL_INCLUDE_UVC_MODE=y
|
||||
# CONFIG_START_IN_UVC_MODE is not set
|
||||
# CONFIG_START_IN_UVC_MODE is not set
|
||||
# CONFIG_MONITORING_LED_CURRENT is not set
|
||||
CONFIG_GENERAL_WHO_AM_I="project_babble"
|
||||
@@ -57,4 +57,6 @@ CONFIG_SPIRAM_SPEED_80M=y
|
||||
# CONFIG_LED_EXTERNAL_CONTROL is not set
|
||||
CONFIG_CAMERA_USB_XCLK_FREQ=23000000
|
||||
CONFIG_GENERAL_INCLUDE_UVC_MODE=y
|
||||
# CONFIG_START_IN_UVC_MODE is not set
|
||||
# CONFIG_START_IN_UVC_MODE is not set
|
||||
# CONFIG_MONITORING_LED_CURRENT is not set
|
||||
CONFIG_GENERAL_WHO_AM_I="xiao_esp32s3"
|
||||
@@ -975,6 +975,22 @@ def _probe_serial(device: OpenIrisDevice) -> Dict:
|
||||
serial, mac = info
|
||||
return {"serial": serial, "mac": mac}
|
||||
|
||||
def _probe_info(device: OpenIrisDevice) -> Dict:
|
||||
resp = device.send_command("get_who_am_i")
|
||||
if "error" in resp:
|
||||
return {"who_am_i": None, "version": None, "error": resp["error"]}
|
||||
try:
|
||||
results = resp.get("results", [])
|
||||
if results:
|
||||
result_data = json.loads(results[0])
|
||||
payload = result_data["result"]
|
||||
if isinstance(payload, str):
|
||||
payload = json.loads(payload)
|
||||
return {"who_am_i": payload.get("who_am_i"), "version": payload.get("version")}
|
||||
except Exception as e:
|
||||
return {"who_am_i": None, "version": None, "error": str(e)}
|
||||
return {"who_am_i": None, "version": None}
|
||||
|
||||
|
||||
def _probe_led_pwm(device: OpenIrisDevice) -> Dict:
|
||||
duty = device.get_led_duty_cycle()
|
||||
@@ -1013,7 +1029,8 @@ def get_settings(device: OpenIrisDevice, args=None):
|
||||
print("\n🧩 Collecting device settings...\n")
|
||||
|
||||
probes = [
|
||||
("Identity", _probe_serial),
|
||||
("Identity", _probe_serial),
|
||||
("Info", _probe_info),
|
||||
("LED", _probe_led_pwm),
|
||||
("Current", _probe_led_current),
|
||||
("Mode", _probe_mode),
|
||||
@@ -1041,6 +1058,15 @@ def get_settings(device: OpenIrisDevice, args=None):
|
||||
if not serial and not mac:
|
||||
print("🔑 Serial/MAC: unavailable")
|
||||
|
||||
# LED
|
||||
info = summary.get("Info", {})
|
||||
who = info.get("who_am_i")
|
||||
ver = info.get("version")
|
||||
if who:
|
||||
print(f"🏷️ Device: {who}")
|
||||
if ver:
|
||||
print(f"🧭 Version: {ver}")
|
||||
|
||||
# LED
|
||||
led = summary.get("LED", {})
|
||||
duty = led.get("led_external_pwm_duty_cycle")
|
||||
|
||||
Reference in New Issue
Block a user