diff --git a/CHANGELOG.md b/CHANGELOG.md index f0138f91..7b9761a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.0.2] - 2021-XX-XX +## [0.0.2] - 2021-10-09 ### Added - Safe implementation of `SimpleBLE::Adapter` and `SimpleBLE::Peripheral` classes. @@ -18,6 +18,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `SimpleBLE::Adapter` would fail to stop scanning. _(Thanks PatrykSajdok!)_ - Switched WinRT initialization to single-threaded. +### Changed +- SimpleDBus dependency not migrated to OpenBluetoothToolbox. + ## [0.0.1] - 2021-09-06 ### Added diff --git a/CMakeLists.txt b/CMakeLists.txt index 3354c70f..e908751c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,11 +20,11 @@ else() endif() # Load default parameters passed in through the command line. -if(NOT SIMPLEDBUS_GIT_REPOSITORY) - set(SIMPLEDBUS_GIT_REPOSITORY "https://github.com/kdewald/SimpleDBus.git") +if(NOT SIMPLEBLUEZ_GIT_REPOSITORY) + set(SIMPLEBLUEZ_GIT_REPOSITORY "https://github.com/OpenBluetoothToolbox/SimpleBluez.git") endif() -if(NOT SIMPLEDBUS_GIT_TAG) - set(SIMPLEDBUS_GIT_TAG "feature/simpleble") +if(NOT SIMPLEBLUEZ_GIT_TAG) + set(SIMPLEBLUEZ_GIT_TAG "master") endif() # Perform some overall CMake configurations @@ -57,20 +57,20 @@ if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") message("-- [INFO] Linux Host Detected") FetchContent_Declare( - simpledbus - GIT_REPOSITORY ${SIMPLEDBUS_GIT_REPOSITORY} - GIT_TAG ${SIMPLEDBUS_GIT_TAG} + simplebluez + GIT_REPOSITORY ${SIMPLEBLUEZ_GIT_REPOSITORY} + GIT_TAG ${SIMPLEBLUEZ_GIT_TAG} ) - FetchContent_MakeAvailable(simpledbus) + FetchContent_MakeAvailable(simplebluez) set( EXTERNAL_LIBRARIES - bluezdbus-static + simplebluez-static pthread ) set( EXTERNAL_INCLUDE_DIRS - ${SIMPLEDBUS_INCLUDES} + ${SIMPLEBLUEZ_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR}/src/linux ) set( @@ -90,7 +90,6 @@ elseif (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") set( EXTERNAL_INCLUDE_DIRS - ${SIMPLEDBUS_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR}/src/windows ) set( @@ -203,4 +202,4 @@ endif() # Export the variables needed by the parent project if(NOT ${STANDALONE}) set(SIMPLEBLE_INCLUDES ${SIMPLEBLE_USER_INCLUDE_DIR} PARENT_SCOPE) -endif() \ No newline at end of file +endif() diff --git a/README.md b/README.md index 446e08f4..17e3d915 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,13 @@ from internal or secure sources without the risk of those getting compromised. This is done by specifying the additional command line arguments to the `cmake` command: +- `SIMPLEBLUEZ_GIT_REPOSITORY` + Call CMake with `-DSIMPLEBLUEZ_GIT_REPOSITORY=` to override the + default location of the SimpleBluez repository. +- `SIMPLEBLUEZ_GIT_TAG` + Call CMake with `-DSIMPLEBLUEZ_GIT_TAG=` to override the default + tag of the SimpleBluez repository. + - `SIMPLEDBUS_GIT_REPOSITORY` Call CMake with `-DSIMPLEDBUS_GIT_REPOSITORY=` to override the default location of the SimpleDBus repository. @@ -136,10 +143,10 @@ or just be ignored. | `SimpleBLE::Peripheral::connect` | Yes | Yes | Yes | | `SimpleBLE::Peripheral::disconnect` | Yes | Yes | Yes | | `SimpleBLE::Peripheral::is_connected` | Yes | Yes | Yes | -| `SimpleBLE::Peripheral::is_connectable` | No | Yes | Yes | +| `SimpleBLE::Peripheral::is_connectable` | Yes | Yes | Yes | | `SimpleBLE::Peripheral::services` | Yes | Yes | Yes | -| `SimpleBLE::Peripheral::manufacturer_data` | No | Yes | Yes | -| `SimpleBLE::Peripheral::read` | No | Yes | Yes | +| `SimpleBLE::Peripheral::manufacturer_data` | Yes | Yes | Yes | +| `SimpleBLE::Peripheral::read` | Yes | Yes | Yes | | `SimpleBLE::Peripheral::write_request` | Yes | Yes | Yes | | `SimpleBLE::Peripheral::write_command` | Yes | Yes | Yes | | `SimpleBLE::Peripheral::notify` | Yes | Yes | Yes | @@ -150,7 +157,6 @@ or just be ignored. ## Known Issues / To-Do's - [Linux] Fork safety is not guaranteed. -- [Linux] `SimpleBLE::Peripheral::read` does not work. - [MacOS] Only the main system adapter can be detected. - [MacOS] Implementation has incomplete error handling and might crash if invalid parameters are passed. - [MacOS] Timeout logic can be DRYed up. diff --git a/src/linux/AdapterBase.h b/src/linux/AdapterBase.h index 2eb95f76..974c7f22 100644 --- a/src/linux/AdapterBase.h +++ b/src/linux/AdapterBase.h @@ -10,7 +10,7 @@ #include #include -#include +#include namespace SimpleBLE { diff --git a/src/linux/Bluez.h b/src/linux/Bluez.h index 9fa09229..381c9496 100644 --- a/src/linux/Bluez.h +++ b/src/linux/Bluez.h @@ -2,7 +2,7 @@ #include #include -#include "bluezdbus/BluezService.h" +#include "BluezService.h" namespace SimpleBLE { @@ -23,4 +23,4 @@ class Bluez { void async_thread_function(); }; -} // namespace SimpleBLE \ No newline at end of file +} // namespace SimpleBLE diff --git a/src/linux/PeripheralBase.cpp b/src/linux/PeripheralBase.cpp index 7feafdb8..ee63df5b 100644 --- a/src/linux/PeripheralBase.cpp +++ b/src/linux/PeripheralBase.cpp @@ -57,13 +57,7 @@ bool PeripheralBase::is_connected() { return device->Property_Connected() && device->Property_ServicesResolved(); } -bool PeripheralBase::is_connectable() { - // TODO its a stub, replace with real implementation - if (is_connected()) { - return false; - } - return true; -} +bool PeripheralBase::is_connectable() { return identifier_ != ""; } std::vector PeripheralBase::services() { auto device = _get_device(); @@ -80,19 +74,22 @@ std::vector PeripheralBase::services() { } std::map PeripheralBase::manufacturer_data() { - // TODO: Implement - return {}; + auto device = _get_device(); + + std::map manufacturer_data; + for (auto& [manufacturer_id, value_array] : device->get_manufacturer_data()) { + manufacturer_data[manufacturer_id] = ByteArray((const char*)value_array.data(), value_array.size()); + } + + return manufacturer_data; } ByteArray PeripheralBase::read(BluetoothUUID service, BluetoothUUID characteristic) { // TODO: Check if the characteristic is readable. auto characteristic_object = _get_characteristic(service, characteristic); - // FIXME: SimpleDBus does not have this feature yet. - // std::vector value = characteristic_object->get_value(); - // return ByteArray((const char*)value.data(), value.size()); - - return ByteArray(); + std::vector value = characteristic_object->Property_Value(); + return ByteArray((const char*)value.data(), value.size()); } void PeripheralBase::write_request(BluetoothUUID service, BluetoothUUID characteristic, ByteArray data) { diff --git a/src/linux/PeripheralBase.h b/src/linux/PeripheralBase.h index 15c7764f..e1c73016 100644 --- a/src/linux/PeripheralBase.h +++ b/src/linux/PeripheralBase.h @@ -5,7 +5,7 @@ #include #include -#include +#include #include