diff --git a/CMakeLists.txt b/CMakeLists.txt index f3618dc..c50f447 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,9 +11,9 @@ set(CMAKE_AUTOUIC ON) set(CMAKE_AUTORCC ON) # Set Compile Versions -set(OPENAUTO_BUILD_DATE 20241121) # Binary Release Build Date +set(OPENAUTO_BUILD_DATE 20241124) # Binary Release Build Date set(OPENAUTO_BUILD_MAJOR_RELEASE 4) # Binary Release Build Major Number -set(OPENAUTO_BUILD_MINOR_RELEASE 0) # Binary Release Build Minor Number +set(OPENAUTO_BUILD_MINOR_RELEASE 1) # Binary Release Build Minor Number set(OPENAUTO_BUILD_INCREMENTAL 0) # Binary Build Version - Increment for Each Build # Configure CMAKE @@ -26,6 +26,9 @@ set(CMAKE_CXX_FLAGS_RELEASE "-g -O3") if(NOT CMAKE_BUILD_TYPE) message(STATUS "Forcing Release build type") set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) + set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,/usr/local/qt5/lib") + # Set the possible values of build type for cmake-gui set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() @@ -87,7 +90,7 @@ find_package(aap_protobuf REQUIRED) find_package(aasdk REQUIRED) find_package(Boost REQUIRED COMPONENTS system log OPTIONAL_COMPONENTS unit_test_framework) find_package(libusb-1.0 REQUIRED) -find_package(Qt5 COMPONENTS Multimedia MultimediaWidgets Bluetooth Network) +find_package(Qt5 COMPONENTS DBus Multimedia MultimediaWidgets Bluetooth Network) find_package(OpenSSL REQUIRED) find_package(rtaudio REQUIRED) find_package(taglib REQUIRED) @@ -119,7 +122,7 @@ set(common_include_directory ${include_directory}/f1x/openauto/Common) set(autoapp_sources_directory ${sources_directory}/autoapp) set(autoapp_include_directory ${include_directory}/f1x/openauto/autoapp) -file(GLOB_RECURSE autoapp_source_files ${autoapp_sources_directory}/*.ui ${autoapp_sources_directory}/*.cpp ${autoapp_include_directory}/*.hpp ${common_include_directory}/*.hpp ${resources_directory}/*.qrc) +file(GLOB_RECURSE autoapp_source_files ${autoapp_sources_directory}/*.ui ${autoapp_sources_directory}/*.cpp ${autoapp_include_directory}/*.hpp ${autoapp_include_directory}/*.h ${common_include_directory}/*.hpp ${resources_directory}/*.qrc) add_executable(autoapp ${autoapp_source_files}) @@ -128,6 +131,7 @@ target_include_directories(autoapp PUBLIC ${AAP_PROTOBUF_INCLUDE_DIR} ${AASDK_IN target_link_libraries(autoapp PUBLIC libusb ${Boost_LIBRARIES} + ${Qt5DBus_LIBRARIES} ${Qt5Multimedia_LIBRARIES} ${Qt5MultimediaWidgets_LIBRARIES} ${Qt5Bluetooth_LIBRARIES} @@ -152,7 +156,8 @@ set(btservice_sources_directory ${sources_directory}/btservice) set(btservice_include_directory ${include_directory}/f1x/openauto/btservice) file(GLOB_RECURSE btservice_source_files ${btservice_sources_directory}/*.cpp ${btservice_include_directory}/*.hpp ${autoapp_sources_directory}/Configuration/*.cpp ${autoapp_includes_directory}/Configuration/*.hpp ${common_include_directory}/*.hpp) -add_executable(btservice ${btservice_source_files}) +add_executable(btservice ${btservice_source_files} + src/btservice/BluetoothHandler.cpp) target_link_libraries(btservice PUBLIC ${Boost_LIBRARIES} @@ -162,11 +167,11 @@ target_link_libraries(btservice PUBLIC ${PROTOBUF_LIBRARIES} ${AAP_PROTOBUF_LIB_DIR}) -set_target_properties(openauto - PROPERTIES VERSION ${LIBRARY_VERSION_STRING} SOVERSION ${LIBRARY_BUILD_INCREMENTAL}) +set_target_properties(autoapp + PROPERTIES VERSION ${PROGRAM_VERSION_STRING} SOVERSION ${OPENAUTO_BUILD_INCREMENTAL}) # Install rules -install(TARGETS openauto btservice - EXPORT aasdkTargets - RUNTIME DESTINATION bin -) \ No newline at end of file +#install(TARGETS autoapp btservice +# EXPORT aasdkTargets +# RUNTIME DESTINATION bin +#) \ No newline at end of file diff --git a/RELEASE.txt b/RELEASE.txt index d82e1e3..b47a1a3 100644 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -1,7 +1,15 @@ Release Notes -20241121 - 4.0.0 -Added support for new services provided by AASDK and AAP Protocol version 1.6. -Add extensive logging -Add logo for forked version -Resolve display issue where if Raspberry Pi thinks both HDMI and LCD are enabled, the display width is appearing as two side by side monitors (double width) rather than just using the physical width of the screen. +20241124 - 4.1.0 - Bluetooth Updates +* Rename BluetootAdapterType to BluetoothAdapterType, and change from NONE, LOCAL, REMOTE to NONE, LOCAL, EXTERNAL to better match available settings +* getLocalAddress() on Dummy, Local and Remote bluetooth changed to getAdapterAddress() +* Removed RemoteBluetoothDevice replacing all references with LocalBluetoothDevice. RemoteBluetoothDevice is a wrapper essentially with all pairing work handled by btservice. +* Pairing overlaps between btservice and LocalBluetoothDevice - removed duplicated elements from LocalBluetoothDevice to rely on btservice. +* Swap Bluetooth dropdown in Settings from none, builtin or external, to showing a list of detected Bluetooth Adapters. Write hardware address to config file. + +20241121 - 4.0.0 - AAP 1.6 Support +* Added support for new services provided by AASDK and AAP Protocol version 1.6. +* Add extensive logging +* Add logo for forked version +* Resolve display issue where if Raspberry Pi thinks both HDMI and LCD are enabled, the display width is appearing as two side by side monitors (double width) rather than just using the physical width of the screen. + diff --git a/include/f1x/openauto/btservice/AndroidBluetoothServer.hpp b/include/f1x/openauto/btservice/AndroidBluetoothServer.hpp index 72c9815..478129b 100644 --- a/include/f1x/openauto/btservice/AndroidBluetoothServer.hpp +++ b/include/f1x/openauto/btservice/AndroidBluetoothServer.hpp @@ -47,6 +47,7 @@ namespace f1x::openauto::btservice { private slots: void onClientConnected(); + void onError(QBluetoothServer::Error error); private: std::unique_ptr rfcommServer_; diff --git a/include/f1x/openauto/btservice/AndroidBluetoothService.hpp b/include/f1x/openauto/btservice/AndroidBluetoothService.hpp index 64e0abb..551918d 100644 --- a/include/f1x/openauto/btservice/AndroidBluetoothService.hpp +++ b/include/f1x/openauto/btservice/AndroidBluetoothService.hpp @@ -27,9 +27,9 @@ namespace f1x::openauto::btservice class AndroidBluetoothService: public IAndroidBluetoothService { public: - AndroidBluetoothService(uint16_t portNumber); + AndroidBluetoothService(); - bool registerService(const QBluetoothAddress& bluetoothAddress) override; + bool registerService(int16_t portNumber, const QBluetoothAddress& bluetoothAddress) override; bool unregisterService() override; private: diff --git a/include/f1x/openauto/btservice/BluetoothHandler.hpp b/include/f1x/openauto/btservice/BluetoothHandler.hpp index 236b461..911ad0b 100644 --- a/include/f1x/openauto/btservice/BluetoothHandler.hpp +++ b/include/f1x/openauto/btservice/BluetoothHandler.hpp @@ -6,16 +6,20 @@ #define OPENAUTO_BLUETOOTHHANDLER_HPP #include +#include +#include #include #include - namespace f1x::openauto::btservice { class BluetoothHandler : public QObject, public IBluetoothHandler { Q_OBJECT public: - BluetoothHandler(autoapp::configuration::IConfiguration::Pointer configuration); + BluetoothHandler(btservice::IAndroidBluetoothService::Pointer androidBluetoothService, + autoapp::configuration::IConfiguration::Pointer configuration); + + void shutdownService() override; private slots: void onPairingDisplayPinCode(const QBluetoothAddress &address, QString pin); @@ -28,9 +32,12 @@ namespace f1x::openauto::btservice { void onHostModeStateChanged(QBluetoothLocalDevice::HostMode state); + private: std::unique_ptr localDevice_; autoapp::configuration::IConfiguration::Pointer configuration_; + btservice::IAndroidBluetoothService::Pointer androidBluetoothService_; + btservice::IAndroidBluetoothServer::Pointer androidBluetoothServer_; }; } diff --git a/include/f1x/openauto/btservice/IAndroidBluetoothServer.hpp b/include/f1x/openauto/btservice/IAndroidBluetoothServer.hpp index d626bea..8622209 100644 --- a/include/f1x/openauto/btservice/IAndroidBluetoothServer.hpp +++ b/include/f1x/openauto/btservice/IAndroidBluetoothServer.hpp @@ -18,20 +18,19 @@ #pragma once +#include #include +namespace f1x::openauto::btservice { + class IAndroidBluetoothServer { + public: + typedef std::shared_ptr Pointer; -namespace f1x::openauto::btservice -{ - -class IAndroidBluetoothServer -{ -public: virtual ~IAndroidBluetoothServer() = default; - virtual uint16_t start(const QBluetoothAddress& address) = 0; -}; + virtual uint16_t start(const QBluetoothAddress &address) = 0; + }; } diff --git a/include/f1x/openauto/btservice/IAndroidBluetoothService.hpp b/include/f1x/openauto/btservice/IAndroidBluetoothService.hpp index 0868d83..2dd1c21 100644 --- a/include/f1x/openauto/btservice/IAndroidBluetoothService.hpp +++ b/include/f1x/openauto/btservice/IAndroidBluetoothService.hpp @@ -17,7 +17,7 @@ */ #pragma once - +#include #include namespace f1x::openauto::btservice @@ -26,10 +26,12 @@ namespace f1x::openauto::btservice class IAndroidBluetoothService { public: - virtual ~IAndroidBluetoothService() = default; + typedef std::shared_ptr Pointer; - virtual bool registerService(const QBluetoothAddress& bluetoothAddress) = 0; - virtual bool unregisterService() = 0; + virtual ~IAndroidBluetoothService() = default; + + virtual bool registerService(int16_t portNumber, const QBluetoothAddress& bluetoothAddress) = 0; + virtual bool unregisterService() = 0; }; } diff --git a/include/f1x/openauto/btservice/IBluetoothHandler.hpp b/include/f1x/openauto/btservice/IBluetoothHandler.hpp index d3430c7..94f1fdf 100644 --- a/include/f1x/openauto/btservice/IBluetoothHandler.hpp +++ b/include/f1x/openauto/btservice/IBluetoothHandler.hpp @@ -5,6 +5,7 @@ #ifndef OPENAUTO_IBLUETOOTHHANDLER_HPP #define OPENAUTO_IBLUETOOTHHANDLER_HPP +#include #include #include @@ -15,6 +16,7 @@ namespace f1x::openauto::btservice { public: virtual ~IBluetoothHandler() = default; + virtual void shutdownService() = 0; }; } diff --git a/src/autoapp/Service/ServiceFactory.cpp b/src/autoapp/Service/ServiceFactory.cpp index f4638e8..b7440e5 100644 --- a/src/autoapp/Service/ServiceFactory.cpp +++ b/src/autoapp/Service/ServiceFactory.cpp @@ -141,6 +141,7 @@ namespace f1x::openauto::autoapp::service { std::move(guidanceAudioOutput))); } + /* if (configuration_->telephonyAudioChannelEnabled()) { OPENAUTO_LOG(info) << "[ServiceFactory] Telephony Audio Channel enabled"; auto telephonyAudioOutput = @@ -153,7 +154,7 @@ namespace f1x::openauto::autoapp::service { std::make_shared(ioService_, messenger, std::move(telephonyAudioOutput))); } - +*/ /* * No Need to Check for systemAudioChannelEnabled - MUST be enabled by default. */ diff --git a/src/btservice/AndroidBluetoothServer.cpp b/src/btservice/AndroidBluetoothServer.cpp index 8a66cb6..a9d8af6 100644 --- a/src/btservice/AndroidBluetoothServer.cpp +++ b/src/btservice/AndroidBluetoothServer.cpp @@ -39,22 +39,30 @@ namespace f1x::openauto::btservice { AndroidBluetoothServer::AndroidBluetoothServer(autoapp::configuration::IConfiguration::Pointer configuration) : rfcommServer_(std::make_unique(QBluetoothServiceInfo::RfcommProtocol, this)), configuration_(std::move(configuration)) { + OPENAUTO_LOG(info) << "[AndroidBluetoothServer::AndroidBluetoothServer] Initialising"; + connect(rfcommServer_.get(), &QBluetoothServer::newConnection, this, &AndroidBluetoothServer::onClientConnected); + } /// Start Server listening on Address uint16_t AndroidBluetoothServer::start(const QBluetoothAddress &address) { - OPENAUTO_LOG(debug) << "[AndroidBluetoothServer] start()"; + OPENAUTO_LOG(debug) << "[AndroidBluetoothServer::start]"; if (rfcommServer_->listen(address)) { + return rfcommServer_->serverPort(); } return 0; } + void AndroidBluetoothServer::onError(QBluetoothServer::Error error) { + OPENAUTO_LOG(debug) << "[AndroidBluetoothServer::onError]"; + } + /// Call-Back for when Client Connected void AndroidBluetoothServer::onClientConnected() { - OPENAUTO_LOG(debug) << "[AndroidBluetoothServer] onClientConnected()"; + OPENAUTO_LOG(debug) << "[AndroidBluetoothServer::onClientConnected]"; if (socket != nullptr) { socket->deleteLater(); } @@ -159,8 +167,9 @@ namespace f1x::openauto::btservice { response.set_password( configuration_->getParamFromFile("/etc/hostapd/hostapd.conf", "wpa_passphrase").toStdString()); response.set_bssid(QNetworkInterface::interfaceFromName("wlan0").hardwareAddress().toStdString()); + // TODO: AAP uses different values than WiFiProjection.... response.set_security_mode( - aap_protobuf::service::wifiprojection::message::WifiSecurityMode::WPA2_PERSONAL); + aap_protobuf::service::wifiprojection::message::WifiSecurityMode::WPA2_ENTERPRISE); response.set_access_point_type(aap_protobuf::service::wifiprojection::message::AccessPointType::STATIC); sendMessage(response, 3); diff --git a/src/btservice/AndroidBluetoothService.cpp b/src/btservice/AndroidBluetoothService.cpp index 01cc042..f979848 100644 --- a/src/btservice/AndroidBluetoothService.cpp +++ b/src/btservice/AndroidBluetoothService.cpp @@ -17,10 +17,12 @@ */ #include +#include namespace f1x::openauto::btservice { - AndroidBluetoothService::AndroidBluetoothService(uint16_t portNumber) { + AndroidBluetoothService::AndroidBluetoothService() { + OPENAUTO_LOG(info) << "[AndroidBluetoothService::AndroidBluetoothService] Initialising"; const QBluetoothUuid serviceUuid(QLatin1String("4de17a00-52cb-11e6-bdf4-0800200c9a66")); QBluetoothServiceInfo::Sequence classId; @@ -36,6 +38,10 @@ namespace f1x::openauto::btservice { QBluetoothServiceInfo::Sequence publicBrowse; publicBrowse << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup)); serviceInfo_.setAttribute(QBluetoothServiceInfo::BrowseGroupList, publicBrowse); + } + + bool AndroidBluetoothService::registerService(int16_t portNumber, const QBluetoothAddress &bluetoothAddress) { + OPENAUTO_LOG(info) << "[AndroidBluetoothService::registerService] Registering Service"; QBluetoothServiceInfo::Sequence protocolDescriptorList; QBluetoothServiceInfo::Sequence protocol; @@ -46,13 +52,12 @@ namespace f1x::openauto::btservice { << QVariant::fromValue(quint16(portNumber)); protocolDescriptorList.append(QVariant::fromValue(protocol)); serviceInfo_.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList, protocolDescriptorList); - } - bool AndroidBluetoothService::registerService(const QBluetoothAddress &bluetoothAddress) { return serviceInfo_.registerService(bluetoothAddress); } bool AndroidBluetoothService::unregisterService() { + OPENAUTO_LOG(info) << "[AndroidBluetoothService::unregisterService] Unregistering"; return serviceInfo_.unregisterService(); } diff --git a/src/btservice/BluetoothHandler.cpp b/src/btservice/BluetoothHandler.cpp index 40daafa..149d719 100644 --- a/src/btservice/BluetoothHandler.cpp +++ b/src/btservice/BluetoothHandler.cpp @@ -8,8 +8,11 @@ #include namespace f1x::openauto::btservice { - BluetoothHandler::BluetoothHandler(autoapp::configuration::IConfiguration::Pointer configuration) - : configuration_(std::move(configuration)) { + BluetoothHandler::BluetoothHandler(btservice::IAndroidBluetoothService::Pointer androidBluetoothService, + autoapp::configuration::IConfiguration::Pointer configuration) + : configuration_(std::move(configuration)), + androidBluetoothService_(std::move(androidBluetoothService)), + androidBluetoothServer_(std::make_unique(configuration_)) { OPENAUTO_LOG(info) << "[BluetoothHandler::BluetoothHandler] Starting Up..."; @@ -35,8 +38,7 @@ namespace f1x::openauto::btservice { // Make it visible to others localDevice_->setHostMode(QBluetoothLocalDevice::HostDiscoverable); - btservice::AndroidBluetoothServer androidBluetoothServer(configuration_); - uint16_t portNumber = androidBluetoothServer.start(address); + uint16_t portNumber = androidBluetoothServer_->start(address); if (portNumber == 0) { OPENAUTO_LOG(error) << "[BluetoothHandler::BluetoothHandler] Server start failed."; @@ -46,15 +48,19 @@ namespace f1x::openauto::btservice { OPENAUTO_LOG(info) << "[BluetoothHandler::BluetoothHandler] Listening for connections, address: " << address.toString().toStdString() << ", port: " << portNumber; - btservice::AndroidBluetoothService androidBluetoothService(portNumber); - if (!androidBluetoothService.registerService(address)) { + if (!androidBluetoothService_->registerService(portNumber, address)) { OPENAUTO_LOG(error) << "[BluetoothHandler::BluetoothHandler] Service registration failed."; throw std::runtime_error("Unable to register btservice"); } else { OPENAUTO_LOG(info) << "[BluetoothHandler::BluetoothHandler] Service registered, port: " << portNumber; } - androidBluetoothService.unregisterService(); + // TODO: Connect to any previously paired devices + } + + void BluetoothHandler::shutdownService() { + OPENAUTO_LOG(info) << "[BluetoothHandler::shutdownService] Shutdown initiated"; + androidBluetoothService_->unregisterService(); } void BluetoothHandler::onPairingDisplayPinCode(const QBluetoothAddress &address, QString pin) { diff --git a/src/btservice/btservice.cpp b/src/btservice/btservice.cpp index 287eede..d7074ed 100644 --- a/src/btservice/btservice.cpp +++ b/src/btservice/btservice.cpp @@ -21,6 +21,7 @@ #include #include #include +#include namespace btservice = f1x::openauto::btservice; @@ -31,7 +32,8 @@ int main(int argc, char *argv[]) { auto configuration = std::make_shared(); try { - btservice::BluetoothHandler bluetoothHandler(configuration); + auto androidBluetoothService = std::make_shared(); + btservice::BluetoothHandler bluetoothHandler(androidBluetoothService, configuration); QCoreApplication::exec(); } catch (std::runtime_error& e) { std::cerr << "Exception caught: " << e.what() << std::endl;