summaryrefslogtreecommitdiffstats
path: root/src/commands/mod.rs
blob: e2b886bbb5124b2e870e19cf2d693ee428a785b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
pub mod stream_mapper;

use super::enums::LatencyMode;

/// Commands

pub enum Command {
  GetInfo,
  CreateScanner {
    scan_id: u32,
  },
  RemoveScanner {
    scan_id: u32,
  },
  CreateConnectionChannel {
    conn_id: u32,
    bd_addr: String,
    latency_mode: LatencyMode,
    auto_disconnect_time: i16,
  },
  RemoveConnectionChannel {
    conn_id: u32,
  },
  ForceDisconnect {
    bd_addr: String,
  },
  ChangeModeParameters {
    conn_id: u32,
    latency_mode: LatencyMode,
    auto_disconnect_time: i16,
  },
  Ping {
    ping_id: u32,
  },
  GetButtonInfo {
    bd_addr: String,
  },
  CreateScanWizard {
    scan_wizard_id: u32,
  },
  CancelScanWizard {
    scan_wizard_id: u32,
  },
  DeleteButton {
    bd_addr: String,
  },
  CreateBatteryStatusListener {
    listener_id: u32,
    bd_addr: String,
  },
  RemoveBatteryStatusListener {
    listener_id: u32,
  },
}

impl Command {
  pub fn opcode(&self) -> u8 {
    match self {
        Self::GetInfo{..} => 0,
        Self::CreateScanner{..} => 1,
        Self::RemoveScanner{..} => 2,
        Self::CreateConnectionChannel{..} => 3,
        Self::RemoveConnectionChannel{..} => 4,
        Self::ForceDisconnect{..} => 5,
        Self::ChangeModeParameters{..} => 6,
        Self::Ping{..} => 7,
        Self::GetButtonInfo{..} => 8,
        Self::CreateScanWizard{..} => 9,
        Self::CancelScanWizard{..} => 10,
        Self::DeleteButton{..} => 11,
        Self::CreateBatteryStatusListener{..} => 12,
        Self::RemoveBatteryStatusListener{..} => 13,
    }
  }
}