mirror of
https://github.com/EyeTrackVR/OpenIris.git
synced 2025-09-26 23:29:14 +08:00
feat: Release 2.5.0
* Refactor commands and serial manager to support updated commands payload * set setMinSecurity to WIFI_AUTH_WEP to fix boards not connecting to some networks, cleanup some logs and comments * feat: Move logging in serial streaming so that we at least attempt to get new frame * remove unused etvr_eye_tracker_usb * PoC query manager for better flasher logging * simplify query implementation * remove old include * fix: serial output for esp32cams and other boards not supporting higher frequency baud rate * fix: serial output for esp32cams and other boards not supporting higher frequency baud rate * Switch higher frequency to be opt-in * feat: Add support for ov5640 cameras * feat: fix usb streaming on wroom boards, add support for babble custom board * feat: PoC add support for project babble board * Add support for bable wireless, adjust flash_mode and memory type to get PSRAM working * Add DARDUINO_USB_MODE=1 and DARDUINO_USB_CDC_ON_BOOT=1 to Babble and wroom boards to fix USB streaming discovered and fixed entirely by Rames the Generic * cleanup PoC
This commit is contained in:
parent
3fa84dc100
commit
81cda523bb
31
CHANGELOG.md
31
CHANGELOG.md
@ -3,6 +3,37 @@
|
||||
[](https://semver.org)
|
||||
> All notable changes to this project will be documented in this file
|
||||
|
||||
## [2.5.0-beta.1](https://github.com/EyeTrackVR/OpenIris/compare/v2.4.0...v2.5.0-beta.1) (2024-06-11)
|
||||
|
||||
|
||||
### 🍕 Features
|
||||
|
||||
* Add support for ov5640 cameras ([14d2cb0](https://github.com/EyeTrackVR/OpenIris/commit/14d2cb0858cd65452f2ce1cee9a3a1f68d8f7f51))
|
||||
* Fix ov5640 support implementation after beta cleanup ([4894c22](https://github.com/EyeTrackVR/OpenIris/commit/4894c2205864d5a7d52e37c81b14ff7dc46517d4))
|
||||
* fix usb streaming on wroom boards, add support for babble custom board ([049b160](https://github.com/EyeTrackVR/OpenIris/commit/049b16078ec5c07042652f2de3545ea6b69de6a9))
|
||||
* Move logging in serial streaming so that we at least attempt to get new frame ([53a3d4b](https://github.com/EyeTrackVR/OpenIris/commit/53a3d4bcd603e2fd07546621628e69de88e4139a))
|
||||
* Refactor commands and serial manager to support updated commands payload ([811a9f8](https://github.com/EyeTrackVR/OpenIris/commit/811a9f898a3f1bdb1e20ffd6f0d6e77a4533f52c))
|
||||
|
||||
|
||||
### 🐛 Bug Fixes
|
||||
|
||||
* serial output for esp32cams and other boards not supporting higher frequency baud rate ([01e5e28](https://github.com/EyeTrackVR/OpenIris/commit/01e5e280ad26d2709231fe6aa2a96d1991cbf360))
|
||||
|
||||
## [2.5.0-beta.1](https://github.com/EyeTrackVR/OpenIris/compare/v2.4.0...v2.5.0-beta.1) (2024-06-10)
|
||||
|
||||
|
||||
### 🍕 Features
|
||||
|
||||
* Add support for ov5640 cameras ([14d2cb0](https://github.com/EyeTrackVR/OpenIris/commit/14d2cb0858cd65452f2ce1cee9a3a1f68d8f7f51))
|
||||
* fix usb streaming on wroom boards, add support for babble custom board ([049b160](https://github.com/EyeTrackVR/OpenIris/commit/049b16078ec5c07042652f2de3545ea6b69de6a9))
|
||||
* Move logging in serial streaming so that we at least attempt to get new frame ([53a3d4b](https://github.com/EyeTrackVR/OpenIris/commit/53a3d4bcd603e2fd07546621628e69de88e4139a))
|
||||
* Refactor commands and serial manager to support updated commands payload ([811a9f8](https://github.com/EyeTrackVR/OpenIris/commit/811a9f898a3f1bdb1e20ffd6f0d6e77a4533f52c))
|
||||
|
||||
|
||||
### 🐛 Bug Fixes
|
||||
|
||||
* serial output for esp32cams and other boards not supporting higher frequency baud rate ([01e5e28](https://github.com/EyeTrackVR/OpenIris/commit/01e5e280ad26d2709231fe6aa2a96d1991cbf360))
|
||||
|
||||
## [2.4.0](https://github.com/EyeTrackVR/OpenIris/compare/v2.3.0...v2.4.0) (2024-03-11)
|
||||
|
||||
|
||||
|
@ -103,6 +103,7 @@ build_type = debug
|
||||
build_flags = ${env.build_flags}
|
||||
-DCORE_DEBUG_LEVEL=4
|
||||
-DDEBUG_MODE=1
|
||||
-DSERIAL_MANAGER_USE_HIGHER_FREQUENCY
|
||||
${pinoutsESPS3WROVER.build_flags}
|
||||
upload_flags = --no-stub
|
||||
|
||||
@ -113,6 +114,7 @@ build_type = release
|
||||
build_flags = ${env.build_flags}
|
||||
-DDEBUG_MODE=0
|
||||
-DCORE_DEBUG_LEVEL=1
|
||||
-DSERIAL_MANAGER_USE_HIGHER_FREQUENCY
|
||||
${pinoutsESPS3WROVER.build_flags}
|
||||
upload_flags = --no-stub
|
||||
|
||||
@ -123,8 +125,10 @@ build_type = debug
|
||||
build_flags = ${env.build_flags}
|
||||
-DCORE_DEBUG_LEVEL=4
|
||||
-DDEBUG_MODE=1
|
||||
-DARDUINO_USB_MODE=1
|
||||
-DARDUINO_USB_CDC_ON_BOOT=1
|
||||
-DETVR_EYE_TRACKER_USB_API
|
||||
-DSERIAL_MANAGER_USE_HIGHER_FREQUENCY
|
||||
${pinoutsESPS3WROVER.build_flags}
|
||||
|
||||
[env:wrooms3QIOUSB_release]
|
||||
@ -134,8 +138,10 @@ build_type = release
|
||||
build_flags = ${env.build_flags}
|
||||
-DDEBUG_MODE=0
|
||||
-DCORE_DEBUG_LEVEL=1
|
||||
-DARDUINO_USB_MODE=1
|
||||
-DARDUINO_USB_CDC_ON_BOOT=1
|
||||
-DETVR_EYE_TRACKER_USB_API
|
||||
-DSERIAL_MANAGER_USE_HIGHER_FREQUENCY
|
||||
${pinoutsESPS3WROVER.build_flags}
|
||||
|
||||
[env:wrooms3]
|
||||
@ -144,6 +150,7 @@ build_type = debug
|
||||
build_flags = ${env.build_flags}
|
||||
-DCORE_DEBUG_LEVEL=4
|
||||
-DDEBUG_MODE=1
|
||||
-DSERIAL_MANAGER_USE_HIGHER_FREQUENCY
|
||||
${pinoutsESPS3WROOM.build_flags}
|
||||
|
||||
[env:wrooms3_release]
|
||||
@ -152,6 +159,7 @@ build_type = release
|
||||
build_flags = ${env.build_flags}
|
||||
-DDEBUG_MODE=0
|
||||
-DCORE_DEBUG_LEVEL=1
|
||||
-DSERIAL_MANAGER_USE_HIGHER_FREQUENCY
|
||||
${pinoutsESPS3WROOM.build_flags}
|
||||
|
||||
[env:wrooms3USB]
|
||||
@ -160,7 +168,10 @@ build_type = debug
|
||||
build_flags = ${env.build_flags}
|
||||
-DCORE_DEBUG_LEVEL=4
|
||||
-DDEBUG_MODE=1
|
||||
-DARDUINO_USB_MODE=1
|
||||
-DARDUINO_USB_CDC_ON_BOOT=1
|
||||
-DETVR_EYE_TRACKER_USB_API
|
||||
-DSERIAL_MANAGER_USE_HIGHER_FREQUENCY
|
||||
${pinoutsESPS3WROOM.build_flags}
|
||||
upload_flags = --no-stub
|
||||
|
||||
@ -170,10 +181,40 @@ build_type = release
|
||||
build_flags = ${env.build_flags}
|
||||
-DDEBUG_MODE=0
|
||||
-DCORE_DEBUG_LEVEL=1
|
||||
-DARDUINO_USB_MODE=1
|
||||
-DARDUINO_USB_CDC_ON_BOOT=1
|
||||
-DETVR_EYE_TRACKER_USB_API
|
||||
-DSERIAL_MANAGER_USE_HIGHER_FREQUENCY
|
||||
${pinoutsESPS3WROOM.build_flags}
|
||||
upload_flags = --no-stub
|
||||
|
||||
[env:Babble-wrooms-s3]
|
||||
board = esp32-s3-devkitc-1
|
||||
board_build.flash_mode = qio ; qio_qspi
|
||||
board_build.arduino.memory_type = qio_qspi
|
||||
build_type = debug
|
||||
build_flags = ${env.build_flags}
|
||||
-DCORE_DEBUG_LEVEL=4
|
||||
-DDEBUG_MODE=1
|
||||
-DSERIAL_MANAGER_USE_HIGHER_FREQUENCY
|
||||
${pinoutSWROOMBABBLES3.build_flags}
|
||||
upload_flags = --no-stub
|
||||
|
||||
[env:Babble_USB-wrooms-s3]
|
||||
board = esp32-s3-devkitc-1
|
||||
board_build.flash_mode = qio ; qio_qspi
|
||||
board_build.arduino.memory_type = qio_qspi
|
||||
build_type = debug
|
||||
build_flags = ${env.build_flags}
|
||||
-DCORE_DEBUG_LEVEL=4
|
||||
-DDEBUG_MODE=1
|
||||
-DETVR_EYE_TRACKER_USB_API
|
||||
-DARDUINO_USB_MODE=1
|
||||
-DARDUINO_USB_CDC_ON_BOOT=1
|
||||
-DSERIAL_MANAGER_USE_HIGHER_FREQUENCY
|
||||
${pinoutSWROOMBABBLES3.build_flags}
|
||||
upload_flags = --no-stub
|
||||
|
||||
[env:xiaosenses3]
|
||||
board = seeed_xiao_esp32s3
|
||||
build_type = debug
|
||||
@ -182,6 +223,7 @@ build_flags = ${env.build_flags}
|
||||
-DDEBUG_MODE=1
|
||||
#-DARDUINO_USB_MODE=1
|
||||
#-DARDUINO_USB_CDC_ON_BOOT=1
|
||||
-DSERIAL_MANAGER_USE_HIGHER_FREQUENCY
|
||||
${pinoutsESPS3XIAOSENSE.build_flags}
|
||||
|
||||
[env:xiaosenses3_USB]
|
||||
@ -191,6 +233,7 @@ build_flags = ${env.build_flags}
|
||||
-DCORE_DEBUG_LEVEL=4
|
||||
-DDEBUG_MODE=1
|
||||
-DETVR_EYE_TRACKER_USB_API
|
||||
-DSERIAL_MANAGER_USE_HIGHER_FREQUENCY
|
||||
${pinoutsESPS3XIAOSENSE.build_flags}
|
||||
upload_flags = --no-stub
|
||||
|
||||
@ -200,6 +243,7 @@ build_type = release
|
||||
build_flags = ${env.build_flags}
|
||||
-DDEBUG_MODE=0
|
||||
-DCORE_DEBUG_LEVEL=1
|
||||
-DSERIAL_MANAGER_USE_HIGHER_FREQUENCY
|
||||
${pinoutsESPS3XIAOSENSE.build_flags}
|
||||
|
||||
[env:xiaosenses3_USB_release]
|
||||
@ -209,5 +253,6 @@ build_flags = ${env.build_flags}
|
||||
-DDEBUG_MODE=0
|
||||
-DCORE_DEBUG_LEVEL=1
|
||||
-DETVR_EYE_TRACKER_USB_API
|
||||
-DSERIAL_MANAGER_USE_HIGHER_FREQUENCY
|
||||
${pinoutsESPS3XIAOSENSE.build_flags}
|
||||
upload_flags = --no-stub
|
||||
|
@ -5,7 +5,7 @@
|
||||
platform = https://github.com/platformio/platform-espressif32.git
|
||||
framework = arduino
|
||||
monitor_speed = 115200
|
||||
custom_firmware_version = 2.4.0
|
||||
custom_firmware_version = 2.5.0
|
||||
monitor_rts = 0
|
||||
monitor_dtr = 0
|
||||
monitor_filters =
|
||||
|
@ -259,6 +259,42 @@ build_flags =
|
||||
-DHREF_GPIO_NUM=${pinoutsESPS3WROOM.HREF_GPIO_NUM}
|
||||
-DPCLK_GPIO_NUM=${pinoutsESPS3WROOM.PCLK_GPIO_NUM}
|
||||
|
||||
[pinoutSWROOMBABBLES3]
|
||||
pwdn_gpio_num = -1
|
||||
reset_gpio_num = -1
|
||||
xclk_gpio_num = 4
|
||||
siod_gpio_num = 14
|
||||
sioc_gpio_num = 13
|
||||
y9_gpio_num = 39
|
||||
y8_gpio_num = 5
|
||||
y7_gpio_num = 6
|
||||
y6_gpio_num = 15
|
||||
y5_gpio_num = 17
|
||||
y4_gpio_num = 8
|
||||
y3_gpio_num = 18
|
||||
y2_gpio_num = 16
|
||||
vsync_gpio_num = 9
|
||||
href_gpio_num = 10
|
||||
pclk_gpio_num = 7
|
||||
build_flags =
|
||||
'-DCAMERA_MODULE_NAME="SWROOM_BABBLE_S3"'
|
||||
-DPWDN_GPIO_NUM=${pinoutSWROOMBABBLES3.PWDN_GPIO_NUM}
|
||||
-DRESET_GPIO_NUM=${pinoutSWROOMBABBLES3.RESET_GPIO_NUM}
|
||||
-DXCLK_GPIO_NUM=${pinoutSWROOMBABBLES3.XCLK_GPIO_NUM}
|
||||
-DSIOD_GPIO_NUM=${pinoutSWROOMBABBLES3.SIOD_GPIO_NUM}
|
||||
-DSIOC_GPIO_NUM=${pinoutSWROOMBABBLES3.SIOC_GPIO_NUM}
|
||||
-DY9_GPIO_NUM=${pinoutSWROOMBABBLES3.Y9_GPIO_NUM}
|
||||
-DY8_GPIO_NUM=${pinoutSWROOMBABBLES3.Y8_GPIO_NUM}
|
||||
-DY7_GPIO_NUM=${pinoutSWROOMBABBLES3.Y7_GPIO_NUM}
|
||||
-DY6_GPIO_NUM=${pinoutSWROOMBABBLES3.Y6_GPIO_NUM}
|
||||
-DY5_GPIO_NUM=${pinoutSWROOMBABBLES3.Y5_GPIO_NUM}
|
||||
-DY4_GPIO_NUM=${pinoutSWROOMBABBLES3.Y4_GPIO_NUM}
|
||||
-DY3_GPIO_NUM=${pinoutSWROOMBABBLES3.Y3_GPIO_NUM}
|
||||
-DY2_GPIO_NUM=${pinoutSWROOMBABBLES3.Y2_GPIO_NUM}
|
||||
-DVSYNC_GPIO_NUM=${pinoutSWROOMBABBLES3.VSYNC_GPIO_NUM}
|
||||
-DHREF_GPIO_NUM=${pinoutSWROOMBABBLES3.HREF_GPIO_NUM}
|
||||
-DPCLK_GPIO_NUM=${pinoutSWROOMBABBLES3.PCLK_GPIO_NUM}
|
||||
|
||||
[pinoutsESPS3XIAOSENSE]
|
||||
pwdn_gpio_num = -1
|
||||
reset_gpio_num = -1
|
||||
|
@ -20,7 +20,7 @@
|
||||
"include": "/lib/src"
|
||||
},
|
||||
"dependencies": {},
|
||||
"version": "2.4.0",
|
||||
"version": "2.5.0",
|
||||
"frameworks": "arduino",
|
||||
"platforms": "espressif32"
|
||||
}
|
||||
|
@ -1,66 +1,73 @@
|
||||
#include "CommandManager.hpp"
|
||||
|
||||
CommandManager::CommandManager(ProjectConfig *deviceConfig) : deviceConfig(deviceConfig) {}
|
||||
CommandManager::CommandManager(ProjectConfig* deviceConfig)
|
||||
: deviceConfig(deviceConfig) {}
|
||||
|
||||
|
||||
const CommandType CommandManager::getCommandType(Command &command){
|
||||
if (!command.data.containsKey("command"))
|
||||
const CommandType CommandManager::getCommandType(JsonVariant& command) {
|
||||
if (!command.containsKey("command"))
|
||||
return CommandType::None;
|
||||
|
||||
if (auto search = commandMap.find(command.data["command"]); search != commandMap.end())
|
||||
if (auto search = commandMap.find(command["command"]);
|
||||
search != commandMap.end())
|
||||
return search->second;
|
||||
|
||||
return CommandType::None;
|
||||
}
|
||||
|
||||
bool CommandManager::hasHasDataField(Command &command) {
|
||||
return command.data.containsKey("data");
|
||||
bool CommandManager::hasDataField(JsonVariant& command) {
|
||||
return command.containsKey("data");
|
||||
}
|
||||
|
||||
void CommandManager::handleCommand(Command command) {
|
||||
void CommandManager::handleCommands(CommandsPayload commandsPayload) {
|
||||
if (!commandsPayload.data.containsKey("commands")) {
|
||||
log_e("Json data sent not supported, lacks commands field");
|
||||
return;
|
||||
}
|
||||
|
||||
for (JsonVariant commandData :
|
||||
commandsPayload.data["commands"].as<JsonArray>()) {
|
||||
this->handleCommand(commandData);
|
||||
}
|
||||
|
||||
this->deviceConfig->save();
|
||||
}
|
||||
|
||||
void CommandManager::handleCommand(JsonVariant command) {
|
||||
auto command_type = this->getCommandType(command);
|
||||
|
||||
switch(command_type)
|
||||
{
|
||||
switch (command_type) {
|
||||
case CommandType::SET_WIFI: {
|
||||
if (!this->hasHasDataField(command))
|
||||
if (!this->hasDataField(command))
|
||||
// malformed command, lacked data field
|
||||
break;
|
||||
|
||||
|
||||
if(!command.data["data"].containsKey("ssid") || !command.data["data"].containsKey("password"))
|
||||
if (!command["data"].containsKey("ssid") ||
|
||||
!command["data"].containsKey("password"))
|
||||
break;
|
||||
|
||||
std::string customNetworkName = "main";
|
||||
if (command.data["data"].containsKey("network_name"))
|
||||
customNetworkName = command.data["data"]["network_name"].as<std::string>();
|
||||
if (command["data"].containsKey("network_name"))
|
||||
customNetworkName = command["data"]["network_name"].as<std::string>();
|
||||
|
||||
this->deviceConfig->setWifiConfig(
|
||||
customNetworkName,
|
||||
command.data["data"]["ssid"],
|
||||
command.data["data"]["password"],
|
||||
this->deviceConfig->setWifiConfig(customNetworkName,
|
||||
command["data"]["ssid"],
|
||||
command["data"]["password"],
|
||||
0, // channel, should this be zero?
|
||||
0, // power, should this be zero?
|
||||
false,
|
||||
false
|
||||
);
|
||||
false, false);
|
||||
|
||||
// we purposefully save here
|
||||
this->deviceConfig->save();
|
||||
break;
|
||||
}
|
||||
case CommandType::SET_MDNS: {
|
||||
if (!this->hasHasDataField(command))
|
||||
if (!this->hasDataField(command))
|
||||
break;
|
||||
|
||||
if(!command.data["data"].containsKey("hostname") || !strlen(command.data["data"]["hostname"]))
|
||||
if (!command["data"].containsKey("hostname") ||
|
||||
!strlen(command["data"]["hostname"]))
|
||||
break;
|
||||
|
||||
this->deviceConfig->setMDNSConfig(
|
||||
command.data["data"]["hostname"],
|
||||
"openiristracker",
|
||||
false
|
||||
);
|
||||
this->deviceConfig->setMDNSConfig(command["data"]["hostname"],
|
||||
"openiristracker", false);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -12,13 +12,11 @@ enum CommandType {
|
||||
SET_MDNS,
|
||||
};
|
||||
|
||||
|
||||
struct Command {
|
||||
struct CommandsPayload {
|
||||
JsonDocument data;
|
||||
};
|
||||
|
||||
class CommandManager {
|
||||
|
||||
private:
|
||||
const std::unordered_map<std::string, CommandType> commandMap = {
|
||||
{"ping", CommandType::PING},
|
||||
@ -28,12 +26,13 @@ const std::unordered_map<std::string, CommandType> commandMap = {
|
||||
|
||||
ProjectConfig* deviceConfig;
|
||||
|
||||
bool hasHasDataField(Command &command);
|
||||
bool hasDataField(JsonVariant& command);
|
||||
void handleCommand(JsonVariant command);
|
||||
const CommandType getCommandType(JsonVariant& command);
|
||||
|
||||
public:
|
||||
CommandManager(ProjectConfig* deviceConfig);
|
||||
void handleCommand(Command command);
|
||||
const CommandType getCommandType(Command &command);
|
||||
void handleCommands(CommandsPayload commandsPayload);
|
||||
};
|
||||
|
||||
#endif
|
@ -5,10 +5,6 @@ SerialManager::SerialManager(CommandManager* commandManager)
|
||||
|
||||
#ifdef ETVR_EYE_TRACKER_USB_API
|
||||
void SerialManager::send_frame() {
|
||||
// if we failed to capture the frame, we bail, but we still want to listen to commands
|
||||
if (err != ESP_OK)
|
||||
return;
|
||||
|
||||
if (!last_frame)
|
||||
last_frame = esp_timer_get_time();
|
||||
|
||||
@ -21,14 +17,17 @@ void SerialManager::send_frame() {
|
||||
if (fb) {
|
||||
len = fb->len;
|
||||
buf = fb->buf;
|
||||
} else {
|
||||
log_e("Camera capture failed with response: %s", esp_err_to_name(err));
|
||||
} else
|
||||
err = ESP_FAIL;
|
||||
|
||||
// if we failed to capture the frame, we bail, but we still want to listen to
|
||||
// commands
|
||||
if (err != ESP_OK) {
|
||||
log_e("Camera capture failed with response: %s", esp_err_to_name(err));
|
||||
return;
|
||||
}
|
||||
|
||||
if (err == ESP_OK)
|
||||
Serial.write(ETVR_HEADER, 2);
|
||||
|
||||
Serial.write(ETVR_HEADER_FRAME, 2);
|
||||
len_bytes[0] = len & 0xFF;
|
||||
len_bytes[1] = (len >> CHAR_BIT) & 0xFF;
|
||||
@ -53,7 +52,9 @@ void SerialManager::send_frame() {
|
||||
#endif
|
||||
|
||||
void SerialManager::init() {
|
||||
#ifndef SERIAL_MANAGER_USE_HIGHER_FREQUENCY
|
||||
Serial.begin(3000000);
|
||||
#endif
|
||||
if (SERIAL_FLUSH_ENABLED) {
|
||||
Serial.flush();
|
||||
}
|
||||
@ -65,12 +66,13 @@ void SerialManager::run() {
|
||||
DeserializationError deserializationError = deserializeJson(doc, Serial);
|
||||
|
||||
if (deserializationError) {
|
||||
log_e("Command deserialization failed: %s",
|
||||
deserializationError.c_str());
|
||||
log_e("Command deserialization failed: %s", deserializationError.c_str());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Command command = {doc};
|
||||
this->commandManager->handleCommand(command);
|
||||
CommandsPayload commands = {doc};
|
||||
this->commandManager->handleCommands(commands);
|
||||
}
|
||||
#ifdef ETVR_EYE_TRACKER_USB_API
|
||||
else {
|
||||
|
@ -12,6 +12,24 @@
|
||||
const char* const ETVR_HEADER = "\xff\xa0";
|
||||
const char* const ETVR_HEADER_FRAME = "\xff\xa1";
|
||||
|
||||
enum QueryAction {
|
||||
READY_TO_RECEIVE,
|
||||
PARSE_COMMANDS,
|
||||
CONNECT_TO_WIFI,
|
||||
};
|
||||
|
||||
enum QueryStatus {
|
||||
NONE,
|
||||
SUCCESS,
|
||||
ERROR,
|
||||
};
|
||||
|
||||
const std::unordered_map<QueryAction, std::string> queryActionMap = {
|
||||
{QueryAction::READY_TO_RECEIVE, "ready_to_receive"},
|
||||
{QueryAction::PARSE_COMMANDS, "parse_commands"},
|
||||
{QueryAction::CONNECT_TO_WIFI, "connect_to_wifi"},
|
||||
};
|
||||
|
||||
class SerialManager {
|
||||
private:
|
||||
esp_err_t err = ESP_OK;
|
||||
@ -26,6 +44,9 @@ class SerialManager {
|
||||
|
||||
public:
|
||||
SerialManager(CommandManager* commandManager);
|
||||
void sendQuery(QueryAction action,
|
||||
QueryStatus status,
|
||||
std::string additional_info);
|
||||
void init();
|
||||
void run();
|
||||
};
|
||||
|
@ -16,7 +16,7 @@ void CameraHandler::setupCameraPinout() {
|
||||
// 16500000 optimal freq on ESP32-CAM (default)
|
||||
// 20000000 max freq on ESP32-CAM
|
||||
// 24000000 optimal freq on ESP32-S3
|
||||
int xclk_freq_hz = 16500000;
|
||||
int xclk_freq_hz = DEFAULT_XCLK_FREQ_HZ;
|
||||
|
||||
#if CONFIG_CAMERA_MODULE_ESP_EYE
|
||||
/* IO13, IO14 is designed for JTAG by default,
|
||||
@ -36,8 +36,7 @@ void CameraHandler::setupCameraPinout() {
|
||||
log_i("CAM_BOARD");
|
||||
#endif
|
||||
#if ETVR_EYE_TRACKER_USB_API
|
||||
/* ESP32-S3 is capable of using higher freqs */
|
||||
xclk_freq_hz = 24000000;
|
||||
xclk_freq_hz = USB_DEFAULT_XCLK_FREQ_HZ;
|
||||
#endif
|
||||
|
||||
config.ledc_channel = LEDC_CHANNEL_0;
|
||||
@ -164,6 +163,23 @@ bool CameraHandler::setupCamera() {
|
||||
return false;
|
||||
}
|
||||
|
||||
#if ETVR_EYE_TRACKER_USB_API
|
||||
auto temp_sensor = esp_camera_sensor_get();
|
||||
auto camera_id = temp_sensor->id.PID;
|
||||
switch (camera_id) {
|
||||
// Thanks to lick_it, we discovered that OV5640 likes to overheat when
|
||||
// running at higher than usual xclk frequencies.
|
||||
// Hence why we're limit the faster ones for OV2640
|
||||
case OV5640_PID:
|
||||
config.xclk_freq_hz = OV5640_XCLK_FREQ_HZ;
|
||||
esp_camera_deinit();
|
||||
esp_camera_init(&config);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
this->setupCameraSensor();
|
||||
return true;
|
||||
}
|
||||
|
@ -1,10 +1,14 @@
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
#include <esp_camera.h>
|
||||
#include "data/StateManager/StateManager.hpp"
|
||||
#include "data/config/project_config.hpp"
|
||||
#include "data/utilities/Observer.hpp"
|
||||
#include "data/utilities/network_utilities.hpp"
|
||||
#include "data/config/project_config.hpp"
|
||||
#include "data/StateManager/StateManager.hpp"
|
||||
|
||||
#define DEFAULT_XCLK_FREQ_HZ 16500000
|
||||
#define USB_DEFAULT_XCLK_FREQ_HZ 24000000
|
||||
#define OV5640_XCLK_FREQ_HZ DEFAULT_XCLK_FREQ_HZ
|
||||
|
||||
class CameraHandler : public IObserver<ConfigState_e> {
|
||||
private:
|
||||
|
@ -18,6 +18,13 @@ WiFiHandler::WiFiHandler(ProjectConfig& configManager,
|
||||
WiFiHandler::~WiFiHandler() {}
|
||||
|
||||
void WiFiHandler::begin() {
|
||||
|
||||
// just to be sure, we reeset everything before we do anything, some boards were having problems otherwise
|
||||
WiFi.disconnect();
|
||||
// we purposefully set the lowest min required security level, some boards have problems connecting otherwise
|
||||
// https://github.com/espressif/arduino-esp32/issues/8770
|
||||
WiFi.setMinSecurity(WIFI_AUTH_WEP);
|
||||
|
||||
log_i("Starting WiFi Handler \n\r");
|
||||
if (this->_enable_adhoc ||
|
||||
wifiStateManager.getCurrentState() == WiFiState_e::WiFiState_ADHOC) {
|
||||
@ -40,8 +47,6 @@ void WiFiHandler::begin() {
|
||||
if (networks.empty()) {
|
||||
log_i("No networks found in config, trying the default one \n\r");
|
||||
|
||||
// since networks may not have a password, we only need to check if we have an ssid
|
||||
// bail if we don't
|
||||
if (this->iniSTA(
|
||||
this->ssid,
|
||||
this->password,
|
||||
@ -135,6 +140,8 @@ bool WiFiHandler::iniSTA(const std::string& ssid,
|
||||
uint8_t channel,
|
||||
wifi_power_t power) {
|
||||
|
||||
// since networks may not have a password, we only need to check if we have an ssid
|
||||
// bail if we don't
|
||||
if (ssid == ""){
|
||||
log_d("ssid missing, bailing");
|
||||
return false;
|
||||
@ -148,13 +155,14 @@ bool WiFiHandler::iniSTA(const std::string& ssid,
|
||||
wifiStateManager.setState(WiFiState_e::WiFiState_Connecting);
|
||||
log_i("Trying to connect to: %s \n\r", ssid.c_str());
|
||||
auto mdnsConfig = configManager.getMDNSConfig();
|
||||
|
||||
log_d("Setting hostname %s \n\r");
|
||||
WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE,
|
||||
INADDR_NONE); // need to call before setting hostname
|
||||
log_d("Setting hostname %s \n\r");
|
||||
WiFi.setHostname(mdnsConfig.hostname.c_str());
|
||||
log_i("Setting TX power to: %d \n\r", (uint8_t)power);
|
||||
WiFi.setTxPower(power); // https://github.com/espressif/arduino-esp32/issues/5698
|
||||
WiFi.begin(ssid.c_str(), password.c_str(), channel);
|
||||
WiFi.setTxPower(power);
|
||||
|
||||
log_d("Waiting for WiFi to connect... \n\r");
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
progress++;
|
||||
@ -169,7 +177,6 @@ bool WiFiHandler::iniSTA(const std::string& ssid,
|
||||
}
|
||||
wifiStateManager.setState(WiFiState_e::WiFiState_Connected);
|
||||
log_i("Successfully connected to %s \n\r", ssid.c_str());
|
||||
log_i("Setting TX power to: %d \n\r", (uint8_t)power);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -3,20 +3,18 @@
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include <data/CommandManager/CommandManager.hpp>
|
||||
#include <data/config/project_config.hpp>
|
||||
#include <io/LEDManager/LEDManager.hpp>
|
||||
#include <io/Serial/SerialManager.hpp>
|
||||
#include <io/camera/cameraHandler.hpp>
|
||||
#include <logo/logo.hpp>
|
||||
#include <io/Serial/SerialManager.hpp>
|
||||
#include <data/CommandManager/CommandManager.hpp>
|
||||
|
||||
#ifndef ETVR_EYE_TRACKER_USB_API
|
||||
#include <network/api/webserverHandler.hpp>
|
||||
#include <network/mDNS/MDNSManager.hpp>
|
||||
#include <network/stream/streamServer.hpp>
|
||||
#include <network/wifihandler/wifihandler.hpp>
|
||||
#else
|
||||
#include <usb/etvr_eye_tracker_usb.hpp>
|
||||
#endif // ETVR_EYE_TRACKER_WEB_API
|
||||
|
||||
#endif // OPENIRIS_HPP
|
||||
|
@ -1,61 +0,0 @@
|
||||
#include "etvr_eye_tracker_usb.hpp"
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <USBCDC.h>
|
||||
#include <esp_camera.h>
|
||||
|
||||
const char* const ETVR_HEADER = "\xff\xa0";
|
||||
const char* const ETVR_HEADER_FRAME = "\xff\xa1";
|
||||
|
||||
void etvr_eye_tracker_usb_init() {
|
||||
Serial.begin(3000000);
|
||||
Serial.flush();
|
||||
}
|
||||
|
||||
void etvr_eye_tracker_usb_loop() {
|
||||
int64_t last_frame = 0;
|
||||
if (!last_frame)
|
||||
last_frame = esp_timer_get_time();
|
||||
|
||||
long last_request_time = 0;
|
||||
camera_fb_t* fb = NULL;
|
||||
esp_err_t err = ESP_OK;
|
||||
|
||||
size_t len = 0;
|
||||
uint8_t* buf = NULL;
|
||||
|
||||
uint8_t len_bytes[2];
|
||||
|
||||
while (true) {
|
||||
fb = esp_camera_fb_get();
|
||||
if (fb) {
|
||||
len = fb->len;
|
||||
buf = fb->buf;
|
||||
} else {
|
||||
log_e("Camera capture failed with response: %s", esp_err_to_name(err));
|
||||
err = ESP_FAIL;
|
||||
}
|
||||
if (err == ESP_OK)
|
||||
Serial.write(ETVR_HEADER, 2);
|
||||
Serial.write(ETVR_HEADER_FRAME, 2);
|
||||
len_bytes[0] = len & 0xFF;
|
||||
len_bytes[1] = (len >> CHAR_BIT) & 0xFF;
|
||||
Serial.write(len_bytes, 2);
|
||||
Serial.write((const char*)buf, len);
|
||||
if (fb) {
|
||||
esp_camera_fb_return(fb);
|
||||
fb = NULL;
|
||||
buf = NULL;
|
||||
} else if (buf) {
|
||||
free(buf);
|
||||
buf = NULL;
|
||||
}
|
||||
if (err != ESP_OK)
|
||||
break;
|
||||
long request_end = millis();
|
||||
long latency = request_end - last_request_time;
|
||||
last_request_time = request_end;
|
||||
log_d("Size: %uKB, Time: %ums (%ifps)\n", len / 1024, latency,
|
||||
1000 / latency);
|
||||
}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
#ifndef INCLUDED_ETVR_EYE_TRACKER_USB_HPP
|
||||
#define INCLUDED_ETVR_EYE_TRACKER_USB_HPP
|
||||
|
||||
void etvr_eye_tracker_usb_init();
|
||||
void etvr_eye_tracker_usb_loop();
|
||||
|
||||
#endif // INCLUDED_ETVR_EYE_TRACKER_USB_HPP
|
@ -20,7 +20,11 @@ CameraHandler cameraHandler(deviceConfig);
|
||||
#endif // SIM_ENABLED
|
||||
|
||||
#ifndef ETVR_EYE_TRACKER_USB_API
|
||||
WiFiHandler wifiHandler(deviceConfig, WIFI_SSID, WIFI_PASSWORD, WIFI_CHANNEL, ENABLE_ADHOC);
|
||||
WiFiHandler wifiHandler(deviceConfig,
|
||||
WIFI_SSID,
|
||||
WIFI_PASSWORD,
|
||||
WIFI_CHANNEL,
|
||||
ENABLE_ADHOC);
|
||||
MDNSHandler mdnsHandler(deviceConfig);
|
||||
#ifdef SIM_ENABLED
|
||||
APIServer apiServer(deviceConfig, wifiStateManager, "/control");
|
||||
|
Loading…
Reference in New Issue
Block a user