feat: Implement Discord app UI and settings management
- Added MainUI class for displaying voice state, status icon, and buttons. - Introduced MainUIHandler to manage UI interactions and bridge communication. - Created SettingsUI for displaying QR code and configuration instructions. - Implemented SettingsUIHandler to manage settings and web server interactions. - Developed WebHandler for handling HTTP requests for settings configuration. - Updated AppRegistry to initialize with the new Discord app descriptor. - Enhanced InteractionHandler to support keyboard interactions across app switches. - Updated UIHandler to manage app switching and rendering of app icons. - Enabled QR code support in LVGL configuration.
This commit is contained in:
67
main/ui/apps/iotdis/bridge/bridge.h
Normal file
67
main/ui/apps/iotdis/bridge/bridge.h
Normal file
@@ -0,0 +1,67 @@
|
||||
#pragma once
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "ui/apps/iotdis/settings/settings_handler.h"
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include "esp_err.h"
|
||||
#include "network/udp_client.h"
|
||||
|
||||
struct StatusUpdateEventData {
|
||||
enum class VoiceState {
|
||||
UNKNOWN,
|
||||
MUTED,
|
||||
UNMUTED,
|
||||
ERROR
|
||||
} state;
|
||||
};
|
||||
|
||||
using StatusEventCallback = void(*)(StatusUpdateEventData, void*);
|
||||
|
||||
|
||||
class IotDisBridge {
|
||||
public:
|
||||
IotDisBridge(
|
||||
SettingHandler* setting_handler
|
||||
) : setting_handler_(setting_handler) { }
|
||||
~IotDisBridge();
|
||||
|
||||
void start_polling_task();
|
||||
void stop_polling_task();
|
||||
|
||||
esp_err_t send_mute_command();
|
||||
bool test_connection(const std::string& ip, uint16_t port) {
|
||||
return test_connection(ip, port, setting_handler_->get_local_port());
|
||||
}
|
||||
bool test_connection(const std::string& ip, uint16_t port, uint16_t local_port);
|
||||
void register_on_status_update_callback(
|
||||
StatusEventCallback callback,
|
||||
void* status_event_user_data
|
||||
) {
|
||||
on_status_update_callback_ = callback;
|
||||
status_event_user_data_ = status_event_user_data;
|
||||
}
|
||||
|
||||
private:
|
||||
static constexpr int POLL_INTERVAL_MS = 2000;
|
||||
static constexpr int ERROR_POLL_INTERVAL_MS = 5000;
|
||||
static constexpr int RESPONSE_TIMEOUT_MS = 1000;
|
||||
static constexpr int MAX_FAILURES_BEFORE_ERROR = 3;
|
||||
|
||||
void poll_status_();
|
||||
|
||||
// Polling task
|
||||
static void poll_task_(void* param);
|
||||
|
||||
TaskHandle_t poll_task_handle_ = nullptr;
|
||||
bool stop_polling_ = false;
|
||||
int consecutive_failures_ = 0;
|
||||
SettingHandler* setting_handler_ = nullptr;
|
||||
UDPClient udp_client_;
|
||||
|
||||
StatusEventCallback on_status_update_callback_ = nullptr;
|
||||
void* status_event_user_data_ = nullptr;
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user