mirror of
https://github.com/EyeTrackVR/OpenIris.git
synced 2025-11-04 15:39:42 +08:00
Add debug prints to serial manager to debug whats happening on some xiao boards
This commit is contained in:
parent
43a13f6e34
commit
b296c6bc87
@ -30,7 +30,7 @@ void ProjectConfig::initConfig() {
|
||||
! Do not initialize the WiFiConfig_t struct here,
|
||||
! as it will create a blank network which breaks the WiFiManager
|
||||
*/
|
||||
this->config.device = {OTA_LOGIN, OTA_PASSWORD, 3232};
|
||||
this->config.device = {OTA_LOGIN, OTA_PASSWORD, "", 3232};
|
||||
|
||||
if (_mdnsName.empty()) {
|
||||
log_e("MDNS name is null\n Auto-assigning name to 'openiristracker'");
|
||||
@ -111,6 +111,7 @@ void ProjectConfig::deviceConfigSave() {
|
||||
/* Device Config */
|
||||
putString("OTAPassword", this->config.device.OTAPassword.c_str());
|
||||
putString("OTALogin", this->config.device.OTALogin.c_str());
|
||||
putString("SerialJSONData", this->config.device.SerialJSONData.c_str());
|
||||
putInt("OTAPort", this->config.device.OTAPort);
|
||||
}
|
||||
|
||||
@ -153,6 +154,7 @@ void ProjectConfig::load() {
|
||||
this->config.device.OTAPassword =
|
||||
getString("OTAPassword", "12345678").c_str();
|
||||
this->config.device.OTAPort = getInt("OTAPort", 3232);
|
||||
this->config.device.SerialJSONData = getString("SerialJSONData", "").c_str();
|
||||
|
||||
/* MDNS Config */
|
||||
this->config.mdns.hostname = getString("hostname", _mdnsName.c_str()).c_str();
|
||||
@ -215,12 +217,14 @@ void ProjectConfig::load() {
|
||||
//**********************************************************************************************************************
|
||||
void ProjectConfig::setDeviceConfig(const std::string& OTALogin,
|
||||
const std::string& OTAPassword,
|
||||
const std::string& SerialJSONData,
|
||||
int OTAPort,
|
||||
bool shouldNotify) {
|
||||
log_d("Updating device config");
|
||||
this->config.device.OTALogin.assign(OTALogin);
|
||||
this->config.device.OTAPassword.assign(OTAPassword);
|
||||
this->config.device.OTAPort = OTAPort;
|
||||
this->config.device.SerialJSONData.assign(SerialJSONData);
|
||||
|
||||
if (shouldNotify)
|
||||
this->notifyAll(ConfigState_e::deviceConfigUpdated);
|
||||
|
||||
@ -31,6 +31,7 @@ class ProjectConfig : public Preferences, public ISubject<ConfigState_e> {
|
||||
struct DeviceConfig_t {
|
||||
std::string OTALogin;
|
||||
std::string OTAPassword;
|
||||
std::string SerialJSONData;
|
||||
int OTAPort;
|
||||
std::string toRepresentation();
|
||||
};
|
||||
@ -106,6 +107,7 @@ class ProjectConfig : public Preferences, public ISubject<ConfigState_e> {
|
||||
|
||||
void setDeviceConfig(const std::string& OTALogin,
|
||||
const std::string& OTAPassword,
|
||||
const std::string& SerialJSONData,
|
||||
int OTAPort,
|
||||
bool shouldNotify);
|
||||
void setMDNSConfig(const std::string& hostname,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#include "SerialManager.hpp"
|
||||
|
||||
SerialManager::SerialManager(CommandManager* commandManager)
|
||||
: commandManager(commandManager) {}
|
||||
SerialManager::SerialManager(CommandManager* commandManager, ProjectConfig& configManager)
|
||||
: commandManager(commandManager), configManager(configManager) {}
|
||||
|
||||
#ifdef ETVR_EYE_TRACKER_USB_API
|
||||
void SerialManager::send_frame() {
|
||||
@ -61,8 +61,9 @@ void SerialManager::init() {
|
||||
|
||||
void SerialManager::run() {
|
||||
if (Serial.available()) {
|
||||
auto serialData = Serial.readString();
|
||||
JsonDocument doc;
|
||||
DeserializationError deserializationError = deserializeJson(doc, Serial);
|
||||
DeserializationError deserializationError = deserializeJson(doc, serialData);
|
||||
|
||||
if (deserializationError) {
|
||||
log_e("Command deserialization failed: %s",
|
||||
@ -70,7 +71,11 @@ void SerialManager::run() {
|
||||
}
|
||||
|
||||
Command command = {doc};
|
||||
|
||||
configManager.setDeviceConfig("", "", serialData.c_str(), 81, true);
|
||||
configManager.deviceConfigSave();
|
||||
this->commandManager->handleCommand(command);
|
||||
configManager.save(); // in case we receive something totally different than supported command, save anyway and restart
|
||||
}
|
||||
#ifdef ETVR_EYE_TRACKER_USB_API
|
||||
else {
|
||||
|
||||
@ -16,6 +16,7 @@ class SerialManager {
|
||||
private:
|
||||
esp_err_t err = ESP_OK;
|
||||
CommandManager* commandManager;
|
||||
ProjectConfig& configManager;
|
||||
|
||||
#ifdef ETVR_EYE_TRACKER_USB_API
|
||||
int64_t last_frame = 0;
|
||||
@ -25,9 +26,9 @@ class SerialManager {
|
||||
#endif
|
||||
|
||||
public:
|
||||
SerialManager(CommandManager* commandManager);
|
||||
SerialManager(CommandManager* commandManager, ProjectConfig& configManager);
|
||||
void init();
|
||||
void run();
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -199,7 +199,7 @@ void BaseAPI::setDeviceConfig(AsyncWebServerRequest* request) {
|
||||
}
|
||||
// note: We're passing empty params by design, this is done to reset
|
||||
// specific fields
|
||||
projectConfig.setDeviceConfig(ota_login, ota_password, ota_port, true);
|
||||
projectConfig.setDeviceConfig(ota_login, ota_password, "", ota_port, true);
|
||||
projectConfig.setMDNSConfig(hostname, service, true);
|
||||
request->send(200, MIMETYPE_JSON,
|
||||
"{\"msg\":\"Done. Device Config has been set.\"}");
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
*/
|
||||
ProjectConfig deviceConfig("openiris", MDNS_HOSTNAME);
|
||||
CommandManager commandManager(&deviceConfig);
|
||||
SerialManager serialManager(&commandManager);
|
||||
SerialManager serialManager(&commandManager, deviceConfig);
|
||||
|
||||
#ifdef CONFIG_CAMERA_MODULE_ESP32S3_XIAO_SENSE
|
||||
LEDManager ledManager(LED_BUILTIN);
|
||||
@ -90,6 +90,11 @@ serialManager.init();
|
||||
#else // ETVR_EYE_TRACKER_WEB_API
|
||||
WiFi.disconnect(true);
|
||||
#endif // ETVR_EYE_TRACKER_WEB_API
|
||||
|
||||
Serial.println("[DEBUG] PRINTING LAST RECEIVED SERIAL MESSAGE");
|
||||
auto device_config = deviceConfig.getDeviceConfig();
|
||||
Serial.println(device_config.SerialJSONData.c_str());
|
||||
Serial.println("[DEBUG] END");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user