Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions design/linkhub.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,22 @@ renewal and attempts a stop. A suspended browser must not revive an expired
lease, and reopening the panel never starts or adopts a running motor.
UI operation is described in the [motor panel guide](../linkhub-ui/README.md#bluetooth-motor-panel).

The controller journals its state changes as diagnostics with source
`linkhub.motor` and category `motor`, so they share the MAVLink timeline and
appear in an experiment's `mavlog.json`:

| Event | Fields | When |
|---|---|---|
| `motor.connected` | `device`, `device_id` | A device connects (initialized off) |
| `motor.command` | `device_id`, `speed_percent`, `direction`, `timeout_ms` | A command starts the motor or changes its target or direction |
| `motor.stop_requested` | `reason` (`request`, `command_expired`, `disconnect`) | A controlled ramp-down of a running motor begins |
| `motor.stopped` | | The ramp reaches zero and the safe-stop command is written |
| `motor.disconnected` | `device`, `error` | A connected device is disconnected (warning when disconnect failed) |
| `motor.error` | `error` | A Bluetooth operation fails and motor state is unconfirmed (error level) |

Lease renewals that keep the same target and direction are not journaled.
Query them with `linkhub query <dir> diagnostics --source linkhub.motor`.

Generic records, diagnostics, raw MAVLink frames, and decoded MAVLink messages
are finite projections over the same cursor space. Every journal-backed GET
projection accepts an explicit `after` cursor and returns:
Expand Down
17 changes: 11 additions & 6 deletions linkhub/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
motor_scan_timeout_ms,
motor_heartbeat_ms,
motor_max_command_timeout_ms,
journal.clone(),
)
.await?;

Expand Down Expand Up @@ -382,18 +383,22 @@ async fn configure_motor(
scan_timeout_ms: u64,
heartbeat_ms: u64,
maximum_command_timeout_ms: u64,
journal: JournalHandle,
) -> Result<Option<MotorHandle>, Box<dyn std::error::Error>> {
use linkhub::motor::{BleMotorController, MotorConfig};

let Some(name_prefix) = name_prefix else {
return Ok(None);
};
let controller = BleMotorController::bluetooth(MotorConfig {
name_prefix,
scan_timeout: Duration::from_millis(scan_timeout_ms),
heartbeat_interval: Duration::from_millis(heartbeat_ms),
maximum_command_timeout_ms,
})
let controller = BleMotorController::bluetooth(
MotorConfig {
name_prefix,
scan_timeout: Duration::from_millis(scan_timeout_ms),
heartbeat_interval: Duration::from_millis(heartbeat_ms),
maximum_command_timeout_ms,
},
journal,
)
.await?;
Ok(Some(std::sync::Arc::new(controller)))
}
Expand Down
Loading
Loading