- Added readSerial(Stream &stream) method to allow reading from any Stream-compatible transport. - Introduced readChar(char inChar) method for processing individual characters. - Updated command matching logic to enhance debugging output. - Improved buffer handling and command execution flow. Enhance platformio.ini for better compatibility and added libraries - Added NimBLE-Arduino and WebSockets libraries for BLE and WiFi support. - Updated upload and monitor ports for better compatibility with macOS. Integrate WiFi and BLE protocol interfaces - Implemented startWebInterface() to initialize WiFi protocol alongside existing web server. - Added BLE support with a new EggBot BLE Serial Protocol for command handling over BLE. - Created WebSocket server for WiFi communication, maintaining compatibility with existing command protocols. Refactor command handling in Functions.cpp - Replaced direct Serial.print calls with protocolWrite for consistent output handling. - Updated command registration to use a lambda function for better readability and maintainability. Add documentation for EggBot protocols - Created separate markdown files for BLE, WiFi, and Serial protocols detailing command structures and usage. - Provided examples of command transactions for better developer guidance. Implement BLE and WiFi protocol handling in respective source files - Developed BLE_Interface.cpp for managing BLE connections and data transmission. - Created WiFi_Protocol.cpp for handling WebSocket communication and data reception.
54 lines
1.8 KiB
Markdown
54 lines
1.8 KiB
Markdown
# EggBot Serial Protocol (USB/UART)
|
|
|
|
## Scope
|
|
This firmware emulates the EggBot/EBB command protocol over serial transport.
|
|
|
|
- Transport: USB CDC/UART (`115200 8N1`)
|
|
- Command separator: `,`
|
|
- Command terminator: carriage return (`\r`, ASCII 0x0D)
|
|
- Response terminator: carriage return + newline (`\r\n`)
|
|
|
|
## Handshake and Generic Responses
|
|
- Version query: `v\r`
|
|
- Version response: `EBBv13_and_above Protocol emulated by Eggduino-Firmware V1.6a\r\n`
|
|
- Success response: `OK\r\n`
|
|
- Error response: `unknown CMD\r\n`
|
|
|
|
## Implemented Commands
|
|
All commands are case-sensitive and comma-delimited.
|
|
|
|
- `EM,<mode>[,<ignored>]`
|
|
- `SC,<id>,<value>`
|
|
- `SP,<penState>[,<delayMs>]`
|
|
- `SM,<durationMs>,<penSteps>,<rotSteps>`
|
|
- `SE` (ack-only placeholder)
|
|
- `TP[,<delayMs>]`
|
|
- `PO` (ack-only placeholder)
|
|
- `NI`
|
|
- `ND`
|
|
- `SN,<nodeCount>`
|
|
- `QN`
|
|
- `SL,<layer>`
|
|
- `QL`
|
|
- `QP`
|
|
- `QB`
|
|
|
|
## Command Behavior Notes
|
|
- `SM`: firmware blocks until previous move completes, sends `OK`, then runs the requested move.
|
|
- `SP` and `TP`: support optional delay argument in milliseconds.
|
|
- `QP`: returns pen state line (`1` for pen up, `0` for pen down), then `OK`.
|
|
- `QB`: returns button state (`0` or `1`), then `OK`; internal button latch is reset after query.
|
|
- `QN`, `QL`: return numeric line first, then `OK`.
|
|
- `SC` supports these IDs:
|
|
- `4`: set pen-down servo position (EBB value to servo-mapped value)
|
|
- `5`: set pen-up servo position
|
|
- `6`, `7`: accepted, ignored, and acknowledged
|
|
- `11`: set servo rate up
|
|
- `12`: set servo rate down
|
|
|
|
## Timing/Parsing Requirements for Hosts
|
|
- Always terminate each command with `\r`.
|
|
- Do not rely on `\n` as a command terminator.
|
|
- Read until `OK\r\n` (or `unknown CMD\r\n`) to complete command transactions.
|
|
- For commands that return data (`QP`, `QB`, `QN`, `QL`), read one data line plus the final status line.
|