ble
免费Bluetooth context for the Megahub project. Use when working on BLE GATT server, Classic Bluetooth HID host, Web Bluetooth API integration, btremote library, connection handling, or any Bluetooth-related firmware code.
中文简介正在准备中。当前显示原文说明。
Core firmware context for the Megahub ESP32 project. Use when working on PlatformIO configuration, build scripts, library structure, main.cpp, or general ESP32 firmware development. Covers build system, project structure, common pitfalls, and debugging.
中文简介正在准备中。当前显示原文说明。
查看安装方法安装前可以查看交给 AI 代理的指令内容。
PlatformIO configuration — see platformio.ini:
esp-wrover-kitcustom_4mb_noota.csv (no OTA, maximizes app partition)gitversion.py — injects git hash into firmwarebuildfrontend.py — runs npm run build for the selected frontend modeembedfiles.py — gzips and embeds frontend files into firmware as C arraysSerial monitor: 115200 baud. Log level controlled by CORE_DEBUG_LEVEL (currently 2).
Logging macros — always use these, never Serial.print():
INFO("Free heap: %d bytes", ESP.getFreeHeap());
WARN("Something unexpected: %d", value);
ERROR("Critical failure in %s", __func__);
lib/
btremote/ BLE server (Web Bluetooth API) + Classic BT HID host (gamepads)
commands/ Command processing system — all device operations use this pattern
configuration/ WiFi & system configuration persistence
hubwebserver/ HTTP server using PsychicHttp library
imu/ MPU6050 IMU — I²C, requires proper init sequence
lpfuart/ LEGO Powered Up UART protocol implementation
lua/ Lua 5.4 interpreter (embedded, constrained memory)
megahub/ Main application — wires all libraries together
portstatus/ Port status tracking and JSON serialization
inputdevices/ Gamepad/HID input device abstraction
statusmonitor/ System health monitoring (heap, tasks)
All device operations go through lib/commands/. This provides:
| Pitfall | Fix |
|---|---|
| BLE race condition | Use proper task synchronization (mutex/queue) |
| Stack overflow | Use uxTaskGetStackHighWaterMark(), move large vars to heap |
| String heap fragmentation | Use std::string::reserve() or fixed buffers |
| Blocking in BLE callback | Post to a queue, handle in application task |
| Lua crash | Wrap ALL Lua execution in lua_pcall() |
| LEGO device timeout | Send keepalive commands, handle wake-up sequence |
| IMU init failure | Always include required delays in MPU6050 init sequence |
| Memory leak | Every new/malloc must have matching delete/free |
pio device monitor --baud 115200 # Serial monitor
pio test # Run unit tests
pio run # Build only (no upload)
Crash analysis: Enable ESP32 exception decoder in PlatformIO. Stack traces decode to source lines.
Runtime monitoring:
INFO("Free heap: %d bytes, Free PSRAM: %d bytes",
ESP.getFreeHeap(), ESP.getFreePsram());
INFO("Task stack HWM: %d words", uxTaskGetStackHighWaterMark(NULL));
Known heap budget (from real device logs):
还没有评价。欢迎分享你的使用感受。
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。
Bluetooth context for the Megahub project. Use when working on BLE GATT server, Classic Bluetooth HID host, Web Bluetooth API integration, btremote library, connection handling, or any Bluetooth-related firmware code.
中文简介正在准备中。当前显示原文说明。
Blockly visual programming context for the Megahub project. Use when adding, modifying, or debugging custom Blockly blocks, the Lua code generator, the toolbox, block colors, or the BLOCKS.md documentation generation script.
中文简介正在准备中。当前显示原文说明。
Documentation structure and maintenance rules for the Megahub project. Use whenever making user-facing changes — adding features, changing behavior, fixing hardware compatibility, or modifying configuration. Describes which files to update, the README structure, and writing style.
中文简介正在准备中。当前显示原文说明。
Frontend development context for the Megahub project. Use when working on the web-based IDE, Vite build system, Blockly visual programming, Web Bluetooth API integration, JavaScript frontend code, CSS/styles, UI components, or anything in the /frontend/ directory.
中文简介正在准备中。当前显示原文说明。
LEGO Powered Up protocol context for the Megahub project. Use when working on LEGO device communication, lpfuart library, UART parsing, motor control, sensor modes, device initialization, or debugging UART noise/corruption issues.
中文简介正在准备中。当前显示原文说明。
Code formatting and linting context for the Megahub project. Use when writing or reviewing code in C++ or JavaScript, or when running format/lint checks. Describes tool commands, style conventions, and when to apply them.
中文简介正在准备中。当前显示原文说明。