summaryrefslogtreecommitdiff
path: root/chromium/components/arc/common/bluetooth.mojom
blob: f3ecb8b0f11c8121bd72290bd9d86e44f24bda9d (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module arc;

[Extensible]
enum BluetoothAdapterState {
  OFF = 0,
  ON
};

[Extensible]
enum BluetoothDiscoveryState {
  STOPPED,
  STARTED
};

[Extensible]
enum BluetoothAclState {
  CONNECTED,
  DISCONNECTED
};

[Extensible]
enum BluetoothStatus {
  SUCCESS = 0,
  FAIL,
  NOT_READY,
  NOMEM,
  BUSY,
  DONE,
  UNSUPPORTED,
  PARM_INVALID,
  UNHANDLED,
  AUTH_FAILURE,
  RMT_DEV_DOWN,
  AUTH_REJECTED
};

struct BluetoothAddress {
  array<uint8, 6> address;
};

struct BluetoothUUID {
  array<uint8, 16> uuid;
};

struct BluetoothServiceRecord {
  BluetoothUUID uuid;
  uint16 channel;
  string name;
};

struct BluetoothLocalLEFeatures {
  uint16 version_supported;
  uint8 local_privacy_enabled;
  uint8 max_adv_instance;
  uint8 rpa_offload_supported;
  uint8 max_irk_list_size;
  uint8 max_adv_filter_supported;
  uint8 activity_energy_info_supported;
  uint16 scan_result_storage_size;
  uint16 total_trackable_advertisers;
  bool extended_scan_support;
  bool debug_logging_supported;
};

[Extensible]
enum BluetoothPropertyType {
  ALL = 0,
  BDNAME = 1,
  BDADDR,
  UUIDS,
  CLASS_OF_DEVICE,
  TYPE_OF_DEVICE,
  SERVICE_RECORD,
  ADAPTER_SCAN_MODE,
  ADAPTER_BONDED_DEVICES,
  ADAPTER_DISCOVERY_TIMEOUT,
  REMOTE_FRIENDLY_NAME,
  REMOTE_RSSI,
  REMOTE_VERSION_INFO,
  LOCAL_LE_FEATURES,
  REMOTE_DEVICE_TIMESTAMP = 0xFF,
};

[Extensible]
enum BluetoothScanMode {
  NONE = 0x0,
  CONNECTABLE,
  CONNECTABLE_DISCOVERABLE
};

[Extensible]
enum BluetoothDeviceType {
  BREDR = 0x1,
  BLE,
  DUAL
};

[Extensible]
enum BluetoothBondState {
  NONE = 0,
  BONDING,
  BONDED
};

struct BluetoothRemoteVersion {
  int32 version;
  int32 sub_ver;
  int32 manufacturer;
};

union BluetoothProperty {
  string bdname;
  BluetoothAddress bdaddr;
  array<BluetoothUUID> uuids;
  uint32 device_class;
  BluetoothDeviceType device_type;
  BluetoothServiceRecord service_record;
  BluetoothScanMode adapter_scan_mode;
  array<BluetoothAddress> bonded_devices;
  uint32 discovery_timeout;
  string remote_friendly_name;
  int32 remote_rssi;
  BluetoothRemoteVersion remote_version;
  BluetoothLocalLEFeatures local_le_features;
};

interface BluetoothHost {
  EnableAdapter() => (BluetoothAdapterState state);
  DisableAdapter() => (BluetoothAdapterState state);
  GetAdapterProperty(BluetoothPropertyType type);
  SetAdapterProperty(BluetoothProperty property);
  GetRemoteDeviceProperty(BluetoothAddress remote_addr,
                          BluetoothPropertyType type);
  SetRemoteDeviceProperty(BluetoothAddress remote_addr,
                          BluetoothProperty property);
  GetRemoteServiceRecord(BluetoothAddress remote_addr,
                         BluetoothUUID uuid);
  GetRemoteServices(BluetoothAddress remote_addr);
  StartDiscovery();
  CancelDiscovery();
  CreateBond(BluetoothAddress addr, int32 transport);
  RemoveBond(BluetoothAddress addr);
  CancelBond(BluetoothAddress addr);

  GetConnectionState(BluetoothAddress addr) => (bool connected);
};

interface BluetoothInstance {
  Init(BluetoothHost host_ptr);

  OnAdapterProperties(BluetoothStatus status,
                      array<BluetoothProperty> properties);
  OnRemoteDeviceProperties(BluetoothStatus status,
                           BluetoothAddress address,
                           array<BluetoothProperty> properties);
  OnDeviceFound(array<BluetoothProperty> properties);
  OnDiscoveryStateChanged(BluetoothDiscoveryState state);
  OnBondStateChanged(BluetoothStatus status,
                     BluetoothAddress remote_addr,
                     BluetoothBondState state);
  OnAclStateChanged(BluetoothStatus status,
                    BluetoothAddress remote_addr,
                    BluetoothAclState state);
};