본문으로 건너뛰기
cccskills
무료GitHub에 공개

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.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md3.5 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Bluetooth Architecture — Megahub ESP32

The project uses both BLE and Classic Bluetooth simultaneously (BTDM dual-mode).

TypePurposeLibrary
BLE (GATT server)Web Bluetooth API ↔ firmwarelib/btremote/
Classic BT (HID host)Gamepad/keyboard/mouse inputlib/btremote/

BLE GATT Server

Service UUID: 4fafc201-1fb5-459e-8fcc-c5c9c331914b

CharacteristicUUIDDirectionType
REQUESTbeb5483e-36e1-4688-b7f5-ea07361b26a8Browser → FirmwareWrite
RESPONSE1c95d5e3-d8f7-413a-bf3d-7a2e5d7be87eFirmware → BrowserNotify
EVENTd8de624e-140f-4a22-8594-e2216b84a5f2Firmware → BrowserNotify
CONTROLf78ebbff-c8b7-4107-93de-889a6a06d408Firmware → BrowserIndicate
  • Indications vs Notifications: CONTROL uses indications (require client ACK). RESPONSE/EVENT use notifications.
  • MTU: Default 23 bytes on connect. Firmware sends MTU_INFO notification immediately after connect, then again after negotiation (up to 517 bytes).
  • From real device logs: MTU negotiates to 514/517 bytes reliably.

BLE Rules (never violate)

  • Never block in BLE callbacks — they run in the BLE stack task context
  • Always check isConnected() before sending notifications/indications
  • Reconnection: Browser handles reconnect via device.gatt.connect() — firmware must keep advertising
  • Multiple connections: Each consumes ~30KB heap — the BT stack alone drops free heap from ~140KB to ~75KB
  • BLE callbacks → post work to a queue, handle in BTMsgProcessor task
  • Indication failures (status=132) during startup are normal — the client ACK pipeline needs time to stabilize after connect

Classic Bluetooth (HID Host)

  • Only for HID devices: gamepads, keyboards, mice
  • Auto-pairing enabled (IO capability: NONE, PIN: "0000")
  • HID events processed in HIDEventTask (priority 5, separate from BLE stack)
  • Never block in HID callback — post to queue
  • Pairing state is persisted in NVS; handle removal gracefully

Startup Sequence

From real device logs, BT init order:

  1. BT controller starts in BTDM dual-mode (esp_bt_controller_enable)
  2. Classic GAP callback registered
  3. Classic scan mode: connectable + discoverable
  4. HID Host initialized → waits for ESP_HIDH_INIT_EVT
  5. Bluedroid BLE init → waits for GATTS registration
  6. GATT service + characteristics created (handles 40–51)
  7. Advertising started
  8. Total heap consumed by BT stack: ~65KB

Message Protocol (BLE)

  • 5-byte fragment header: [type, messageId, fragmentNum(2), flags]
  • Fragmentation: automatic for all requests/responses
  • Streaming file upload: sliding window of 8 chunks, waits for ACK before advancing
  • App request types: from logs — type 10=ready-for-events, type 7=get-projects, type 8=get-autostart, type 9=set-autostart, type 2=get-file, type 6=execute-lua

Debugging BLE

# Enable HCI logs in ESP-IDF menuconfig for raw BLE packet capture
# Watch for these in serial log:
# [INFO] handleGattsConnect()   — client connected
# [INFO] handleGattsMTU()       — MTU negotiated
# [WARN] handleGattsConfirm()   — indication failed (status=132 at startup is normal)

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

blockly

무료

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.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

mirkosertic/Megahub72026년 10월 18일 업데이트

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.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

mirkosertic/Megahub72026년 10월 18일 업데이트

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.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

mirkosertic/Megahub72026년 10월 18일 업데이트

frontend

무료

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.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

mirkosertic/Megahub72026년 10월 18일 업데이트

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.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

mirkosertic/Megahub72026년 10월 18일 업데이트

linting

무료

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.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

mirkosertic/Megahub72026년 10월 18일 업데이트

mirkosertic의 스킬 모두 보기

이 스킬의 문제 신고