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.
中文简介正在准备中。当前显示原文说明。
Memory management and FreeRTOS context for the Megahub ESP32 project. Use when dealing with heap allocation, stack size, task creation, inter-task communication, semaphores, queues, or any ESP32 memory constraints.
中文简介正在准备中。当前显示原文说明。
查看安装方法安装前可以查看交给 AI 代理的指令内容。
| Point in startup | Free heap |
|---|---|
| After IMU init | ~170 KB |
| After Lua state creation | ~140 KB |
| After LEGO motor init | ~140 KB |
| After configuration load | ~139 KB |
| After BT stack start | ~76 KB |
| After BLE characteristics setup | ~76 KB |
| During BLE connection (connected) | ~63–73 KB |
PSRAM: ~4.1 MB available (confirmed present on this board — ESP.getFreePsram()).
BT stack alone consumes ~65 KB of heap. Every BLE connection consumes an additional ~30 KB.
static, heap, or PSRAM.new/malloc. Every allocation needs a matching delete/free.String += loops. Prefer std::string::reserve() or fixed char[] buffers.const and PROGMEM for large constant data to keep it in flash.Known tasks and their stack high-water marks (from real device logs):
| Task | Priority | Stack HWM (words) | Notes |
|---|---|---|---|
loopTask | 1 | 272 | Arduino main loop |
BTMsgProcessor | 2 | 2968–7528 | Processes BLE messages |
HIDEventTask | 5 | 1920 | Classic BT HID events |
PortStatus | 1 | 1420 | LEGO port status reporting |
StatusMonitor | 1 | 2452 | Heap/task monitoring |
Device monitor | 1 | 1776 | Lua thread for device monitoring |
BTU_TASK | 20 | 3624–4988 | BT stack internal |
BTC_TASK | 19 | 4328–4364 | BT stack internal |
hciT | 22 | 1516–1544 | BT HCI layer |
btController | 23 | 2088 | BT controller |
esp_timer | 22 | 4048 | ESP timer service |
ipc0/1 | 24 | 356/476 | IPC (highest priority) |
⚠ loopTask HWM of 272 words is critically low — avoid adding stack usage to the main loop.
xSemaphoreTake with a timeout — never block indefinitelyuxTaskGetStackHighWaterMark(). Stack overflow = silent crash.// Log heap + PSRAM
INFO("Free heap: %d bytes, Free PSRAM: %d bytes",
ESP.getFreeHeap(), ESP.getFreePsram());
// Log task stack (for current task)
INFO("Stack HWM: %d words", uxTaskGetStackHighWaterMark(NULL));
// Log all task stacks (use vTaskList for full snapshot)
还没有评价。欢迎分享你的使用感受。
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。
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.
中文简介正在准备中。当前显示原文说明。
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.
中文简介正在准备中。当前显示原文说明。
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.
中文简介正在准备中。当前显示原文说明。