gearvr_controller/event.rs
1//! What a connection to a controller reports.
2
3use crate::protocol::Packet;
4
5/// What a connection to a controller reports.
6///
7/// The background task started by `ble::events` sends these. The type needs no Bluetooth
8/// itself, so another transport, such as a web page using Web Bluetooth, can send the same.
9#[derive(Clone, Debug)]
10pub enum Event {
11 /// Looking for a controller. Sent once each time a search begins.
12 Searching,
13 /// Connected and receiving data.
14 Connected {
15 name: String,
16 /// Battery charge in percent, if the controller reports it.
17 battery: Option<u8>,
18 },
19 /// A data packet.
20 Packet(Packet),
21 /// The connection was lost. A new search follows.
22 Disconnected,
23 /// Something went wrong. The task keeps trying.
24 Error(String),
25}