Package: BluetoothDeviceImpl

BluetoothDeviceImpl

nameinstructionbranchcomplexitylinemethod
BluetoothDeviceImpl(String, String, CommandExecutorService)
M: 12 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
getAdress()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getBluetoothConnector()
M: 19 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
getBluetoothGatt()
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getName()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getType()
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011, 2019 Eurotech and/or its affiliates
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License v1.0
6: * which accompanies this distribution, and is available at
7: * http://www.eclipse.org/legal/epl-v10.html
8: *
9: * Contributors:
10: * Eurotech
11: *******************************************************************************/
12: package org.eclipse.kura.linux.bluetooth;
13:
14: import org.eclipse.kura.bluetooth.BluetoothConnector;
15: import org.eclipse.kura.bluetooth.BluetoothDevice;
16: import org.eclipse.kura.bluetooth.BluetoothGatt;
17: import org.eclipse.kura.executor.CommandExecutorService;
18: import org.eclipse.kura.linux.bluetooth.le.BluetoothGattImpl;
19: import org.osgi.framework.BundleContext;
20: import org.osgi.framework.ServiceReference;
21:
22: public class BluetoothDeviceImpl implements BluetoothDevice {
23:
24: public static final int DEVICE_TYPE_DUAL = 0x003;
25: public static final int DEVICE_TYPE_LE = 0x002;
26: public static final int DEVICE_TYPE_UNKNOWN = 0x000;
27:
28: private final String name;
29: private final String address;
30: private final CommandExecutorService executorService;
31:
32: public BluetoothDeviceImpl(String address, String name, CommandExecutorService executorService) {
33: this.address = address;
34: this.name = name;
35: this.executorService = executorService;
36: }
37:
38: // --------------------------------------------------------------------
39: //
40: // BluetoothDevice API
41: //
42: // --------------------------------------------------------------------
43: @Override
44: public String getName() {
45: return this.name;
46: }
47:
48: @Override
49: public String getAdress() {
50: return this.address;
51: }
52:
53: @Override
54: public int getType() {
55: return DEVICE_TYPE_UNKNOWN;
56: }
57:
58: @Override
59: public BluetoothConnector getBluetoothConnector() {
60: BluetoothConnector bluetoothConnector = null;
61: BundleContext bundleContext = BluetoothServiceImpl.getBundleContext();
62:• if (bundleContext != null) {
63: ServiceReference<BluetoothConnector> sr = bundleContext.getServiceReference(BluetoothConnector.class);
64:• if (sr != null) {
65: bluetoothConnector = bundleContext.getService(sr);
66: }
67: }
68: return bluetoothConnector;
69: }
70:
71: @Override
72: public BluetoothGatt getBluetoothGatt() {
73: return new BluetoothGattImpl(this.address, this.executorService);
74: }
75:
76: }