feat: integrate MCP server and screen override into system firmware
- Add McpSettings (load/save mcpEnabled, mcpOverrideEnabled to /data/service/mcp/settings.properties) - Add McpSystem: global state, canvas drawing (RGB565, BMP, PBM, text), I2S audio (WAV, MP3 via minimp3, tone, record) - Add McpHandler: unauthenticated POST /api/mcp (JSON-RPC 2.0, 13 tools) and POST /api/screen/raw endpoints - Route MCP endpoints before Basic Auth check in WebServerService::handleApiPost - Start HTTP server at boot if either webServerEnabled OR mcpEnabled is set - Fix setEnabled: start unconditionally when called with true; only stop if both WS and MCP are disabled - Add McpSettingsApp (Settings category): toggle MCP service + screen override, show live endpoint URL - Add McpOverrideApp (appId one.tactility.mcpscreen): full-screen LVGL canvas for LLM-driven display override - Register both new apps in Tactility.cpp
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
#ifdef ESP_PLATFORM
|
||||
|
||||
#include <lvgl.h>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <tactility/device.h>
|
||||
|
||||
namespace tt::mcp {
|
||||
|
||||
struct McpSystemState {
|
||||
std::mutex mutex;
|
||||
bool overrideActive = false;
|
||||
|
||||
// UI elements when McpOverrideApp is active
|
||||
lv_obj_t* drawArea = nullptr;
|
||||
uint16_t* framebuffer = nullptr;
|
||||
size_t framebufferSize = 0;
|
||||
uint16_t displayWidth = 320;
|
||||
uint16_t displayHeight = 240;
|
||||
uint16_t drawWidth = 320;
|
||||
uint16_t drawHeight = 240;
|
||||
int drawColor = 1; // 0 = white, 1 = black
|
||||
|
||||
// Audio device status
|
||||
Device* i2sDevice = nullptr;
|
||||
volatile bool audioBusy = false;
|
||||
volatile bool audioRunning = false; // Used to abort play/record loop
|
||||
};
|
||||
|
||||
McpSystemState& getState();
|
||||
|
||||
bool clearScreen(int color);
|
||||
bool drawText(const std::string& text, int x, int y, int size);
|
||||
bool drawRgb565(const uint8_t* data, size_t size, int x, int y, int w, int h);
|
||||
bool drawBmp(const uint8_t* data, size_t size, int x, int y);
|
||||
bool drawPbm(const uint8_t* data, size_t size, int x, int y);
|
||||
std::string getScreenshotPbmBase64();
|
||||
|
||||
bool playTone(int frequency, int durationMs, int volume, std::string& error);
|
||||
bool recordVoice(int durationSec, const std::string& filename, size_t& recordedBytes, std::string& error);
|
||||
bool playAudioFile(const std::string& filename, int volume, std::string& error);
|
||||
bool playWavMemory(const uint8_t* data, size_t size, int volume, std::string& error);
|
||||
bool playMp3File(const std::string& filename, int volume, std::string& error);
|
||||
bool playMp3Memory(const uint8_t* data, size_t size, int volume, std::string& error);
|
||||
|
||||
} // namespace tt::mcp
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -76,6 +76,8 @@ private:
|
||||
static esp_err_t handleApiAppsInstall(httpd_req_t* request);
|
||||
static esp_err_t handleApiWifi(httpd_req_t* request);
|
||||
static esp_err_t handleApiScreenshot(httpd_req_t* request);
|
||||
static esp_err_t handleApiMcp(httpd_req_t* request);
|
||||
static esp_err_t handleApiScreenRaw(httpd_req_t* request);
|
||||
|
||||
// Dynamic asset serving
|
||||
static esp_err_t handleAssets(httpd_req_t* request);
|
||||
|
||||
Reference in New Issue
Block a user