# EggBot BLE Serial Protocol

## Scope
This transport exposes the same EggBot command protocol as serial, but over BLE GATT.

- Protocol commands and responses are unchanged.
- Framing is unchanged (`\r` command terminator, `\r\n` response lines).

## BLE GATT Profile
- Device name: `EggDuino`
- Service UUID: `6e400001-b5a3-f393-e0a9-e50e24dcca9e`
- RX characteristic (host -> EggDuino): `6e400002-b5a3-f393-e0a9-e50e24dcca9e`
  - Properties: `Write`, `Write Without Response`
- TX characteristic (EggDuino -> host): `6e400003-b5a3-f393-e0a9-e50e24dcca9e`
  - Properties: `Notify`, `Read`

## Data Model
- Host writes plain ASCII command bytes to RX.
- Firmware parses bytes with the same EggBot command parser used for USB serial.
- Firmware sends responses via TX notifications.
- Long responses are segmented into BLE-sized notification chunks; host must reassemble by bytes and parse lines by `\r\n`.

## Compatibility Rules
- A BLE client must send commands exactly as serial hosts do.
- Each command must end with `\r`.
- Data-returning commands (`QP`, `QB`, `QN`, `QL`) return a value line before final status (`OK\r\n`).
- Unknown/invalid command format returns `unknown CMD\r\n`.

## Example BLE Transactions
Version query:
- Write RX: `v\r`
- Notify TX: `EBBv13_and_above Protocol emulated by Eggduino-Firmware V1.6a\r\n`

Move command:
- Write RX: `SM,100,0,200\r`
- Notify TX: `OK\r\n`

Query node count:
- Write RX: `QN\r`
- Notify TX: `<number>\r\n`
- Notify TX: `OK\r\n`

## Operational Notes
- BLE receive bytes are queued and parsed in the main firmware loop.
- If the BLE RX queue overruns, excess bytes are dropped and a log entry is generated.
- BLE and USB serial can coexist; each command response is routed to the transport that received that command.
