aboutsummaryrefslogtreecommitdiff
path: root/ble/Bluetooth.cpp
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2015-07-26 18:33:15 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2015-07-26 18:41:40 +0200
commitd720fa36ad4768ed1b948a92ba5287c30093fbec (patch)
tree3d566e0d4ab47981af85a783f81ebbd363d57f15 /ble/Bluetooth.cpp
parent33c537c84fea53c899fb5275256518598f66101e (diff)
downloadble-toys-d720fa36ad4768ed1b948a92ba5287c30093fbec.tar.gz
ble-toys-d720fa36ad4768ed1b948a92ba5287c30093fbec.tar.bz2
ble-toys-d720fa36ad4768ed1b948a92ba5287c30093fbec.tar.xz
ble-toys-d720fa36ad4768ed1b948a92ba5287c30093fbec.zip
o Overhaul of the bluetooth code.
- Adding support for reading FLOAT (specified in IEEE 11073-20601) values from a bluetooth device. - More shared pointers to help keep track of the object's lifecycle. Makes sure that the connections are released back to Linux, Linux is way to sensitive with crashing applications. o Adding support for reading the temperature sensors from the SoilMoisture device.
Diffstat (limited to 'ble/Bluetooth.cpp')
-rw-r--r--ble/Bluetooth.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/ble/Bluetooth.cpp b/ble/Bluetooth.cpp
index 3db0bfc..13c81b3 100644
--- a/ble/Bluetooth.cpp
+++ b/ble/Bluetooth.cpp
@@ -201,19 +201,26 @@ BluetoothAdapter::BluetoothAdapter() {
BluetoothAdapter::~BluetoothAdapter() {
}
+// -----------------------------------------------------------------------
+// Bluetooth System. This is not sub-classed by implementations.
+// -----------------------------------------------------------------------
+
BluetoothSystem::BluetoothSystem() {
}
BluetoothSystem::~BluetoothSystem() {
- shutdown();
+ adapters.clear();
}
-shared_ptr<BluetoothAdapter> getAdapter(int hciDevice) {
- return getAdapterImpl(hciDevice);
-}
+shared_ptr<BluetoothAdapter> BluetoothSystem::getAdapter(string name) {
+ auto it = adapters.find(name);
+
+ if (it == adapters.end()) {
+ auto adapter = adapters[name] = getAdapterImpl(name);
+ return adapter;
+ }
-void shutdown() {
- shutdownImpl();
+ return it->second;
}
uuid_t makeUuid(const uuid_t base, uint8_t a, uint8_t b) {