mirror of
https://github.com/EyeTrackVR/OpenIris.git
synced 2025-11-04 15:39:42 +08:00
Remove OpenIris namespace - code cleanup
This commit is contained in:
parent
cdb89b8444
commit
62df54295f
@ -9,8 +9,8 @@ extern char *MDSNTrackerName;
|
|||||||
extern int STREAM_SERVER_PORT;
|
extern int STREAM_SERVER_PORT;
|
||||||
extern int CONTROL_SERVER_PORT;
|
extern int CONTROL_SERVER_PORT;
|
||||||
|
|
||||||
extern OpenIris::LEDManager ledManager;
|
extern LEDManager ledManager;
|
||||||
extern OpenIris::StateManager stateManager;
|
extern StateManager stateManager;
|
||||||
extern OpenIris::CameraHandler cameraHandler;
|
extern CameraHandler cameraHandler;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -1,21 +1,17 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
namespace OpenIris
|
class LEDManager
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
uint8_t ledPin;
|
||||||
|
|
||||||
class LEDManager
|
public:
|
||||||
{
|
explicit LEDManager(uint8_t pin) : ledPin(pin) {}
|
||||||
private:
|
|
||||||
uint8_t ledPin;
|
|
||||||
|
|
||||||
public:
|
void setupLED() const;
|
||||||
explicit LEDManager(uint8_t pin) : ledPin(pin) {}
|
void on() const;
|
||||||
|
void off() const;
|
||||||
void setupLED() const;
|
void blink(unsigned int time);
|
||||||
void on() const;
|
void displayStatus();
|
||||||
void off() const;
|
};
|
||||||
void blink(unsigned int time);
|
|
||||||
void displayStatus();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,10 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <ESPmDNS.h>
|
#include <ESPmDNS.h>
|
||||||
|
|
||||||
namespace OpenIris
|
namespace MDNSHandler
|
||||||
{
|
{
|
||||||
namespace MDNSHandler
|
void setupMDNS();
|
||||||
{
|
}
|
||||||
void setupMDNS();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,57 +1,54 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <ArduinoOTA.h>
|
#include <ArduinoOTA.h>
|
||||||
|
|
||||||
namespace OpenIris
|
class OTA
|
||||||
{
|
{
|
||||||
class OTA
|
private:
|
||||||
|
bool isOTAEnabled = false;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void SetupOTA(const char *OTAPassword, uint16_t OTAServerPort)
|
||||||
{
|
{
|
||||||
private:
|
log_i("Setting up OTA updates");
|
||||||
bool isOTAEnabled = false;
|
|
||||||
|
|
||||||
public:
|
if (OTAPassword == nullptr)
|
||||||
void SetupOTA(const char *OTAPassword, uint16_t OTAServerPort)
|
|
||||||
{
|
{
|
||||||
log_i("Setting up OTA updates");
|
log_e("THE PASSWORD IS REQUIRED, [[ABORTING]]");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ArduinoOTA.setPort(OTAServerPort);
|
||||||
|
isOTAEnabled = true;
|
||||||
|
|
||||||
if (OTAPassword == nullptr)
|
ArduinoOTA
|
||||||
{
|
.onStart([]()
|
||||||
log_e("THE PASSWORD IS REQUIRED, [[ABORTING]]");
|
{
|
||||||
return;
|
|
||||||
}
|
|
||||||
ArduinoOTA.setPort(OTAServerPort);
|
|
||||||
isOTAEnabled = true;
|
|
||||||
|
|
||||||
ArduinoOTA
|
|
||||||
.onStart([]()
|
|
||||||
{
|
|
||||||
String type;
|
String type;
|
||||||
if (ArduinoOTA.getCommand() == U_FLASH)
|
if (ArduinoOTA.getCommand() == U_FLASH)
|
||||||
type = "sketch";
|
type = "sketch";
|
||||||
else // U_SPIFFS
|
else // U_SPIFFS
|
||||||
type = "filesystem"; })
|
type = "filesystem"; })
|
||||||
.onEnd([]()
|
.onEnd([]()
|
||||||
{ log_i("OTA updated finished successfully!"); })
|
{ log_i("OTA updated finished successfully!"); })
|
||||||
.onProgress([](unsigned int progress, unsigned int total)
|
.onProgress([](unsigned int progress, unsigned int total)
|
||||||
{ log_i("Progress: %u%%\r", (progress / (total / 100))); })
|
{ log_i("Progress: %u%%\r", (progress / (total / 100))); })
|
||||||
.onError([](ota_error_t error)
|
.onError([](ota_error_t error)
|
||||||
{
|
{
|
||||||
log_e("Error[%u]: ", error);
|
log_e("Error[%u]: ", error);
|
||||||
if (error == OTA_AUTH_ERROR) log_e("Auth Failed");
|
if (error == OTA_AUTH_ERROR) log_e("Auth Failed");
|
||||||
else if (error == OTA_BEGIN_ERROR) log_e("Begin Failed");
|
else if (error == OTA_BEGIN_ERROR) log_e("Begin Failed");
|
||||||
else if (error == OTA_CONNECT_ERROR) log_e("Connect Failed");
|
else if (error == OTA_CONNECT_ERROR) log_e("Connect Failed");
|
||||||
else if (error == OTA_RECEIVE_ERROR) log_e("Receive Failed");
|
else if (error == OTA_RECEIVE_ERROR) log_e("Receive Failed");
|
||||||
else if (error == OTA_END_ERROR) log_e("End Failed"); });
|
else if (error == OTA_END_ERROR) log_e("End Failed"); });
|
||||||
log_i("Starting up basic OTA server");
|
log_i("Starting up basic OTA server");
|
||||||
log_i("OTA will be live for 30s, after which it will be disabled until restart");
|
log_i("OTA will be live for 30s, after which it will be disabled until restart");
|
||||||
ArduinoOTA.begin();
|
ArduinoOTA.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleOTAUpdate()
|
void HandleOTAUpdate()
|
||||||
|
{
|
||||||
|
if (isOTAEnabled)
|
||||||
{
|
{
|
||||||
if (isOTAEnabled)
|
ArduinoOTA.handle();
|
||||||
{
|
|
||||||
ArduinoOTA.handle();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
};
|
||||||
|
|||||||
@ -1,28 +1,24 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace OpenIris
|
enum State
|
||||||
{
|
{
|
||||||
enum State
|
Starting = 1,
|
||||||
{
|
ConnectingToWifi = 2,
|
||||||
Starting = 1,
|
ConnectingToWifiError = 3,
|
||||||
ConnectingToWifi = 2,
|
ConnectingToWifiSuccess = 4,
|
||||||
ConnectingToWifiError = 3,
|
ServerError = 5,
|
||||||
ConnectingToWifiSuccess = 4,
|
CameraError = 6,
|
||||||
ServerError = 5,
|
MDNSSuccess = 7,
|
||||||
CameraError = 6,
|
MDNSError = 8,
|
||||||
MDNSSuccess = 7,
|
};
|
||||||
MDNSError = 8,
|
|
||||||
};
|
|
||||||
|
|
||||||
class StateManager
|
class StateManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
StateManager() : current_state(Starting) {}
|
StateManager() : current_state(Starting) {}
|
||||||
void setState(State state);
|
void setState(State state);
|
||||||
State getCurrentState();
|
State getCurrentState();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
State current_state;
|
State current_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@ -2,10 +2,7 @@
|
|||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include "pinout.h"
|
#include "pinout.h"
|
||||||
|
|
||||||
namespace OpenIris
|
namespace WiFiHandler
|
||||||
{
|
{
|
||||||
namespace WiFiHandler
|
void setupWifi(const char *ssid, const char *password);
|
||||||
{
|
}
|
||||||
void setupWifi(const char *ssid, const char *password);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -3,19 +3,16 @@
|
|||||||
#include "esp_camera.h"
|
#include "esp_camera.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
namespace OpenIris
|
class CameraHandler
|
||||||
{
|
{
|
||||||
class CameraHandler
|
private:
|
||||||
{
|
sensor_t *camera_sensor;
|
||||||
private:
|
camera_config_t config;
|
||||||
sensor_t *camera_sensor;
|
|
||||||
camera_config_t config;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int setupCamera();
|
int setupCamera();
|
||||||
int setCameraResolution(framesize_t frameSize);
|
int setCameraResolution(framesize_t frameSize);
|
||||||
int setVFlip(int direction);
|
int setVFlip(int direction);
|
||||||
int setHFlip(int direction);
|
int setHFlip(int direction);
|
||||||
int setVieWindow(int offsetX, int offsetY, int outputX, int outputY);
|
int setVieWindow(int offsetX, int offsetY, int outputX, int outputY);
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|||||||
@ -4,19 +4,16 @@
|
|||||||
#include "esp_camera.h"
|
#include "esp_camera.h"
|
||||||
#include "esp_http_server.h"
|
#include "esp_http_server.h"
|
||||||
|
|
||||||
namespace OpenIris
|
namespace StreamHelpers
|
||||||
|
{
|
||||||
|
esp_err_t stream(httpd_req_t *req);
|
||||||
|
}
|
||||||
|
class StreamServer
|
||||||
{
|
{
|
||||||
namespace StreamHelpers
|
|
||||||
{
|
|
||||||
esp_err_t stream(httpd_req_t *req);
|
|
||||||
}
|
|
||||||
class StreamServer
|
|
||||||
{
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
httpd_handle_t camera_stream = nullptr;
|
httpd_handle_t camera_stream = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int startStreamServer();
|
int startStreamServer();
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|||||||
@ -6,16 +6,13 @@
|
|||||||
#include <AsyncTCP.h>
|
#include <AsyncTCP.h>
|
||||||
#include <ESPAsyncWebServer.h>
|
#include <ESPAsyncWebServer.h>
|
||||||
|
|
||||||
namespace OpenIris
|
class APIServer
|
||||||
{
|
{
|
||||||
class APIServer
|
private:
|
||||||
{
|
void command_handler(AsyncWebServerRequest *request);
|
||||||
private:
|
AsyncWebServer *server;
|
||||||
void command_handler(AsyncWebServerRequest *request);
|
|
||||||
AsyncWebServer *server;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
APIServer();
|
APIServer();
|
||||||
void startAPIServer();
|
void startAPIServer();
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|||||||
@ -1,27 +1,27 @@
|
|||||||
#include "LEDManager.h"
|
#include "LEDManager.h"
|
||||||
|
|
||||||
void OpenIris::LEDManager::setupLED() const
|
void LEDManager::setupLED() const
|
||||||
{
|
{
|
||||||
pinMode(ledPin, OUTPUT);
|
pinMode(ledPin, OUTPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenIris::LEDManager::on() const
|
void LEDManager::on() const
|
||||||
{
|
{
|
||||||
digitalWrite(ledPin, LOW);
|
digitalWrite(ledPin, LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenIris::LEDManager::off() const
|
void LEDManager::off() const
|
||||||
{
|
{
|
||||||
digitalWrite(ledPin, HIGH);
|
digitalWrite(ledPin, HIGH);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenIris::LEDManager::blink(unsigned int time)
|
void LEDManager::blink(unsigned int time)
|
||||||
{
|
{
|
||||||
on();
|
on();
|
||||||
delay(time);
|
delay(time);
|
||||||
off();
|
off();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenIris::LEDManager::displayStatus()
|
void LEDManager::displayStatus()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +1,18 @@
|
|||||||
#include "MDNSManager.h"
|
#include "MDNSManager.h"
|
||||||
#include "GlobalVars.h"
|
#include "GlobalVars.h"
|
||||||
|
|
||||||
void OpenIris::MDNSHandler::setupMDNS()
|
void MDNSHandler::setupMDNS()
|
||||||
{
|
{
|
||||||
if (MDNS.begin(MDSNTrackerName))
|
if (MDNS.begin(MDSNTrackerName))
|
||||||
{
|
{
|
||||||
stateManager.setState(OpenIris::State::MDNSSuccess);
|
stateManager.setState(State::MDNSSuccess); // todo make it a separate state from the global one
|
||||||
MDNS.addService("openIrisTracker", "tcp", 80);
|
MDNS.addService("openIrisTracker", "tcp", 80);
|
||||||
MDNS.addServiceTxt("openIrisTracker", "tcp", "stream_port", String(80));
|
MDNS.addServiceTxt("openIrisTracker", "tcp", "stream_port", String(80));
|
||||||
log_d("MDNS initialized!");
|
log_d("MDNS initialized!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stateManager.setState(OpenIris::State::MDNSError);
|
stateManager.setState(State::MDNSError);
|
||||||
log_e("Error initializing MDNS");
|
log_e("Error initializing MDNS");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,14 +1,11 @@
|
|||||||
#include "StateManager.h"
|
#include "StateManager.h"
|
||||||
|
|
||||||
namespace OpenIris
|
void StateManager::setState(State state)
|
||||||
{
|
{
|
||||||
void StateManager::setState(State state)
|
current_state = state;
|
||||||
{
|
}
|
||||||
current_state = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
State StateManager::getCurrentState()
|
State StateManager::getCurrentState()
|
||||||
{
|
{
|
||||||
return current_state;
|
return current_state;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
#include "cameraHandler.h"
|
#include "cameraHandler.h"
|
||||||
|
|
||||||
int OpenIris::CameraHandler::setupCamera()
|
int CameraHandler::setupCamera()
|
||||||
{
|
{
|
||||||
log_d("Setting up camera \r\n");
|
log_d("Setting up camera \r\n");
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ int OpenIris::CameraHandler::setupCamera()
|
|||||||
{
|
{
|
||||||
log_d("Found psram, setting the 240x240 image quality");
|
log_d("Found psram, setting the 240x240 image quality");
|
||||||
config.frame_size = FRAMESIZE_240X240;
|
config.frame_size = FRAMESIZE_240X240;
|
||||||
config.jpeg_quality = 7; // 0-63 lower number = higher quality, more latency and less fps 7 for most fps, 5 for best quality
|
config.jpeg_quality = 7; // 0-63 lower number = higher quality, more latency and less fps 7 for most fps, 5 for best quality
|
||||||
config.fb_count = 3;
|
config.fb_count = 3;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -47,9 +47,9 @@ int OpenIris::CameraHandler::setupCamera()
|
|||||||
camera_sensor = esp_camera_sensor_get();
|
camera_sensor = esp_camera_sensor_get();
|
||||||
// fixes corrupted jpegs, https://github.com/espressif/esp32-camera/issues/203
|
// fixes corrupted jpegs, https://github.com/espressif/esp32-camera/issues/203
|
||||||
camera_sensor->set_reg(camera_sensor, 0xff, 0xff, 0x00); // banksel
|
camera_sensor->set_reg(camera_sensor, 0xff, 0xff, 0x00); // banksel
|
||||||
camera_sensor->set_reg(camera_sensor, 0xd3, 0xff, 5); // clock
|
camera_sensor->set_reg(camera_sensor, 0xd3, 0xff, 5); // clock
|
||||||
camera_sensor->set_brightness(camera_sensor, 2); // -2 to 2 I see no difference between numbers..
|
camera_sensor->set_brightness(camera_sensor, 2); // -2 to 2 I see no difference between numbers..
|
||||||
camera_sensor->set_contrast(camera_sensor, 2); // -2 to 2
|
camera_sensor->set_contrast(camera_sensor, 2); // -2 to 2
|
||||||
camera_sensor->set_saturation(camera_sensor, -2); // -2 to 2
|
camera_sensor->set_saturation(camera_sensor, -2); // -2 to 2
|
||||||
camera_sensor->set_whitebal(camera_sensor, 1); // 0 = disable , 1 = enable
|
camera_sensor->set_whitebal(camera_sensor, 1); // 0 = disable , 1 = enable
|
||||||
camera_sensor->set_awb_gain(camera_sensor, 1); // 0 = disable , 1 = enable
|
camera_sensor->set_awb_gain(camera_sensor, 1); // 0 = disable , 1 = enable
|
||||||
@ -81,7 +81,7 @@ int OpenIris::CameraHandler::setupCamera()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int OpenIris::CameraHandler::setCameraResolution(framesize_t frameSize)
|
int CameraHandler::setCameraResolution(framesize_t frameSize)
|
||||||
{
|
{
|
||||||
if (camera_sensor->pixformat == PIXFORMAT_JPEG)
|
if (camera_sensor->pixformat == PIXFORMAT_JPEG)
|
||||||
{
|
{
|
||||||
@ -98,23 +98,12 @@ int OpenIris::CameraHandler::setCameraResolution(framesize_t frameSize)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int OpenIris::CameraHandler::setVFlip(int direction)
|
int CameraHandler::setVFlip(int direction)
|
||||||
{
|
{
|
||||||
return camera_sensor->set_vflip(camera_sensor, direction);
|
return camera_sensor->set_vflip(camera_sensor, direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
int OpenIris::CameraHandler::setHFlip(int direction)
|
int CameraHandler::setHFlip(int direction)
|
||||||
{
|
{
|
||||||
return camera_sensor->set_hmirror(camera_sensor, direction);
|
return camera_sensor->set_hmirror(camera_sensor, direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
int OpenIris::CameraHandler::setVieWindow(int offsetX, int offsetY, int outputX, int outputY)
|
|
||||||
{
|
|
||||||
// we're only providing these parameters as these are the only ones that actually affect the ov2640
|
|
||||||
// TODO: if we're going to support different sensors - this will have to be moved to per-sensor implementation 'cause
|
|
||||||
// TODO: manufacturers handle it differently each time
|
|
||||||
|
|
||||||
// we're doubling the totalX and totalY parameters to make it easier for end user to adjust the eye ROI
|
|
||||||
// it also seems to produce a cleaner image
|
|
||||||
return camera_sensor->set_res_raw(camera_sensor, 0, 0, 0, 0, offsetX, offsetY, outputX * 2, outputY * 2, outputX, outputY, true, true);
|
|
||||||
}
|
|
||||||
@ -16,12 +16,12 @@ const char *MDSNTrackerName = "OpenIrisTracker";
|
|||||||
int STREAM_SERVER_PORT = 80;
|
int STREAM_SERVER_PORT = 80;
|
||||||
int CONTROL_SERVER_PORT = 81;
|
int CONTROL_SERVER_PORT = 81;
|
||||||
|
|
||||||
auto ota = OpenIris::OTA();
|
auto ota = OTA();
|
||||||
auto ledManager = OpenIris::LEDManager(33);
|
auto ledManager = LEDManager(33);
|
||||||
auto cameraHandler = OpenIris::CameraHandler();
|
auto cameraHandler = CameraHandler();
|
||||||
auto stateManager = OpenIris::StateManager();
|
auto stateManager = StateManager();
|
||||||
auto apiServer = OpenIris::APIServer();
|
auto apiServer = APIServer();
|
||||||
auto streamServer = OpenIris::StreamServer();
|
auto streamServer = StreamServer();
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
@ -29,8 +29,8 @@ void setup()
|
|||||||
Serial.setDebugOutput(true);
|
Serial.setDebugOutput(true);
|
||||||
ledManager.setupLED();
|
ledManager.setupLED();
|
||||||
cameraHandler.setupCamera();
|
cameraHandler.setupCamera();
|
||||||
OpenIris::WiFiHandler::setupWifi(ssid, password);
|
WiFiHandler::setupWifi(ssid, password);
|
||||||
OpenIris::MDNSHandler::setupMDNS();
|
MDNSHandler::setupMDNS();
|
||||||
apiServer.startAPIServer();
|
apiServer.startAPIServer();
|
||||||
streamServer.startStreamServer();
|
streamServer.startStreamServer();
|
||||||
ledManager.on();
|
ledManager.on();
|
||||||
|
|||||||
@ -5,7 +5,7 @@ constexpr static char *STREAM_CONTENT_TYPE = "multipart/x-mixed-replace;boundary
|
|||||||
constexpr static char *STREAM_BOUNDARY = "\r\n--" PART_BOUNDARY "\r\n";
|
constexpr static char *STREAM_BOUNDARY = "\r\n--" PART_BOUNDARY "\r\n";
|
||||||
constexpr static char *STREAM_PART = "Content-Type: image/jpeg\r\nContent-Length: %u\r\nX-Timestamp: %d.%06d\r\n\r\n";
|
constexpr static char *STREAM_PART = "Content-Type: image/jpeg\r\nContent-Length: %u\r\nX-Timestamp: %d.%06d\r\n\r\n";
|
||||||
|
|
||||||
esp_err_t OpenIris::StreamHelpers::stream(httpd_req_t *req)
|
esp_err_t StreamHelpers::stream(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
long last_request_time = 0;
|
long last_request_time = 0;
|
||||||
camera_fb_t *fb = NULL;
|
camera_fb_t *fb = NULL;
|
||||||
@ -83,7 +83,7 @@ esp_err_t OpenIris::StreamHelpers::stream(httpd_req_t *req)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int OpenIris::StreamServer::startStreamServer()
|
int StreamServer::startStreamServer()
|
||||||
{
|
{
|
||||||
httpd_config_t config = HTTPD_DEFAULT_CONFIG();
|
httpd_config_t config = HTTPD_DEFAULT_CONFIG();
|
||||||
config.max_uri_handlers = 1;
|
config.max_uri_handlers = 1;
|
||||||
@ -93,7 +93,7 @@ int OpenIris::StreamServer::startStreamServer()
|
|||||||
httpd_uri_t stream_page = {
|
httpd_uri_t stream_page = {
|
||||||
.uri = "/",
|
.uri = "/",
|
||||||
.method = HTTP_GET,
|
.method = HTTP_GET,
|
||||||
.handler = &OpenIris::StreamHelpers::stream,
|
.handler = &StreamHelpers::stream,
|
||||||
.user_ctx = nullptr};
|
.user_ctx = nullptr};
|
||||||
|
|
||||||
int status = httpd_start(&camera_stream, &config);
|
int status = httpd_start(&camera_stream, &config);
|
||||||
|
|||||||
@ -1,23 +1,23 @@
|
|||||||
#include "GlobalVars.h"
|
#include "GlobalVars.h"
|
||||||
#include "webserverHandler.h"
|
#include "webserverHandler.h"
|
||||||
|
|
||||||
OpenIris::APIServer::APIServer()
|
APIServer::APIServer()
|
||||||
{
|
{
|
||||||
this->server = new AsyncWebServer(CONTROL_SERVER_PORT);
|
this->server = new AsyncWebServer(CONTROL_SERVER_PORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenIris::APIServer::startAPIServer()
|
void APIServer::startAPIServer()
|
||||||
{
|
{
|
||||||
this->server->on(
|
this->server->on(
|
||||||
"/control",
|
"/control",
|
||||||
HTTP_GET,
|
HTTP_GET,
|
||||||
std::bind(&OpenIris::APIServer::command_handler, this, std::placeholders::_1));
|
std::bind(&APIServer::command_handler, this, std::placeholders::_1));
|
||||||
|
|
||||||
log_d("Initializing web server");
|
log_d("Initializing web server");
|
||||||
this->server->begin();
|
this->server->begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenIris::APIServer::command_handler(AsyncWebServerRequest *request)
|
void APIServer::command_handler(AsyncWebServerRequest *request)
|
||||||
{
|
{
|
||||||
if (request->hasParam("framesize"))
|
if (request->hasParam("framesize"))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#include "WifiHandler.h"
|
#include "WifiHandler.h"
|
||||||
#include "GlobalVars.h"
|
#include "GlobalVars.h"
|
||||||
|
|
||||||
void OpenIris::WiFiHandler::setupWifi(const char *ssid, const char *password)
|
void WiFiHandler::setupWifi(const char *ssid, const char *password)
|
||||||
{
|
{
|
||||||
log_d("Initializing connection to wifi");
|
log_d("Initializing connection to wifi");
|
||||||
|
|
||||||
@ -16,14 +16,14 @@ void OpenIris::WiFiHandler::setupWifi(const char *ssid, const char *password)
|
|||||||
{
|
{
|
||||||
wifi_status = WiFi.status();
|
wifi_status = WiFi.status();
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
stateManager.setState(OpenIris::State::ConnectingToWifi);
|
stateManager.setState(State::ConnectingToWifi);
|
||||||
time_spent_connecting += 1600;
|
time_spent_connecting += 1600;
|
||||||
delay(1600);
|
delay(1600);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wifi_status == WL_CONNECTED)
|
if (wifi_status == WL_CONNECTED)
|
||||||
{
|
{
|
||||||
stateManager.setState(OpenIris::State::ConnectingToWifiSuccess);
|
stateManager.setState(State::ConnectingToWifiSuccess);
|
||||||
delay(1600);
|
delay(1600);
|
||||||
log_i("\n\rWiFi connected\n\r");
|
log_i("\n\rWiFi connected\n\r");
|
||||||
log_i("ESP will be streaming under 'http://%s:80/\r\n", WiFi.localIP().toString().c_str());
|
log_i("ESP will be streaming under 'http://%s:80/\r\n", WiFi.localIP().toString().c_str());
|
||||||
@ -31,7 +31,7 @@ void OpenIris::WiFiHandler::setupWifi(const char *ssid, const char *password)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stateManager.setState(OpenIris::State::ConnectingToWifiError);
|
stateManager.setState(State::ConnectingToWifiError);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user