Admin
reboot restarts one of the two chips, factory_reset erases what the box keeps across a reboot, and reset returns the box to passthrough. All three are fire-and-forget: one frame, no reply.
use medius::Device;
let device = Device::find()?; // first box on the system, handshake done
device.reset()?; // back to passthroughresetClear all injection, return to passthrough
fn reset(&self) -> Result<()>
Fire-and-forget
| State | After reset |
|---|---|
| Box accumulator | Zeroed: the running total of injected motion and scroll not yet emitted to the PC. |
| Box overrides | All released. An override holds one usage down or up. |
| Library held-state | Cleared. A later reapply or reconnect re-asserts nothing. The box counts the reset as a session release, and recovery from it restores nothing. |
Sends one RESET frame.
use medius::Button;
device.move_rel(40, 0)?; // 40 right
device.press(Button::LEFT)?; // hold left down
device.release(Button::LEFT)?; // release it
device.reset()?; // drop all of the above, back to passthroughfactory_reset Reset, erase the store, reboot
fn factory_reset(&self) -> Result<()>
Fire-and-forget
Does what reset does, then erases what the box keeps across a reboot and restarts it.
| Stored | After |
|---|---|
| Box name | The MAC-derived default, as on a new box (set_name). |
| Options | All seven at their defaults, imperfect-clone opt-in included. |
| Learned per-device data | Gone for every device the box has seen, patch sets included. |
Sends one RESET frame with its NVS flag. The clone re-enumerates on the game PC. The control port stays enumerated through the reboot, so the link stays up. Queries time out until the box replies, so poll one to know it is back.
device.factory_reset()?; // back to a box that has learned nothingrebootRestart a chip, or boot it to download mode
fn reboot(&self, target: RebootTarget) -> Result<()>
Fire-and-forget
RebootTarget picks the chip, and whether it comes back running firmware or in download mode. Its four variants and bytes are on Types. The wire layout is on the native REBOOT command.
use medius::RebootTarget;
device.reboot(RebootTarget::DeviceRun)?; // restart the device chipA Download variant leaves the chip in ROM download mode until reflashed or power-cycled. Meanwhile it presents no clone and doesn't reply on the control link. Send one only to flash.
A rebooted device chip sends the ready hello. Once the clone is back, the library re-sends what it holds (session recovery). If the link drops meanwhile, the reader thread's auto-reconnect brings it back, or reconnect forces it.
A box already running Medius takes firmware over the open connection through the update calls. A Download reboot is only for a first install or a chip whose app won't boot.
On AsyncDevice Still fire-and-forget, no await
AsyncDevice re-exposes reset and reboot unchanged: no reply, so no .await and no block_on. Only queries are async.
use medius::{AsyncDevice, RebootTarget};
let device = AsyncDevice::open("/dev/ttyACM0")?;
device.reset()?; // sync, no await
device.reboot(RebootTarget::HostRun)?; // sync, no await