set(ambd_headers core.h imainloop.h pluginloader.h glibmainloop.h)
set(ambd_sources core.cpp main.cpp pluginloader.cpp glibmainloop.cpp imainloop.h)
+pkg_check_modules(gio REQUIRED gio-2.0)
+
if(qtmainloop)
message(STATUS "using Qt mainloop")
add_executable(ambd ${ambd_sources})
include_directories(${include_dirs} )
-target_link_libraries(ambd ${link_libraries} dl amb)
+target_link_libraries(ambd ${link_libraries} dl amb ${gio_LIBRARIES})
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/config.in.json ${CMAKE_CURRENT_BINARY_DIR}/config @ONLY)
${CMAKE_CURRENT_BINARY_DIR}/websocketsink2
${CMAKE_CURRENT_BINARY_DIR}/websocketsource2
${CMAKE_CURRENT_BINARY_DIR}/testsourceconfig
- ${CMAKE_CURRENT_BINARY_DIR}/bluemonkey/bluemonkeyconfig)
+ ${CMAKE_CURRENT_BINARY_DIR}/bluemonkey/bluemonkeyconfig
+ ${CMAKE_CURRENT_BINARY_DIR}/bluetooth)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/configwheel.in.json ${CMAKE_CURRENT_BINARY_DIR}/configwheel @ONLY)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/databasesource.in.json ${CMAKE_CURRENT_BINARY_DIR}/databasesource @ONLY)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/testsourceconfig.in.json ${CMAKE_CURRENT_BINARY_DIR}/testsourceconfig @ONLY)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cangenconfig.in.json ${CMAKE_CURRENT_BINARY_DIR}/cangenconfig @ONLY)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/bluemonkey/bluemonkeyconfig.in.json ${CMAKE_CURRENT_BINARY_DIR}/bluemonkey/bluemonkeyconfig @ONLY)
+configure_file (${CMAKE_CURRENT_SOURCE_DIR}/bluetooth.in.json ${CMAKE_CURRENT_BINARY_DIR}/bluetooth @ONLY)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/testplugins.d.in.json ${CMAKE_CURRENT_SOURCE_DIR}/testplugins.d.json @ONLY)
install (FILES ${amb_examples} DESTINATION /etc/ambd/examples)
--- /dev/null
+{
+ "mainloop" : "@PLUGIN_INSTALL_PATH@/qtmainloopplugin.so",
+ "sources" : [
+ {
+ "name" : "ExampleSouce",
+ "path" : "@PLUGIN_INSTALL_PATH@/examplesourceplugin.so",
+ "delay" : "10000"
+ }
+ ],
+ "sinks": [
+ {
+ "name" : "Bluetooth",
+ "path" : "@PLUGIN_INSTALL_PATH@/bluetoothplugin.so"
+ }
+ ]
+}
+
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/debian/automotive-message-broker-plugins.debian.install ${CMAKE_SOURCE_DIR}/debian/automotive-message-broker-plugins.install @ONLY)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/debian/changelog ${CMAKE_SOURCE_DIR}/debian/changelog @ONLY)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/debian/rules ${CMAKE_SOURCE_DIR}/debian/rules @ONLY)
- configure_file (${CMAKE_CURRENT_SOURCE_DIR}/debian/automotive-message-broker-plugins-bluemonkey.debian.install ${CMAKE_SOURCE_DIR}/debian/automotive-message-broker-plugins-bluemonkey.install @ONLY)
+ configure_file (${CMAKE_CURRENT_SOURCE_DIR}/debian/automotive-message-broker-plugins-bluemonkey.debian.install
+ ${CMAKE_SOURCE_DIR}/debian/automotive-message-broker-plugins-bluemonkey.install @ONLY)
+ configure_file (${CMAKE_CURRENT_SOURCE_DIR}/debian/automotive-message-broker-plugins-bluetooth.debian.install
+ ${CMAKE_SOURCE_DIR}/debian/automotive-message-broker-plugins-bluetooth.install @ONLY)
+ configure_file (${CMAKE_CURRENT_SOURCE_DIR}/debian/automotive-message-broker-plugins-qtmainloop.debian.install
+ ${CMAKE_SOURCE_DIR}/debian/automotive-message-broker-plugins-qtmainloop.install @ONLY)
endif(debuild)
debian/tmp/@PLUGIN_INSTALL_PATH@/bluemonkeyplugin.so
debian/tmp/@PLUGIN_INSTALL_PATH@/bluemonkeyDbModule.so
+debian/tmp/@PLUGIN_INSTALL_PATH@/bluemonkeyDBusModule.so
debian/tmp/etc/ambd/bluemonkey/config.js
+debian/tmp/etc/ambd/plugins.d/bluemonkey
--- /dev/null
+debian/tmp/@PLUGIN_INSTALL_PATH@/bluetoothplugin.so
+debian/tmp/usr/bin/testAmbBt
+
Section: Utilities
Priority: extra
Maintainer: Kevron Rees <tripzero.kev@gmail.com>
-Build-Depends: build-essential, debhelper (>= 8.0.0), cdbs, pkg-config, libltdl-dev, cmake, libboost-dev, uuid-dev, libjson-c-dev, libglib2.0-dev, qtbase5-dev
+Build-Depends: build-essential, debhelper (>= 8.0.0), cdbs, pkg-config, libltdl-dev, cmake, libboost-dev, uuid-dev, libglib2.0-dev, qtbase5-dev
Standards-Version: 3.9.2
Homepage: https://01.org/automotive-message-broker
Vcs-Git: git@github.com:otcshare/automotive-message-broker.git
Vehicle data abstraction and multiplexing daemon implemented as
plugin framework that communicates to OBDII and GPS devices
-Package: automotive-message-broker-plugins-bluemonkey
+Package: automotive-message-broker-plugins-qtmainloop
Architecture: i386
Version: @PROJECT_VERSION@
Depends: ${shlibs:Depends}, ${misc:Depends}, libamb
Vehicle data abstraction and multiplexing daemon implemented as
plugin framework that communicates to OBDII and GPS devices
+Package: automotive-message-broker-plugins-bluemonkey
+Architecture: i386
+Version: @PROJECT_VERSION@
+Depends: ${shlibs:Depends}, ${misc:Depends}, libamb, automotive-message-broker-plugins-qtmainloop
+Description: Vehicle data abstraction and multiplexing daemon
+ Vehicle data abstraction and multiplexing daemon implemented as
+ plugin framework that communicates to OBDII and GPS devices
+
+Package: automotive-message-broker-plugins-bluetooth
+Architecture: i386
+Version: @PROJECT_VERSION@
+Depends: ${shlibs:Depends}, ${misc:Depends}, libamb, automotive-message-broker-plugins-qtmainloop
+Description: Vehicle data abstraction and multiplexing daemon
+ Vehicle data abstraction and multiplexing daemon implemented as
+ plugin framework that communicates to OBDII and GPS devices
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/cmake.mk
+DEB_CMAKE_NORMAL_ARGS += -Dbluemonkey_plugin=ON -Dbluetooth_plugin=ON -Dqtmainloop=ON
+DEB_BUILD_OPTIONS += parallel=8
add_executable(testAmbBt testAmbBt.cpp bluetoothplugin.cpp)
target_link_libraries(testAmbBt ${link_libraries} amb -L${CMAKE_CURRENT_BINARY_DIR}/lib amb-plugins-common -L${CMAKE_CURRENT_BINARY_DIR}/plugins/common ${QT_LIBRARIES})
+install (TARGETS testAmbBt RUNTIME DESTINATION bin)
+
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/bluetooth.in.json ${CMAKE_CURRENT_BINARY_DIR}/bluetooth @ONLY)
+install (FILES ${CMAKE_CURRENT_BINARY_DIR}/bluetooth DESTINATION ${PLUGIN_SEGMENT_INSTALL_PATH})
+
endif(bluetooth_plugin)
--- /dev/null
+{
+ "name" : "Bluetooth",
+ "path" : "@PLUGIN_INSTALL_PATH@/bluetoothplugin.so",
+ "enabled" : false
+}
*/
#include "bluetoothplugin.h"
-#include "timestamp.h"
-#include "listplusplus.h"
+
+#include <timestamp.h>
+#include <listplusplus.h>
+#include <bluetooth5.h>
#include <iostream>
#include <boost/assert.hpp>
return false;
}
- BluetoothSinkPlugin* p = static_cast<BluetoothSinkPlugin*>(data);
+ AbstractBluetoothSerialProfile* p = static_cast<AbstractBluetoothSerialProfile*>(data);
p->canHasData();
{
DebugOut(DebugOut::Error)<<"RegisterProfile call failed: "<<reply.error().message().toStdString()<<endl;
}
+
+}
+
+void AbstractBluetoothSerialProfile::connect(string hwaddy)
+{
+ std::string device = findDevice(hwaddy);
+
+ if(device.empty())
+ {
+ DebugOut(DebugOut::Error) << "could not find device with address: " << hwaddy << endl;
+ return;
+ }
+
+ QDBusInterface deviceManager("org.bluez", device.c_str(), "org.bluez.Device1", QDBusConnection::systemBus());
+
+ if(!deviceManager.isValid())
+ {
+ DebugOut(DebugOut::Error) << "could not create DBus interface for device with address '"
+ << hwaddy <<"' " << deviceManager.lastError().message().toStdString() << endl;
+ return;
+ }
+
+ QDBusPendingCall reply = deviceManager.asyncCall("Connect");
+
+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
+
+ QObject::connect(watcher, &QDBusPendingCallWatcher::finished, [](auto call)
+ {
+ QDBusPendingReply<void> reply = *call;
+ if(reply.isError())
+ {
+ DebugOut(DebugOut::Error) << "Connecting: " << reply.error().message().toStdString() << endl;
+ }
+ });
+
}
void AbstractBluetoothSerialProfile::release()
DebugOut()<<"new Connection! Path: "<<path<<" fd: "<<fd.fileDescriptor()<<endl;
socket.setDescriptor(fd.fileDescriptor());
- socket.write("ping");
GIOChannel *chan = g_io_channel_unix_new(socket.fileDescriptor());
g_io_add_watch(chan, GIOCondition(G_IO_IN | G_IO_HUP | G_IO_ERR),(GIOFunc)readCallback, this);
dataReceived(data);
}
+void AbstractBluetoothSerialProfile::write(const std::string & data)
+{
+ socket.write(data);
+}
+
BtProfileAdaptor::BtProfileAdaptor(AbstractBluetoothSerialProfile *parent)
:QDBusAbstractAdaptor(parent), mParent(parent)
{
public:
AbstractBluetoothSerialProfile(QString role = "server");
+ virtual void connect(std::string hwaddy);
+
virtual void release();
virtual void newConnection(std::string path, QDBusUnixFileDescriptor fd, QVariantMap props);
virtual void canHasData();
+ void write(const string & data);
+
protected:
- virtual void dataReceived(QByteArray data) = 0;
+ virtual void connected() {}
+ virtual void disconnected() {}
+ virtual void dataReceived(QByteArray data) {}
SerialPort socket;
private:
-#include <bluetooth.hpp>
+#include <bluetooth5.h>
#include <debugout.h>
#include <QCoreApplication>
#include <QJsonDocument>
#include "bluetoothplugin.h"
-class Bluetooth5: public AbstractBluetoothSerialProfile
+class BluetoothSerialClient: public AbstractBluetoothSerialProfile
{
public:
- Bluetooth5(): AbstractBluetoothSerialProfile("client") {}
+ BluetoothSerialClient(): AbstractBluetoothSerialProfile("client") {}
+
+ void connected()
+ {
+
+ }
+
+ void disconnected()
+ {
+
+ }
+
void dataReceived(QByteArray d)
{
qDebug()<<"data: "<< d;
qDebug()<<"connecting to: "<<addy;
- Bluetooth5 client;
+ BluetoothSerialClient client;
+
+ client.connect(addy.toStdString());
app.exec();
setProperty
};
-std::string findDevice(std::string address, std::string adapterPath="")
+std::string findDevice(std::string address, std::string adapterPath)
{
std::string objectPath;
typedef std::function<void(int)> ConnectedCallback;
+std::string findDevice(std::string address, std::string adapterPath="");
+
class Bluetooth5
{
public: