[Packaging][Deb] - More packaging
authorKevron Rees <kevron.m.rees@intel.com>
Tue, 20 Jan 2015 00:47:45 +0000 (16:47 -0800)
committerKevron Rees <kevron.m.rees@intel.com>
Tue, 20 Jan 2015 00:47:45 +0000 (16:47 -0800)
15 files changed:
ambd/CMakeLists.txt
examples/CMakeLists.txt
examples/bluetooth.in.json [new file with mode: 0644]
packaging.in/CMakeLists.txt
packaging.in/debian/automotive-message-broker-plugins-bluemonkey.debian.install
packaging.in/debian/automotive-message-broker-plugins-bluetooth.debian.install [new file with mode: 0644]
packaging.in/debian/control.debian.in
packaging.in/debian/rules
plugins/bluetooth/CMakeLists.txt
plugins/bluetooth/bluetooth.in.json [new file with mode: 0644]
plugins/bluetooth/bluetoothplugin.cpp
plugins/bluetooth/bluetoothplugin.h
plugins/bluetooth/testAmbBt.cpp
plugins/common/bluetooth5.cpp
plugins/common/bluetooth5.h

index 7009145..4c66e05 100644 (file)
@@ -1,6 +1,8 @@
 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")
@@ -32,7 +34,7 @@ endif(qtmainloop)
 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)
 
index 1100120..5437a9f 100644 (file)
@@ -10,7 +10,8 @@ set(amb_examples ${CMAKE_CURRENT_BINARY_DIR}/configwheel
                                 ${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)
@@ -28,6 +29,7 @@ configure_file (${CMAKE_CURRENT_SOURCE_DIR}/databasewebsocketsink.in.json ${CMAK
 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)
diff --git a/examples/bluetooth.in.json b/examples/bluetooth.in.json
new file mode 100644 (file)
index 0000000..30674b9
--- /dev/null
@@ -0,0 +1,17 @@
+{
+       "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"
+               }
+       ]
+}
+
index 7ead021..b4ecbcb 100644 (file)
@@ -15,5 +15,10 @@ if(debuild)
   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)
index 1b94378..9e14b1d 100644 (file)
@@ -1,3 +1,5 @@
 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
diff --git a/packaging.in/debian/automotive-message-broker-plugins-bluetooth.debian.install b/packaging.in/debian/automotive-message-broker-plugins-bluetooth.debian.install
new file mode 100644 (file)
index 0000000..409d1ab
--- /dev/null
@@ -0,0 +1,3 @@
+debian/tmp/@PLUGIN_INSTALL_PATH@/bluetoothplugin.so
+debian/tmp/usr/bin/testAmbBt
+
index e2e3321..b4d6b5f 100644 (file)
@@ -2,7 +2,7 @@ Source: automotive-message-broker
 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
@@ -40,7 +40,7 @@ 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-bluemonkey
+Package: automotive-message-broker-plugins-qtmainloop
 Architecture: i386
 Version: @PROJECT_VERSION@
 Depends: ${shlibs:Depends}, ${misc:Depends}, libamb
@@ -48,4 +48,19 @@ 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-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
 
index b5f12a4..451f74a 100755 (executable)
@@ -17,3 +17,5 @@ export DH_VERBOSE=1
 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
index 4197370..af9f7c3 100644 (file)
@@ -30,4 +30,10 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ambbt.conf DESTINATION /etc/dbus-1/sys
 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)
diff --git a/plugins/bluetooth/bluetooth.in.json b/plugins/bluetooth/bluetooth.in.json
new file mode 100644 (file)
index 0000000..b6e8b86
--- /dev/null
@@ -0,0 +1,5 @@
+{
+       "name" : "Bluetooth",
+       "path" : "@PLUGIN_INSTALL_PATH@/bluetoothplugin.so",
+       "enabled" : false
+}
index ddfdcaa..600467b 100644 (file)
@@ -17,8 +17,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */
 
 #include "bluetoothplugin.h"
-#include "timestamp.h"
-#include "listplusplus.h"
+
+#include <timestamp.h>
+#include <listplusplus.h>
+#include <bluetooth5.h>
 
 #include <iostream>
 #include <boost/assert.hpp>
@@ -51,7 +53,7 @@ bool readCallback(GIOChannel *source, GIOCondition condition, gpointer data)
                return false;
        }
 
-       BluetoothSinkPlugin* p = static_cast<BluetoothSinkPlugin*>(data);
+       AbstractBluetoothSerialProfile* p = static_cast<AbstractBluetoothSerialProfile*>(data);
 
        p->canHasData();
 
@@ -109,6 +111,41 @@ AbstractBluetoothSerialProfile::AbstractBluetoothSerialProfile(QString r)
        {
                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()
@@ -121,7 +158,6 @@ void AbstractBluetoothSerialProfile::newConnection(string path, QDBusUnixFileDes
        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);
@@ -144,6 +180,11 @@ void AbstractBluetoothSerialProfile::canHasData()
        dataReceived(data);
 }
 
+void AbstractBluetoothSerialProfile::write(const std::string & data)
+{
+       socket.write(data);
+}
+
 BtProfileAdaptor::BtProfileAdaptor(AbstractBluetoothSerialProfile *parent)
        :QDBusAbstractAdaptor(parent), mParent(parent)
 {
index 8c0bc98..e7d42a7 100644 (file)
@@ -61,6 +61,8 @@ class AbstractBluetoothSerialProfile: public QObject
 public:
        AbstractBluetoothSerialProfile(QString role = "server");
 
+       virtual void connect(std::string hwaddy);
+
        virtual void release();
 
        virtual void newConnection(std::string path, QDBusUnixFileDescriptor fd, QVariantMap props);
@@ -69,8 +71,12 @@ public:
 
        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:
index 7b078a2..296edbc 100644 (file)
@@ -1,4 +1,4 @@
-#include <bluetooth.hpp>
+#include <bluetooth5.h>
 #include <debugout.h>
 #include <QCoreApplication>
 #include <QJsonDocument>
@@ -7,10 +7,21 @@
 
 #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;
@@ -27,7 +38,9 @@ int main(int argc, char** argv)
 
        qDebug()<<"connecting to: "<<addy;
 
-       Bluetooth5 client;
+       BluetoothSerialClient client;
+
+       client.connect(addy.toStdString());
 
        app.exec();
 
index f836b42..c2c6327 100644 (file)
@@ -116,7 +116,7 @@ static const GDBusInterfaceVTable interfaceVTable =
        setProperty
 };
 
-std::string findDevice(std::string address, std::string adapterPath="")
+std::string findDevice(std::string address, std::string adapterPath)
 {
        std::string objectPath;
 
index d737d52..4dd698e 100644 (file)
@@ -7,6 +7,8 @@
 
 typedef std::function<void(int)> ConnectedCallback;
 
+std::string findDevice(std::string address, std::string adapterPath="");
+
 class Bluetooth5
 {
 public: