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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use std::collections::HashMap;
use std::error::Error;
use std::sync::Arc;

const NOT_SUPPORTED_ERROR: &str = "Error! Not supported platform!";

#[derive(Clone, Debug)]
pub struct EmptyAdapter {}

impl EmptyAdapter {
    pub fn init() -> Result<EmptyAdapter, Box<dyn Error>> {
        Ok(EmptyAdapter::new())
    }

    fn new() -> EmptyAdapter {
        EmptyAdapter {}
    }

    pub fn get_id(&self) -> String {
        String::new()
    }

    pub fn get_device_list(&self) -> Result<Vec<String>, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_address(&self) -> Result<String, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_name(&self) -> Result<String, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_alias(&self) -> Result<String, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn set_alias(&self, _value: String) -> Result<(), Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_class(&self) -> Result<u32, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn is_powered(&self) -> Result<bool, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn set_powered(&self, _value: bool) -> Result<(), Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn is_discoverable(&self) -> Result<bool, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn set_discoverable(&self, _value: bool) -> Result<(), Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn is_pairable(&self) -> Result<bool, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn set_pairable(&self, _value: bool) -> Result<(), Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_pairable_timeout(&self) -> Result<u32, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn set_pairable_timeout(&self, _value: u32) -> Result<(), Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_discoverable_timeout(&self) -> Result<u32, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn set_discoverable_timeout(&self, _value: u32) -> Result<(), Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn is_discovering(&self) -> Result<bool, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_uuids(&self) -> Result<Vec<String>, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_vendor_id_source(&self) -> Result<String, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_vendor_id(&self) -> Result<u32, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_product_id(&self) -> Result<u32, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_device_id(&self) -> Result<u32, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_modalias(&self) -> Result<(String, u32, u32, u32), Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }
}

#[derive(Clone, Debug)]
pub struct BluetoothDiscoverySession {}

impl BluetoothDiscoverySession {
    pub fn create_session(
        _adapter: Arc<EmptyAdapter>,
    ) -> Result<BluetoothDiscoverySession, Box<dyn Error>> {
        Ok(BluetoothDiscoverySession {})
    }

    pub fn start_discovery(&self) -> Result<(), Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn stop_discovery(&self) -> Result<(), Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }
}

#[derive(Clone, Debug)]
pub struct BluetoothDevice {}

impl BluetoothDevice {
    pub fn new(_device: String) -> BluetoothDevice {
        BluetoothDevice {}
    }

    pub fn get_id(&self) -> String {
        String::new()
    }

    pub fn get_address(&self) -> Result<String, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_name(&self) -> Result<String, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_icon(&self) -> Result<String, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_class(&self) -> Result<u32, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_appearance(&self) -> Result<u16, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_uuids(&self) -> Result<Vec<String>, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn is_paired(&self) -> Result<bool, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn is_connected(&self) -> Result<bool, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn is_trusted(&self) -> Result<bool, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn is_blocked(&self) -> Result<bool, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_alias(&self) -> Result<String, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn set_alias(&self, _value: String) -> Result<(), Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn is_legacy_pairing(&self) -> Result<bool, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_vendor_id_source(&self) -> Result<String, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_vendor_id(&self) -> Result<u32, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_product_id(&self) -> Result<u32, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_device_id(&self) -> Result<u32, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_modalias(&self) -> Result<(String, u32, u32, u32), Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_rssi(&self) -> Result<i16, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_tx_power(&self) -> Result<i16, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_manufacturer_data(&self) -> Result<HashMap<u16, Vec<u8>>, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_service_data(&self) -> Result<HashMap<String, Vec<u8>>, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_gatt_services(&self) -> Result<Vec<String>, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn connect(&self) -> Result<(), Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn disconnect(&self) -> Result<(), Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn connect_profile(&self, _uuid: String) -> Result<(), Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn disconnect_profile(&self, _uuid: String) -> Result<(), Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn pair(&self) -> Result<(), Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn cancel_pairing(&self) -> Result<(), Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }
}

#[derive(Clone, Debug)]
pub struct BluetoothGATTService {}

impl BluetoothGATTService {
    pub fn new(_service: String) -> BluetoothGATTService {
        BluetoothGATTService {}
    }

    pub fn get_id(&self) -> String {
        String::new()
    }

    pub fn get_uuid(&self) -> Result<String, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn is_primary(&self) -> Result<bool, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_includes(&self) -> Result<Vec<String>, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_gatt_characteristics(&self) -> Result<Vec<String>, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }
}

#[derive(Clone, Debug)]
pub struct BluetoothGATTCharacteristic {}

impl BluetoothGATTCharacteristic {
    pub fn new(_characteristic: String) -> BluetoothGATTCharacteristic {
        BluetoothGATTCharacteristic {}
    }

    pub fn get_id(&self) -> String {
        String::new()
    }

    pub fn get_uuid(&self) -> Result<String, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_value(&self) -> Result<Vec<u8>, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn is_notifying(&self) -> Result<bool, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_flags(&self) -> Result<Vec<String>, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_gatt_descriptors(&self) -> Result<Vec<String>, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn read_value(&self) -> Result<Vec<u8>, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn write_value(&self, _values: Vec<u8>) -> Result<(), Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn start_notify(&self) -> Result<(), Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn stop_notify(&self) -> Result<(), Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }
}

#[derive(Clone, Debug)]
pub struct BluetoothGATTDescriptor {}

impl BluetoothGATTDescriptor {
    pub fn new(_descriptor: String) -> BluetoothGATTDescriptor {
        BluetoothGATTDescriptor {}
    }

    pub fn get_id(&self) -> String {
        String::new()
    }

    pub fn get_uuid(&self) -> Result<String, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_value(&self) -> Result<Vec<u8>, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn get_flags(&self) -> Result<Vec<String>, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn read_value(&self) -> Result<Vec<u8>, Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }

    pub fn write_value(&self, _values: Vec<u8>) -> Result<(), Box<dyn Error>> {
        Err(Box::from(NOT_SUPPORTED_ERROR))
    }
}