Python SDK
The Python SDK provides a clean interface for hardware-in-the-loop testing with pytest or any Python workflow.
Installation
bash
pip install flashbayAuthentication
Set your API key:
bash
export FLASHBAY_API_KEY=key_...Or pass it directly:
python
client = flashbay.Client(api_key="key_...")Basic usage
python
import flashbay
client = flashbay.Client()
with client.session(board="esp32-s3") as session:
# Flash firmware
session.flash("firmware.bin")
# Wait for boot message
session.serial.expect("Ready", timeout=10)
# Send a command and read response
session.serial.send("version\n")
response = session.serial.read_until("OK", timeout=5)
print(response)The context manager automatically ends the session when the block exits.
pytest integration
python
import pytest
import flashbay
@pytest.fixture
def board():
client = flashbay.Client()
with client.session(board="esp32-s3") as session:
session.flash("build/firmware.bin")
session.serial.expect("Ready")
yield session
def test_status_command(board):
board.serial.send("status\n")
output = board.serial.read_until("OK", timeout=5)
assert "uptime" in output
def test_wifi_connect(board):
board.serial.send("wifi connect\n")
output = board.serial.read_until("Connected", timeout=15)
assert "IP:" in outputSerial methods
| Method | Description |
|---|---|
serial.send(data) | Send string to the board's UART |
serial.read(n) | Read up to n bytes |
serial.read_until(pattern, timeout) | Read until pattern is found or timeout |
serial.expect(pattern, timeout) | Assert that pattern appears within timeout |
serial.flush() | Clear the receive buffer |
Session methods
| Method | Description |
|---|---|
session.flash(path) | Flash a firmware binary |
session.reset() | Power cycle the board |
session.info() | Get session details (board, state, credits used) |