diff --git a/hive/.gitignore b/hive/.gitignore deleted file mode 100644 index 996b5cc7..00000000 --- a/hive/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -.directory -*.user -*~ -Makefile -build -moc -.make.cache -rcc - diff --git a/hive/client/client.pro b/hive/client/client.pro deleted file mode 100644 index f6448645..00000000 --- a/hive/client/client.pro +++ /dev/null @@ -1,5 +0,0 @@ -TEMPLATE = subdirs - -CONFIG = ordered - -SUBDIRS += hive_client diff --git a/hive/client/hive_client/hive_client.desktop b/hive/client/hive_client/hive_client.desktop deleted file mode 100644 index 9771241c..00000000 --- a/hive/client/hive_client/hive_client.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=hive_client -Exec=/opt/hive_client/bin/hive_client -Icon=hive_client64 -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/hive/client/hive_client/hive_client.pro b/hive/client/hive_client/hive_client.pro deleted file mode 100644 index 8125ebad..00000000 --- a/hive/client/hive_client/hive_client.pro +++ /dev/null @@ -1,46 +0,0 @@ -# Add more folders to ship with the application, here -folder_01.source = qml/hive_client -folder_01.target = qml -DEPLOYMENTFOLDERS = folder_01 - -QT += core qml quick declarative - - -# Additional import path used to resolve QML modules in Creator's code model -QML_IMPORT_PATH = -# If your application uses the Qt Mobility libraries, uncomment the following -# lines and add the respective components to the MOBILITY variable. -# CONFIG += mobility -# MOBILITY += - -# The .cpp file which was generated for your project. Feel free to hack it. -SOURCES += main.cpp \ - hiveclientcore.cpp \ - settings.cpp \ - sensormodel.cpp - -HEADERS += \ - hiveclientcore.h \ - settings.h \ - sensormodel.h - - -# Installation path -# target.path = - -# Please do not modify the following two lines. Required for deployment. -include(qtquick2applicationviewer/qtquick2applicationviewer.pri) -qtcAddDeployment() - - - -win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../libhive/release/ -llibhive -else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../libhive/debug/ -llibhive -else:unix: LIBS += -L$$OUT_PWD/../../libhive/ -llibhive - -INCLUDEPATH += $$PWD/../../libhive -DEPENDPATH += $$PWD/../../libhive - -win32:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../libhive/release/libhive.lib -else:win32:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../libhive/debug/libhive.lib -else:unix: PRE_TARGETDEPS += $$OUT_PWD/../../libhive/liblibhive.a diff --git a/hive/client/hive_client/hive_client64.png b/hive/client/hive_client/hive_client64.png deleted file mode 100644 index 707d5c4e..00000000 Binary files a/hive/client/hive_client/hive_client64.png and /dev/null differ diff --git a/hive/client/hive_client/hive_client80.png b/hive/client/hive_client/hive_client80.png deleted file mode 100644 index 6ad8096c..00000000 Binary files a/hive/client/hive_client/hive_client80.png and /dev/null differ diff --git a/hive/client/hive_client/hive_client_harmattan.desktop b/hive/client/hive_client/hive_client_harmattan.desktop deleted file mode 100644 index e98d6f84..00000000 --- a/hive/client/hive_client/hive_client_harmattan.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=hive_client -Exec=/usr/bin/single-instance /opt/hive_client/bin/hive_client -Icon=/usr/share/icons/hicolor/80x80/apps/hive_client80.png -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/hive/client/hive_client/hiveclientcore.cpp b/hive/client/hive_client/hiveclientcore.cpp deleted file mode 100644 index 54e83aec..00000000 --- a/hive/client/hive_client/hiveclientcore.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "hiveclientcore.h" -#include -#include -#include - -HiveClientCore::HiveClientCore(QObject *parent) : - QObject(parent) -{ - - m_client = new Client(this); - - - // QML Typs - qmlRegisterType("hive",1,0,"Settings"); - - // QML application window - m_engine = new QQmlApplicationEngine(this); - m_engine->load(QUrl("qml/hive_client/main.qml")); - - m_engine->rootContext()->setContextProperty("client", m_client); - - topLevel = m_engine->rootObjects().value(0); - QQuickWindow *window = qobject_cast(topLevel); - window->show(); - - -} - diff --git a/hive/client/hive_client/hiveclientcore.h b/hive/client/hive_client/hiveclientcore.h deleted file mode 100644 index 597bdbdf..00000000 --- a/hive/client/hive_client/hiveclientcore.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef HIVECLIENTCORE_H -#define HIVECLIENTCORE_H - -#include -#include - -#include "client.h" -#include "settings.h" - -class HiveClientCore : public QObject -{ - Q_OBJECT -public: - explicit HiveClientCore(QObject *parent = 0); - -private: - Client *m_client; - //Settings *m_settings; - - QQmlApplicationEngine *m_engine; - QObject *topLevel; - -private slots: - -signals: - -public slots: - -}; - -#endif // HIVECLIENTCORE_H diff --git a/hive/client/hive_client/main.cpp b/hive/client/hive_client/main.cpp deleted file mode 100644 index dce16a59..00000000 --- a/hive/client/hive_client/main.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include "hiveclientcore.h" -#include "usb.h" - -int main(int argc, char *argv[]) -{ - QGuiApplication app(argc, argv); - - HiveClientCore core; - - return app.exec(); -} diff --git a/hive/client/hive_client/qml/hive_client/AddDevicePage.qml b/hive/client/hive_client/qml/hive_client/AddDevicePage.qml deleted file mode 100644 index 3cea9a7d..00000000 --- a/hive/client/hive_client/qml/hive_client/AddDevicePage.qml +++ /dev/null @@ -1,163 +0,0 @@ -import QtQuick 2.0 -import QtQuick.Controls 1.0 -import QtQuick.Layouts 1.0 - -Component { - - Rectangle{ - color: "black" - ColumnLayout{ - id: addDeviceColumn - anchors.left: parent.left - anchors.leftMargin: 30 - anchors.right: parent.right - anchors.rightMargin: 30 - GroupBox{ - id: nameGroupBox - anchors.left: parent.left - anchors.right: parent.right - title: "Name" - - Row{ - id: row1 - spacing: 5 - - Label{ - id: nameLabel - anchors.verticalCenter: parent.verticalCenter - text: "Name:" - color: "white" - } - - TextField{ - id: nameTextField - implicitWidth: 300 - anchors.verticalCenter: parent.verticalCenter - placeholderText: "Device Name" - } - } - - } - GroupBox{ - id: deviceTypeGroupBox - anchors.left: parent.left - anchors.leftMargin: 0 - anchors.right: parent.right - anchors.rightMargin: 0 - title: "Device Type" - - ComboBox { - id: deviceComboBox - model: ["device","actor","sensor"] - } - } - GroupBox{ - id: communicationTypeGroupBox - anchors.left: parent.left - anchors.leftMargin: 0 - anchors.right: parent.right - anchors.rightMargin: 0 - title: "Communication Type" - - ComboBox { - id: communicationTypeComboBox - model: ["RC433","RC868","ZigBee"] - } - } - GroupBox{ - id: linecodeGroupBox - anchors.left: parent.left - anchors.leftMargin: 0 - anchors.right: parent.right - anchors.rightMargin: 0 - title: "Linecode" - visible: communicationTypeComboBox.currentText == "RC868" || communicationTypeComboBox.currentText == "RC433" ? true : false - - ComboBox { - id: linecodeComboBox - model: ["Switch","Light","Unicode","Manchester","Differential Manchester"] - } - } - GroupBox{ - id: switchGroupBox - anchors.left: parent.left - anchors.leftMargin: 0 - anchors.right: parent.right - anchors.rightMargin: 0 - title: "Switchsettings" - visible: (linecodeComboBox.currentText == "Switch") && (communicationTypeComboBox.currentText == "RC868" || communicationTypeComboBox.currentText == "RC433") ? true : false - - RowLayout{ - GridLayout{ - columns: 5 - Label{ - text: "1" - color: "white" - } - Label{ - text: "2" - color: "white" - } - Label{ - text: "3" - color: "white" - } - Label{ - text: "4" - color: "white" - } - Label{ - text: "5" - color: "white" - } - CheckBox{ - id: channel1 - } - CheckBox{ - id: channel2 - } - CheckBox{ - id: channel3 - } - CheckBox{ - id: channel4 - } - CheckBox{ - id: channel5 - } - } - ComboBox { - id: switchComboBox - model: ["A","B","C","D","E"] - } - } - } - } - Button{ - id: cancelButton - anchors.left: parent.left - anchors.leftMargin: 30 - anchors.bottom: parent.bottom - anchors.bottomMargin: 10 - - text: "Cancel" - onClicked: stackView.pop(this) - - } - Button{ - id: saveButton - anchors.right: parent.right - anchors.rightMargin: 30 - anchors.bottom: parent.bottom - anchors.bottomMargin: 10 - - text: "Save" - onClicked: { - var deviceType = deviceComboBox.currentText - var method = "add" - // TODO: variant map...to send hive the correct add command with all parameters - stackView.pop(this) - } - } - } -} diff --git a/hive/client/hive_client/qml/hive_client/ConnectionPage.qml b/hive/client/hive_client/qml/hive_client/ConnectionPage.qml deleted file mode 100644 index 12c194f4..00000000 --- a/hive/client/hive_client/qml/hive_client/ConnectionPage.qml +++ /dev/null @@ -1,57 +0,0 @@ -import QtQuick 2.0 -import QtQuick.Controls 1.0 -import QtQuick.Layouts 1.0 - -Component { - Rectangle{ - focus: connectButton.forceActiveFocus() - color: "black" - - GroupBox { - id: connectionGroupBox - anchors.centerIn: parent - - title: "Connection" - - RowLayout{ - anchors.fill: parent - Button{ - id: connectButton - text: "Connect" - onClicked: { - settings.ipaddress = ipTextInput.text - settings.port = portTextInput.text - client.connectToHost(ipTextInput.text,portTextInput.text) - } - } - Text { - id: ipLable - text: "IP:" - color: "white" - horizontalAlignment: Text.AlignHCenter - } - TextField { - id: ipTextInput - text: settings.ipaddress - horizontalAlignment: TextInput.AlignHCenter - font.pointSize: 9 - } - Text { - id: portLable - text: "Port:" - color: "white" - wrapMode: Text.NoWrap - verticalAlignment: Text.AlignTop - horizontalAlignment: Text.AlignHCenter - } - TextField { - id: portTextInput - text: settings.port - horizontalAlignment: TextInput.AlignHCenter - font.pointSize: 9 - } - } - } - - } -} diff --git a/hive/client/hive_client/qml/hive_client/MainMenuButton.qml b/hive/client/hive_client/qml/hive_client/MainMenuButton.qml deleted file mode 100644 index 4b86ec72..00000000 --- a/hive/client/hive_client/qml/hive_client/MainMenuButton.qml +++ /dev/null @@ -1,89 +0,0 @@ -import QtQuick 2.0 -import QtGraphicalEffects 1.0 -Rectangle { - id: buttonRectangle - - width: 300 - height: 200 - - property string text - signal clicked() - - color: "black" - - RectangularGlow { - id: effect - anchors.fill: rect - glowRadius: rectMouseArea.pressed ? 18 : 10 - spread: 0.4 - color: "steelblue" - cornerRadius: rect.radius + glowRadius - } - - Rectangle { - id: rect - color: "#ed000000" - anchors.centerIn: parent - anchors.fill: parent - anchors.margins: 20 - radius: 25 - border.width: 5 - border.color: "#000000" - opacity: 1 - - Text{ - id: buttonText - anchors.centerIn: parent - - color: "#ffffff" - styleColor: "#ffffff" - horizontalAlignment: Text.AlignHCenter - font.pointSize: 20 - font.family: "Arial" - font.bold: true - text: buttonRectangle.text - } - - MouseArea{ - id: rectMouseArea - anchors.fill: parent - onClicked: { - buttonRectangle.clicked() - } - } - } - -} - - - - -//import QtQuick 2.0 - -//Rectangle{ -// id: buttonRectangle - -// property string text -// signal clicked() - -// color: buttonMousArea.pressed ? "lightsteelblue" : "steelblue" -// border.width: buttonMousArea.pressed ? 4 : 2 -// border.color: "black" -// radius: 10 - -// Text{ -// id: buttonText -// anchors.centerIn: parent -// text: buttonRectangle.text -// } -// MouseArea{ -// id: buttonMousArea -// anchors.fill: parent -// onClicked: { -// buttonRectangle.clicked() -// } -// } - -//} - - diff --git a/hive/client/hive_client/qml/hive_client/MainPage.qml b/hive/client/hive_client/qml/hive_client/MainPage.qml deleted file mode 100644 index 67147bfe..00000000 --- a/hive/client/hive_client/qml/hive_client/MainPage.qml +++ /dev/null @@ -1,31 +0,0 @@ -import QtQuick 2.0 -import QtQuick.Controls 1.0 -import QtQuick.Layouts 1.0 - -Component { - - Rectangle{ - color: "black" - Column{ - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: parent.top - anchors.topMargin: 30 - spacing: 20 - - - MainMenuButton{ - text: "Add device" - onClicked: stackView.push(addDevicePage) - } - MainMenuButton{ - text: "Temperatur" - onClicked: stackView.push(temperaturPage) - } - - - } - - - } - -} diff --git a/hive/client/hive_client/qml/hive_client/SensorField.qml b/hive/client/hive_client/qml/hive_client/SensorField.qml deleted file mode 100644 index 44a6db03..00000000 --- a/hive/client/hive_client/qml/hive_client/SensorField.qml +++ /dev/null @@ -1,28 +0,0 @@ -import QtQuick 2.0 -import QtGraphicalEffects 1.0 - -Rectangle { - - RectangularGlow { - id: effect - anchors.fill: rect - glowRadius: rectMouseArea.pressed ? 18 : 10 - spread: 0.4 - color: "steelblue" - cornerRadius: rect.radius + glowRadius - } - - Rectangle { - id: rect - color: "black" - anchors.centerIn: parent - anchors.fill: parent - anchors.margins: 20 - radius: 25 - - MouseArea{ - id: rectMouseArea - anchors.fill: parent - } - } -} diff --git a/hive/client/hive_client/qml/hive_client/TemperaturePage.qml b/hive/client/hive_client/qml/hive_client/TemperaturePage.qml deleted file mode 100644 index 180ba516..00000000 --- a/hive/client/hive_client/qml/hive_client/TemperaturePage.qml +++ /dev/null @@ -1,63 +0,0 @@ -import QtQuick 2.0 -import QtQuick.Controls 1.0 -import QtGraphicalEffects 1.0 - -Component { - - Rectangle{ - color: "black" - - RectangularGlow { - id: effect - anchors.fill: rect - glowRadius: 18 - spread: 0.4 - color: "steelblue" - cornerRadius: rect.radius + glowRadius - } - - Rectangle{ - id: rect - anchors.fill: parent - anchors.margins: 70 - color: "black" - radius: 30 - Canvas { - anchors.fill: parent - contextType: "2d" - - Path{ - id: myPath - startX: 0; startY: 100 - - PathCurve { x: 75; y: 75 } - PathCurve { x: 200; y: 150 } - PathCurve { x: 325; y: 25 } - PathCurve { x: 400; y: 100 } - PathCurve { x: 500; y: 100 } - PathCurve { x: 600; y: 100 } - PathCurve { x: 700; y: 300 } - } - onPaint: { - context.strokeStyle = Qt.rgba(.4,.6,.8); - context.path = myPath; - context.stroke(); - } - } - - } - - Button{ - id: cancelButton - anchors.left: parent.left - anchors.leftMargin: 30 - anchors.bottom: parent.bottom - anchors.bottomMargin: 10 - - text: "Cancel" - onClicked: stackView.pop(this) - - } - - } -} diff --git a/hive/client/hive_client/qml/hive_client/main.qml b/hive/client/hive_client/qml/hive_client/main.qml deleted file mode 100644 index 7c179bda..00000000 --- a/hive/client/hive_client/qml/hive_client/main.qml +++ /dev/null @@ -1,78 +0,0 @@ -import QtQuick 2.0 -import QtQuick.Controls 1.0 -import QtQuick.Layouts 1.0 - -import hive 1.0 - -ApplicationWindow{ - id: mainWindow - menuBar: MenuBar{ - id: mainWindowMenuBar - Menu { - title: "File" - MenuItem { - text: "Close" - shortcut: "Ctrl+Q" - onTriggered: mainWindow.close() - } - MenuItem { - text: "Disconnect" - shortcut: "Ctrl+D" - onTriggered: client.disconnectFromHost() - } - } - } - statusBar: StatusBar { - id: statusBar - anchors.right: parent.right - anchors.left: parent.left - anchors.bottom: parent.bottom - } - title: "Hive Client" - minimumWidth: 800 - minimumHeight: 600 - - - StackView { - id: stackView - anchors.fill: parent - initialItem: connectionPage - } - - Connections{ - target: client - onConnectionChanged:{ - print("connection changed",client.isConnected) - if(client.isConnected){ - stackView.push(mainPage) - }else{ - stackView.clear() - stackView.push(connectionPage) - } - } - } - - Settings{ - id: settings - } - - ConnectionPage{ - id: connectionPage - } - - MainPage{ - id: mainPage - } - - AddDevicePage{ - id: addDevicePage - } - TemperaturePage{ - id: temperaturPage - } - - -} - - - diff --git a/hive/client/hive_client/qtquick2applicationviewer/qtquick2applicationviewer.cpp b/hive/client/hive_client/qtquick2applicationviewer/qtquick2applicationviewer.cpp deleted file mode 100644 index 10709d7a..00000000 --- a/hive/client/hive_client/qtquick2applicationviewer/qtquick2applicationviewer.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// checksum 0x4f6f version 0x90005 -/* - This file was generated by the Qt Quick 2 Application wizard of Qt Creator. - QtQuick2ApplicationViewer is a convenience class containing mobile device specific - code such as screen orientation handling. Also QML paths and debugging are - handled here. - It is recommended not to modify this file, since newer versions of Qt Creator - may offer an updated version of it. -*/ - -#include "qtquick2applicationviewer.h" - -#include -#include -#include - -class QtQuick2ApplicationViewerPrivate -{ - QString mainQmlFile; - friend class QtQuick2ApplicationViewer; - static QString adjustPath(const QString &path); -}; - -QString QtQuick2ApplicationViewerPrivate::adjustPath(const QString &path) -{ -#if defined(Q_OS_MAC) - if (!QDir::isAbsolutePath(path)) - return QString::fromLatin1("%1/../Resources/%2") - .arg(QCoreApplication::applicationDirPath(), path); -#elif defined(Q_OS_BLACKBERRY) - if (!QDir::isAbsolutePath(path)) - return QString::fromLatin1("app/native/%1").arg(path); -#elif !defined(Q_OS_ANDROID) - QString pathInInstallDir = - QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); - if (QFileInfo(pathInInstallDir).exists()) - return pathInInstallDir; - pathInInstallDir = - QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); - if (QFileInfo(pathInInstallDir).exists()) - return pathInInstallDir; -#endif - return path; -} - -QtQuick2ApplicationViewer::QtQuick2ApplicationViewer(QWindow *parent) - : QQuickView(parent) - , d(new QtQuick2ApplicationViewerPrivate()) -{ - connect(engine(), SIGNAL(quit()), SLOT(close())); - setResizeMode(QQuickView::SizeRootObjectToView); -} - -QtQuick2ApplicationViewer::~QtQuick2ApplicationViewer() -{ - delete d; -} - -void QtQuick2ApplicationViewer::setMainQmlFile(const QString &file) -{ - d->mainQmlFile = QtQuick2ApplicationViewerPrivate::adjustPath(file); -#ifdef Q_OS_ANDROID - setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); -#else - setSource(QUrl::fromLocalFile(d->mainQmlFile)); -#endif -} - -void QtQuick2ApplicationViewer::addImportPath(const QString &path) -{ - engine()->addImportPath(QtQuick2ApplicationViewerPrivate::adjustPath(path)); -} - -void QtQuick2ApplicationViewer::showExpanded() -{ -#if defined(Q_WS_SIMULATOR) || defined(Q_OS_QNX) - showFullScreen(); -#else - show(); -#endif -} diff --git a/hive/client/hive_client/qtquick2applicationviewer/qtquick2applicationviewer.h b/hive/client/hive_client/qtquick2applicationviewer/qtquick2applicationviewer.h deleted file mode 100644 index cf66f140..00000000 --- a/hive/client/hive_client/qtquick2applicationviewer/qtquick2applicationviewer.h +++ /dev/null @@ -1,33 +0,0 @@ -// checksum 0xfde6 version 0x90005 -/* - This file was generated by the Qt Quick 2 Application wizard of Qt Creator. - QtQuick2ApplicationViewer is a convenience class containing mobile device specific - code such as screen orientation handling. Also QML paths and debugging are - handled here. - It is recommended not to modify this file, since newer versions of Qt Creator - may offer an updated version of it. -*/ - -#ifndef QTQUICK2APPLICATIONVIEWER_H -#define QTQUICK2APPLICATIONVIEWER_H - -#include - -class QtQuick2ApplicationViewer : public QQuickView -{ - Q_OBJECT - -public: - explicit QtQuick2ApplicationViewer(QWindow *parent = 0); - virtual ~QtQuick2ApplicationViewer(); - - void setMainQmlFile(const QString &file); - void addImportPath(const QString &path); - - void showExpanded(); - -private: - class QtQuick2ApplicationViewerPrivate *d; -}; - -#endif // QTQUICK2APPLICATIONVIEWER_H diff --git a/hive/client/hive_client/qtquick2applicationviewer/qtquick2applicationviewer.pri b/hive/client/hive_client/qtquick2applicationviewer/qtquick2applicationviewer.pri deleted file mode 100644 index e5f7990f..00000000 --- a/hive/client/hive_client/qtquick2applicationviewer/qtquick2applicationviewer.pri +++ /dev/null @@ -1,180 +0,0 @@ -# checksum 0x7b0d version 0x90005 -# This file was generated by the Qt Quick 2 Application wizard of Qt Creator. -# The code below adds the QtQuick2ApplicationViewer to the project and handles -# the activation of QML debugging. -# It is recommended not to modify this file, since newer versions of Qt Creator -# may offer an updated version of it. - -QT += qml quick - -SOURCES += $$PWD/qtquick2applicationviewer.cpp -HEADERS += $$PWD/qtquick2applicationviewer.h -INCLUDEPATH += $$PWD -# This file was generated by an application wizard of Qt Creator. -# The code below handles deployment to Android and Maemo, aswell as copying -# of the application data to shadow build directories on desktop. -# It is recommended not to modify this file, since newer versions of Qt Creator -# may offer an updated version of it. - -defineTest(qtcAddDeployment) { -for(deploymentfolder, DEPLOYMENTFOLDERS) { - item = item$${deploymentfolder} - greaterThan(QT_MAJOR_VERSION, 4) { - itemsources = $${item}.files - } else { - itemsources = $${item}.sources - } - $$itemsources = $$eval($${deploymentfolder}.source) - itempath = $${item}.path - $$itempath= $$eval($${deploymentfolder}.target) - export($$itemsources) - export($$itempath) - DEPLOYMENT += $$item -} - -MAINPROFILEPWD = $$PWD - -android-no-sdk { - for(deploymentfolder, DEPLOYMENTFOLDERS) { - item = item$${deploymentfolder} - itemfiles = $${item}.files - $$itemfiles = $$eval($${deploymentfolder}.source) - itempath = $${item}.path - $$itempath = /data/user/qt/$$eval($${deploymentfolder}.target) - export($$itemfiles) - export($$itempath) - INSTALLS += $$item - } - - target.path = /data/user/qt - - export(target.path) - INSTALLS += target -} else:android { - for(deploymentfolder, DEPLOYMENTFOLDERS) { - item = item$${deploymentfolder} - itemfiles = $${item}.files - $$itemfiles = $$eval($${deploymentfolder}.source) - itempath = $${item}.path - $$itempath = /assets/$$eval($${deploymentfolder}.target) - export($$itemfiles) - export($$itempath) - INSTALLS += $$item - } - - x86 { - target.path = /libs/x86 - } else: armeabi-v7a { - target.path = /libs/armeabi-v7a - } else { - target.path = /libs/armeabi - } - - export(target.path) - INSTALLS += target -} else:win32 { - copyCommand = - for(deploymentfolder, DEPLOYMENTFOLDERS) { - source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source) - source = $$replace(source, /, \\) - sourcePathSegments = $$split(source, \\) - target = $$OUT_PWD/$$eval($${deploymentfolder}.target)/$$last(sourcePathSegments) - target = $$replace(target, /, \\) - target ~= s,\\\\\\.?\\\\,\\, - !isEqual(source,$$target) { - !isEmpty(copyCommand):copyCommand += && - isEqual(QMAKE_DIR_SEP, \\) { - copyCommand += $(COPY_DIR) \"$$source\" \"$$target\" - } else { - source = $$replace(source, \\\\, /) - target = $$OUT_PWD/$$eval($${deploymentfolder}.target) - target = $$replace(target, \\\\, /) - copyCommand += test -d \"$$target\" || mkdir -p \"$$target\" && cp -r \"$$source\" \"$$target\" - } - } - } - !isEmpty(copyCommand) { - copyCommand = @echo Copying application data... && $$copyCommand - copydeploymentfolders.commands = $$copyCommand - first.depends = $(first) copydeploymentfolders - export(first.depends) - export(copydeploymentfolders.commands) - QMAKE_EXTRA_TARGETS += first copydeploymentfolders - } -} else:unix { - maemo5 { - desktopfile.files = $${TARGET}.desktop - desktopfile.path = /usr/share/applications/hildon - icon.files = $${TARGET}64.png - icon.path = /usr/share/icons/hicolor/64x64/apps - } else:!isEmpty(MEEGO_VERSION_MAJOR) { - desktopfile.files = $${TARGET}_harmattan.desktop - desktopfile.path = /usr/share/applications - icon.files = $${TARGET}80.png - icon.path = /usr/share/icons/hicolor/80x80/apps - } else { # Assumed to be a Desktop Unix - copyCommand = - for(deploymentfolder, DEPLOYMENTFOLDERS) { - source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source) - source = $$replace(source, \\\\, /) - macx { - target = $$OUT_PWD/$${TARGET}.app/Contents/Resources/$$eval($${deploymentfolder}.target) - } else { - target = $$OUT_PWD/$$eval($${deploymentfolder}.target) - } - target = $$replace(target, \\\\, /) - sourcePathSegments = $$split(source, /) - targetFullPath = $$target/$$last(sourcePathSegments) - targetFullPath ~= s,/\\.?/,/, - !isEqual(source,$$targetFullPath) { - !isEmpty(copyCommand):copyCommand += && - copyCommand += $(MKDIR) \"$$target\" - copyCommand += && $(COPY_DIR) \"$$source\" \"$$target\" - } - } - !isEmpty(copyCommand) { - copyCommand = @echo Copying application data... && $$copyCommand - copydeploymentfolders.commands = $$copyCommand - first.depends = $(first) copydeploymentfolders - export(first.depends) - export(copydeploymentfolders.commands) - QMAKE_EXTRA_TARGETS += first copydeploymentfolders - } - } - !isEmpty(target.path) { - installPrefix = $${target.path} - } else { - installPrefix = /opt/$${TARGET} - } - for(deploymentfolder, DEPLOYMENTFOLDERS) { - item = item$${deploymentfolder} - itemfiles = $${item}.files - $$itemfiles = $$eval($${deploymentfolder}.source) - itempath = $${item}.path - $$itempath = $${installPrefix}/$$eval($${deploymentfolder}.target) - export($$itemfiles) - export($$itempath) - INSTALLS += $$item - } - - !isEmpty(desktopfile.path) { - export(icon.files) - export(icon.path) - export(desktopfile.files) - export(desktopfile.path) - INSTALLS += icon desktopfile - } - - isEmpty(target.path) { - target.path = $${installPrefix}/bin - export(target.path) - } - INSTALLS += target -} - -export (ICON) -export (INSTALLS) -export (DEPLOYMENT) -export (LIBS) -export (QMAKE_EXTRA_TARGETS) -} diff --git a/hive/client/hive_client/sensormodel.cpp b/hive/client/hive_client/sensormodel.cpp deleted file mode 100644 index 7b69a95a..00000000 --- a/hive/client/hive_client/sensormodel.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "sensormodel.h" - -SensorModel::SensorModel(QObject *parent) : - QAbstractListModel(parent) -{ -} diff --git a/hive/client/hive_client/sensormodel.h b/hive/client/hive_client/sensormodel.h deleted file mode 100644 index af300a6c..00000000 --- a/hive/client/hive_client/sensormodel.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef SENSORMODEL_H -#define SENSORMODEL_H - -#include -#include - -class SensorModel : public QAbstractListModel -{ - Q_OBJECT -public: - explicit SensorModel(QObject *parent = 0); - -private: - - - -signals: - -public slots: - -}; - -#endif // SENSORMODEL_H diff --git a/hive/client/hive_client/settings.cpp b/hive/client/hive_client/settings.cpp deleted file mode 100644 index 2cc62e6e..00000000 --- a/hive/client/hive_client/settings.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "settings.h" -#include - -Settings::Settings(QObject *parent) : - QObject(parent) -{ -} - -QString Settings::ipaddress() const -{ - QSettings settings("hive"); - return settings.value("server","10.10.10.40").toString(); -} - -void Settings::setIPaddress(QString ipaddress) -{ - QSettings settings("hive"); - settings.setValue("server",ipaddress); - emit ipaddressChanged(); -} - -int Settings::port() const -{ - QSettings settings("hive"); - return settings.value("port","1234").toInt(); -} - -void Settings::setPort(int port) -{ - QSettings settings("hive"); - settings.setValue("port",port); - emit ipaddressChanged(); -} - diff --git a/hive/client/hive_client/settings.h b/hive/client/hive_client/settings.h deleted file mode 100644 index 7f8d7a85..00000000 --- a/hive/client/hive_client/settings.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef SETTINGS_H -#define SETTINGS_H - -#include -#include - -class Settings : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString ipaddress READ ipaddress WRITE setIPaddress NOTIFY ipaddressChanged) - Q_PROPERTY(int port READ port WRITE setPort NOTIFY portChanged) - -public: - explicit Settings(QObject *parent = 0); - - QString ipaddress() const; - void setIPaddress(QString ipaddress); - - int port() const; - void setPort(int port); - -private: - -signals: - void ipaddressChanged(); - void portChanged(); - -public slots: - - -}; - -#endif // SETTINGS_H diff --git a/hive/hive.pro b/hive/hive.pro deleted file mode 100644 index 8962e23b..00000000 --- a/hive/hive.pro +++ /dev/null @@ -1,7 +0,0 @@ -TEMPLATE = subdirs -CONFIG = ordered - -SUBDIRS += libhive server - - - diff --git a/hive/hive_client.pro b/hive/hive_client.pro deleted file mode 100644 index eccb40d1..00000000 --- a/hive/hive_client.pro +++ /dev/null @@ -1,4 +0,0 @@ -TEMPLATE = subdirs -CONFIG = ordered - -SUBDIRS += libhive client diff --git a/hive/libhive/client.cpp b/hive/libhive/client.cpp deleted file mode 100644 index a4b35f60..00000000 --- a/hive/libhive/client.cpp +++ /dev/null @@ -1,118 +0,0 @@ -#include "client.h" -#include -#include - -Client::Client(QObject *parent) : - QObject(parent) -{ - m_tcpSocket = new QTcpSocket(this); - m_connectionStatus = false; - connect(m_tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(connectionError(QAbstractSocket::SocketError))); - connect(m_tcpSocket, SIGNAL(connected()),this, SLOT(connected())); - connect(m_tcpSocket, SIGNAL(disconnected()),this, SLOT(disconneted())); -} - -bool Client::isConnected() -{ - return m_connectionStatus; -} - -void Client::connectionError(QAbstractSocket::SocketError error) -{ - qDebug() << "---> connection error:" << error; -} - -void Client::readData() -{ - QByteArray message; - while(m_tcpSocket->canReadLine()){ - QByteArray dataLine = m_tcpSocket->readLine(); - message.append(dataLine); - if(dataLine == "}\n"){ - emit dataAvailable(message); - } - } -} - -void Client::connected() -{ - qDebug() << "connected to hive server"; - m_connectionStatus = true; - emit connectionChanged(); -} - -void Client::disconneted() -{ - qDebug() << "disconnect from hive server"; - m_connectionStatus = false; - emit connectionChanged(); -} - -void Client::processData(const QByteArray &data) -{ - QJsonParseError error; - QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &error); - - if(error.error != QJsonParseError::NoError) { - qDebug() << "failed to parse data" << data << ":" << error.errorString(); - } - qDebug() << "-------------------------\n" << jsonDoc.toJson(); - - QVariantMap command = jsonDoc.toVariant().toMap(); - QVariantMap params = jsonDoc.toVariant().toMap().value("params").toMap(); - - if(command.contains("signal")){ - handleSignal(params); - }else{ - handleResponse(params); - } - -} - -void Client::handleResponse(const QVariantMap &rsp) -{ - qDebug() << "handling response" << rsp; - if(!rsp.contains("id")) { - qDebug() << "packet does not contain an id. discarding..."; - return; - } - int id = rsp.value("id").toInt(); - if(m_requestMap.contains(id)) { - switch(m_requestMap.value(id)){ - case RequestAddDevice: - qDebug() << "add device response received"; - break; - case RequestEditDevice: - qDebug() << "edit device response received"; - break; - case RequestRemoveDevice: - qDebug() << "add device response received"; - break; - - } - m_requestMap.remove(id); - } - -} - -void Client::handleSignal(const QVariantMap &signal) -{ - -} - -void Client::connectToHost(QString ipAddress, QString port) -{ - qDebug() << "connecting to" << ipAddress << ":" << port; - m_tcpSocket->connectToHost(QHostAddress(ipAddress), port.toInt()); -} - -void Client::disconnectFromHost() -{ - m_tcpSocket->close(); - qDebug() << "connection to hive server closed"; -} - -void Client::sendData(QByteArray data) -{ - m_tcpSocket->write(data); -} diff --git a/hive/libhive/client.h b/hive/libhive/client.h deleted file mode 100644 index 99ed60a6..00000000 --- a/hive/libhive/client.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef CLIENT_H -#define CLIENT_H - -#include -#include -#include - -class Client : public QObject -{ - Q_OBJECT - Q_PROPERTY(bool isConnected READ isConnected NOTIFY connectionChanged) - - -public: - explicit Client(QObject *parent = 0); - - enum Request { - RequestAddDevice, - RequestEditDevice, - RequestRemoveDevice - }; - - bool isConnected(); - -private: - QTcpSocket *m_tcpSocket; - QString m_tcpBuffer; - - bool m_connectionStatus; - int m_commandId; - - QMap m_requestMap; - - -signals: - void dataAvailable(const QByteArray &data); - void connectionChanged(); - - -private slots: - void connectionError(QAbstractSocket::SocketError error); - void readData(); - void connected(); - void disconneted(); - - void processData(const QByteArray &data); - void handleResponse(const QVariantMap &rsp); - void handleSignal(const QVariantMap &signal); - - -public slots: - void connectToHost(QString ipAddress, QString port); - void disconnectFromHost(); - void sendData(QByteArray data); -}; - -#endif // CLIENT_H diff --git a/hive/libhive/devicemanager.cpp b/hive/libhive/devicemanager.cpp deleted file mode 100644 index 07dbec85..00000000 --- a/hive/libhive/devicemanager.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "devicemanager.h" -#include - -DeviceManager::DeviceManager(QObject *parent) : - QObject(parent) -{ -} - -bool DeviceManager::saveDevice(QString deviceType, QUuid uuid, QVariantMap paramters) -{ - QSettings settings("hive"); - settings.beginGroup(deviceType); - settings.beginGroup(uuid.toString()); - QVariantMap::iterator i = paramters.begin(); - while (i!= paramters.end()){ - settings.setValue(i.key(),i.value()); - ++i; - } - settings.endGroup(); - settings.endGroup(); - return true; -} - -bool DeviceManager::deleteDevice(QString deviceType, QUuid uuid) -{ - QSettings settings("hive"); - settings.beginGroup(deviceType); - - // controll if we have a stored device with this uuid - if(!settings.childGroups().contains(uuid.toString())){ - qDebug() << "no device with uuid" << uuid.toString() << "found."; - return false; - } - settings.remove(uuid.toString()); - settings.endGroup(); - return true; -} - - - diff --git a/hive/libhive/devicemanager.h b/hive/libhive/devicemanager.h deleted file mode 100644 index 7fddac37..00000000 --- a/hive/libhive/devicemanager.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef DEVICEMANAGER_H -#define DEVICEMANAGER_H - -#include -#include -#include -#include - -class DeviceManager : public QObject -{ - Q_OBJECT -public: - explicit DeviceManager(QObject *parent = 0); - - /* deviceType - * radio - * ... - */ - - bool saveDevice(QString deviceType, QUuid uuid, QVariantMap paramters); - bool deleteDevice(QString deviceType, QUuid uuid); - - -signals: - -public slots: - -}; - -#endif // DEVICEMANAGER_H diff --git a/hive/libhive/jsonhandler.cpp b/hive/libhive/jsonhandler.cpp deleted file mode 100644 index 22e1b37d..00000000 --- a/hive/libhive/jsonhandler.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "jsonhandler.h" - -#include -#include -#include - -JsonHandler::JsonHandler(QObject *parent) : - QObject(parent) -{ - m_device = new DeviceJsonPlugin(this); - m_radio = new RadioJsonPlugin(this); -} - - - -QByteArray JsonHandler::process(const QByteArray &data) -{ - QJsonParseError error; - QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &error); - - if(error.error != QJsonParseError::NoError) { - qDebug() << "failed to parse data" << data << ":" << error.errorString(); - } - qDebug() << "-------------------------\n" << jsonDoc.toJson(); - - QVariantMap command = jsonDoc.toVariant().toMap(); - QVariantMap params = jsonDoc.toVariant().toMap().value("params").toMap(); - - //DeviceJsonPlugin plugin; - // {: "name", : "doBla", : "int", { : "name", ... }} - - if(command.value("device").toString() == m_device->deviceName()){ - return m_device->process(command,params); - } - if(command.value("device").toString() == m_radio->deviceName()){ - return m_radio->process(command,params); - }else{ - return NULL; - } - - -} - -QByteArray JsonHandler::formatResponse(const QVariantMap &command, const QVariantMap &responseParams) -{ - QVariantMap responseMap; - responseMap.insert("id", command.value("id")); - responseMap.insert("success", true); - responseMap.insert("params", responseParams); - QByteArray response = QJsonDocument::fromVariant(responseMap).toBinaryData(); - response.append(QString('\n')); - qDebug() << "ERROR response: " << response; - return response; -} - -QByteArray JsonHandler::formatErrorResponse(const QVariantMap &command, const QString &error) -{ - QVariantMap responseMap; - responseMap.insert("id", command.value("id")); - responseMap.insert("success", false); - responseMap.insert("error", error); - QByteArray response = QJsonDocument::fromVariant(responseMap).toBinaryData(); - response.append(QString('\n')); - qDebug() << "ERROR response: " << response; - return response; -} diff --git a/hive/libhive/jsonhandler.h b/hive/libhive/jsonhandler.h deleted file mode 100644 index 2a5c18d8..00000000 --- a/hive/libhive/jsonhandler.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef JSONHANDLER_H -#define JSONHANDLER_H - -#include -#include -#include -#include -#include - - -class JsonHandler : public QObject -{ - Q_OBJECT -public: - explicit JsonHandler(QObject *parent = 0); - QByteArray addRemote(QString deviceType, QString method, QString name, QString protocol, QString Linecode, QString m); - - -signals: - void notifyAll(const QByteArray &data); - - -public slots: - QByteArray process(const QByteArray &data); - -private: - DeviceJsonPlugin *m_device; - RadioJsonPlugin *m_radio; - - QByteArray formatResponse(const QVariantMap &command, const QVariantMap &responseParams); - QByteArray formatErrorResponse(const QVariantMap &command, const QString &error); - - -}; - -#endif // JSONHANDLER_H diff --git a/hive/libhive/jsonplugin/devicejsonplugin.cpp b/hive/libhive/jsonplugin/devicejsonplugin.cpp deleted file mode 100644 index ff4240b3..00000000 --- a/hive/libhive/jsonplugin/devicejsonplugin.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include "devicejsonplugin.h" -#include -#include -#include - -DeviceJsonPlugin::DeviceJsonPlugin(QObject *parent) : - JsonPlugin(parent) -{ - m_deviceManager = new DeviceManager(this); -} - -QString DeviceJsonPlugin::deviceName() -{ - QString deviceName = "device"; - return deviceName; - -} - -QByteArray DeviceJsonPlugin::process(const QVariantMap &command, const QVariantMap ¶meters) -{ - - m_command = command; - m_parameters = parameters; - - // check if we have a id - if(!m_command.contains("id")){ - qDebug() << "request contains no id.."; - } - - // check the methods - if(m_command.value("method").toString() == "add"){ - qDebug() << "got a ADD DEVICE command"; - add(); - } - - return 0; -} - -bool DeviceJsonPlugin::add() -{ -// QUuid uuid = QUuid::createUuid(); -// //qDebug() << uuid; -// if(parameters.value("deviceType").toString() == "actor"){ -// QSettings settings("hive"); -// settings.beginGroup(uuid.toString()); -// QMapIterator i(parameters); -// while(i.hasNext()){ -// i.next(); -// qDebug() << i.key() << "=" << i.value().toString(); -// settings.setValue(i.key(),i.value()); -// } -// settings.endGroup(); -// } -} - -bool DeviceJsonPlugin::remove() -{ - -} - -QByteArray DeviceJsonPlugin::formatResponse() -{ - -} - -QByteArray DeviceJsonPlugin::formatErrorResponse() -{ - -} diff --git a/hive/libhive/jsonplugin/devicejsonplugin.h b/hive/libhive/jsonplugin/devicejsonplugin.h deleted file mode 100644 index e7ff1561..00000000 --- a/hive/libhive/jsonplugin/devicejsonplugin.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef DEVICEJSONPLUGIN_H -#define DEVICEJSONPLUGIN_H - -#include -#include -#include -#include - -class DeviceJsonPlugin : public JsonPlugin -{ - Q_OBJECT -public: - explicit DeviceJsonPlugin(QObject *parent = 0); - QString deviceName(); - QByteArray process(const QVariantMap &command, const QVariantMap ¶meters); - -private: - DeviceManager *m_deviceManager; - - bool add(); - bool remove(); - bool edit(); - bool execute(); - - QVariantMap m_command; - QVariantMap m_parameters; - - - QByteArray formatResponse(); - QByteArray formatErrorResponse(); - -signals: - - -}; - -#endif // DEVICEJSONPLUGIN_H diff --git a/hive/libhive/jsonplugin/jsonplugin.cpp b/hive/libhive/jsonplugin/jsonplugin.cpp deleted file mode 100644 index 920f080b..00000000 --- a/hive/libhive/jsonplugin/jsonplugin.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "jsonplugin.h" - -JsonPlugin::JsonPlugin(QObject *parent) : - QObject(parent) -{ -} - diff --git a/hive/libhive/jsonplugin/jsonplugin.h b/hive/libhive/jsonplugin/jsonplugin.h deleted file mode 100644 index aa98d72d..00000000 --- a/hive/libhive/jsonplugin/jsonplugin.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef JSONPLUGIN_H -#define JSONPLUGIN_H - -#include - -class JsonPlugin : public QObject -{ - Q_OBJECT -public: - explicit JsonPlugin(QObject *parent = 0); - virtual ~JsonPlugin(){} - virtual QString deviceName() = 0; - virtual QByteArray process(const QVariantMap & command, const QVariantMap & parameters) = 0; - -private: - QByteArray formatResponse(); - QByteArray formatErrorResponse(); - -signals: - - -public slots: - -}; - -#endif // JSONPLUGIN_H diff --git a/hive/libhive/jsonplugin/radiojsonplugin.cpp b/hive/libhive/jsonplugin/radiojsonplugin.cpp deleted file mode 100644 index c119edc2..00000000 --- a/hive/libhive/jsonplugin/radiojsonplugin.cpp +++ /dev/null @@ -1,119 +0,0 @@ -#include "radiojsonplugin.h" -#include -#include - -RadioJsonPlugin::RadioJsonPlugin(QObject *parent) : - JsonPlugin(parent) -{ - m_deviceManager = new DeviceManager(this); -} - -QString RadioJsonPlugin::deviceName() -{ - QString deviceName = "radio"; - return deviceName; -} - -QStringList RadioJsonPlugin::devicePropertys() -{ - QStringList propertys; - propertys.append("name"); - propertys.append("uuid"); - propertys.append("channel"); - propertys.append("button"); - propertys.append("buttonState"); - propertys.append("location"); - return propertys; -} - -QStringList RadioJsonPlugin::deviceMethods() -{ - QStringList methods; - methods.append("add"); - methods.append("remove"); - methods.append("edit"); - methods.append("execute"); - methods.append("getAll"); - return methods; -} - -QByteArray RadioJsonPlugin::process(const QVariantMap &command, const QVariantMap ¶meters) -{ - m_command = command; - m_parameters = parameters; - - if(!m_command.contains("id")){ - qDebug() << "request contains no id.."; - } - - // check if we have a valid method - if(deviceMethods().contains(m_command.value("method").toString())){ - // check the methods - if(m_command.value("method").toString() == "add"){ - qDebug() << "got a ADD DEVICE command"; - if(add()){ - //TODO: return response - }else{ - // TODO: return error response - } - } - if(m_command.value("method").toString() == "execut"){ - qDebug() << "got a EXECUTE DEVICE command"; - execute(); - } - - - - }else{ - // TODO: return error respnonse - return NULL; - } - - -} - -bool RadioJsonPlugin::add() -{ - QUuid uuid = QUuid::createUuid(); - //qDebug() << uuid; - return m_deviceManager->saveDevice(m_command.value("deviceType").toString(),uuid,m_parameters); - -} - -bool RadioJsonPlugin::remove() -{ - if(m_parameters.contains("uuid")){ - QUuid uuid = m_parameters.value("uuid").toUuid(); - return m_deviceManager->deleteDevice(m_command.value("deviceType").toString(),uuid); - }else{ - return false; - } -} - -bool RadioJsonPlugin::edit() -{ - -} - -bool RadioJsonPlugin::execute() -{ - if(m_parameters.contains("uuid")){ - QUuid uuid = m_parameters.value("uuid").toUuid(); - - // load paramters (bincode, linecode, frequency ecc.) and execute - - - }else{ - return false; - } -} - -QByteArray RadioJsonPlugin::formatResponse() -{ - -} - -QByteArray RadioJsonPlugin::formatErrorResponse() -{ - -} diff --git a/hive/libhive/jsonplugin/radiojsonplugin.h b/hive/libhive/jsonplugin/radiojsonplugin.h deleted file mode 100644 index ec75b0dc..00000000 --- a/hive/libhive/jsonplugin/radiojsonplugin.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef RADIOJSONPLUGIN_H -#define RADIOJSONPLUGIN_H - -#include -#include -#include -#include -#include - -class RadioJsonPlugin : public JsonPlugin -{ - Q_OBJECT -public: - explicit RadioJsonPlugin(QObject *parent = 0); - - QString deviceName(); - QStringList devicePropertys(); - QStringList deviceMethods(); - - QByteArray process(const QVariantMap & command, const QVariantMap & parameters); - -private: - // methods - bool add(); - bool remove(); - bool edit(); - bool execute(); - - QVariantMap m_command; - QVariantMap m_parameters; - DeviceManager *m_deviceManager; - - QByteArray formatResponse(); - QByteArray formatErrorResponse(); - -signals: - -public slots: - -}; - -#endif // RADIOJSONPLUGIN_H diff --git a/hive/libhive/libhive.cpp b/hive/libhive/libhive.cpp deleted file mode 100644 index a97f18b2..00000000 --- a/hive/libhive/libhive.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "libhive.h" - - -Libhive::Libhive() -{ -} diff --git a/hive/libhive/libhive.h b/hive/libhive/libhive.h deleted file mode 100644 index 0e92c856..00000000 --- a/hive/libhive/libhive.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef LIBHIVE_H -#define LIBHIVE_H - -#include "libhive_global.h" - -class LIBHIVESHARED_EXPORT Libhive -{ - -public: - Libhive(); -}; - -#endif // LIBHIVE_H diff --git a/hive/libhive/libhive.includes b/hive/libhive/libhive.includes deleted file mode 100644 index cda4041e..00000000 --- a/hive/libhive/libhive.includes +++ /dev/null @@ -1 +0,0 @@ -/home/timon/development/hive/hive/libhive \ No newline at end of file diff --git a/hive/libhive/libhive.pro b/hive/libhive/libhive.pro deleted file mode 100644 index 02d23d82..00000000 --- a/hive/libhive/libhive.pro +++ /dev/null @@ -1,51 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2013-08-11T20:58:11 -# -#------------------------------------------------- - -QT += core network - -TARGET = libhive -TEMPLATE = lib -CONFIG += static - -DEFINES += LIBHIVE_LIBRARY - -LIBS += -lqjson - -SOURCES += libhive.cpp \ - server.cpp \ - devicemanager.cpp \ - logwriter.cpp \ - client.cpp \ - jsonhandler.cpp \ - jsonplugin/jsonplugin.cpp \ - jsonplugin/devicejsonplugin.cpp \ - jsonplugin/radiojsonplugin.cpp \ - radioplugin/radioplugin.cpp \ - radioplugin/radioswitch.cpp \ - radioplugin/radiothermometer.cpp - -HEADERS += libhive.h\ - libhive_global.h \ - server.h \ - devicemanager.h \ - logwriter.h \ - client.h \ - jsonhandler.h \ - jsonplugin/jsonplugin.h \ - jsonplugin/devicejsonplugin.h \ - jsonplugin/radiojsonplugin.h \ - radioplugin/radioplugin.h \ - radioplugin/radioswitch.h \ - radioplugin/radiothermometer.h - -#unix:!symbian { -# maemo5 { -# target.path = /opt/usr/lib -# } else { -# target.path = /usr/lib -# } -# INSTALLS += target -#} diff --git a/hive/libhive/libhive_global.h b/hive/libhive/libhive_global.h deleted file mode 100644 index 34d5fa3d..00000000 --- a/hive/libhive/libhive_global.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef LIBHIVE_GLOBAL_H -#define LIBHIVE_GLOBAL_H - -#include - -#if defined(LIBHIVE_LIBRARY) -# define LIBHIVESHARED_EXPORT Q_DECL_EXPORT -#else -# define LIBHIVESHARED_EXPORT Q_DECL_IMPORT -#endif - -#endif // LIBHIVE_GLOBAL_H diff --git a/hive/libhive/logwriter.cpp b/hive/libhive/logwriter.cpp deleted file mode 100644 index fa105f55..00000000 --- a/hive/libhive/logwriter.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "logwriter.h" -#include -#include - -LogWriter::LogWriter(QObject *parent) : - QObject(parent) -{ -} - -void LogWriter::write(LogWriter::MessageType messageType, QString logMessage) -{ - QString timeStamp = QDateTime::currentDateTime().toString("dd.MM.yyyy hh:mm");; - qDebug() << timeStamp; - -} diff --git a/hive/libhive/logwriter.h b/hive/libhive/logwriter.h deleted file mode 100644 index c1752ebe..00000000 --- a/hive/libhive/logwriter.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef LOGWRITER_H -#define LOGWRITER_H - -#include -#include - -class LogWriter : public QObject -{ - Q_OBJECT -public: - explicit LogWriter(QObject *parent = 0); - enum MessageType{ - INFO = 0x1, - ERROR = 0x2, - TEMP = 0X4 - }; - - - -signals: - -public slots: - void write(MessageType messageType, QString logMessage); - -}; - -#endif // LOGWRITER_H diff --git a/hive/libhive/radioplugin/radioplugin.cpp b/hive/libhive/radioplugin/radioplugin.cpp deleted file mode 100644 index c8c8bbfc..00000000 --- a/hive/libhive/radioplugin/radioplugin.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "radioplugin.h" - -RadioPlugin::RadioPlugin(QObject *parent) : - QObject(parent) -{ -} diff --git a/hive/libhive/radioplugin/radioplugin.h b/hive/libhive/radioplugin/radioplugin.h deleted file mode 100644 index e080d827..00000000 --- a/hive/libhive/radioplugin/radioplugin.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef RADIOPLUGIN_H -#define RADIOPLUGIN_H - -#include - -class RadioPlugin : public QObject -{ - Q_OBJECT - -public: - explicit RadioPlugin(QObject *parent = 0); - virtual ~RadioPlugin(){} - - virtual bool isValid(QList rawData) = 0; - virtual QByteArray getBinCode() = 0; - -}; -#endif // RADIOPLUGIN_H diff --git a/hive/libhive/radioplugin/radioswitch.cpp b/hive/libhive/radioplugin/radioswitch.cpp deleted file mode 100644 index b354b240..00000000 --- a/hive/libhive/radioplugin/radioswitch.cpp +++ /dev/null @@ -1,159 +0,0 @@ -#include "radioswitch.h" -#include -#include - - -RadioSwitch::RadioSwitch(QObject *parent) : - RadioPlugin(parent) -{ - m_delay = 0; - m_binCode = 0; -} - -QByteArray RadioSwitch::getBinCode() -{ - if(m_binCode.isEmpty()){ - return NULL; - }else{ - return m_binCode; - } -} - -bool RadioSwitch::isValid(QList rawData) -{ - m_delay = rawData.first()/31; - QByteArray binCode; - - // new Remote -> average 314 - if(m_delay > 300 && m_delay < 400){ - // go trough all 48 timings (without sync signal) - for(int i = 1; i <= 48; i+=2 ){ - int div; - int divNext; - - // if short - if(rawData.at(i) < 700){ - div = 1; - }else{ - div = 3; - } - // if long - if(rawData.at(i+1) < 700){ - divNext = 1; - }else{ - divNext = 3; - } - - // _ - // if we have | |___ = 0 -> in 4 delays => 1000 - // _ - // if we have ___| | = 1 -> in 4 delays => 0001 - - if(div == 1 && divNext == 3){ - binCode.append('0'); - }else if(div == 3 && divNext == 1){ - binCode.append('1'); - }else{ - return false; - } - } - } - - - m_binCode = binCode; - - // get the channel of the remote signal (5 channels, 1=on, 0 = off) - QByteArray channelSettings; - for(int i = 1; i < 10; i+=2){ - if(m_binCode.at(i-1) == '0' && m_binCode.at(i) == '1'){ - channelSettings.append('0'); - }else{ - channelSettings.append('1'); - } - } - // get the button letter - char button; - if(m_binCode.at(10) == '0' && m_binCode.at(11) == '0'){ - button = 'A'; - } - if(m_binCode.at(12) == '0' && m_binCode.at(13) == '0'){ - button = 'B'; - } - if(m_binCode.at(14) == '0' && m_binCode.at(15) == '0'){ - button = 'C'; - } - if(m_binCode.at(16) == '0' && m_binCode.at(17) == '0'){ - button = 'D'; - } - if(m_binCode.at(18) == '0' && m_binCode.at(19) == '0'){ - button = 'E'; - } - - QStringList byteList; - for(int i = 4; i <= 24; i+=4){ - byteList.append(binCode.left(4)); - binCode = binCode.right(binCode.length() -4); - } - - bool buttonStatus; - if(byteList.last().toInt(0,2) == 1){ - buttonStatus = true; - } - if(byteList.last().toInt(0,2) == 4){ - buttonStatus = false; - } - - qDebug() << "-----------------------------------------------------------"; - qDebug() << "| REMOTE signal |"; - qDebug() << "-----------------------------------------------------------"; - qDebug() << "delay :" << m_delay; - qDebug() << "bin CODE :" << m_binCode; - qDebug() << byteList; - qDebug() << "Channels:" << channelSettings << "Button:" << button << "=" << buttonStatus; - emit switchSignalReceived(channelSettings,button,buttonStatus); - return true; -} - -QByteArray RadioSwitch::calcBinCode(const QByteArray &channel, const RadioSwitch::RadioRemoteButton &button, const bool &buttonStatus) -{ - QByteArray binCode; - - // channels - for(int i = 0; i < channel.length(); i++){ - if(channel.at(i) == '0'){ - binCode.append("01"); - }else{ - binCode.append("00"); - } - } - - // Buttons - switch (button) { - case RadioSwitch::A : - binCode.append("0001010101"); - break; - case RadioSwitch::B: - binCode.append("0100010101"); - break; - case RadioSwitch::C: - binCode.append("0101000101"); - break; - case RadioSwitch::D: - binCode.append("0101010001"); - break; - case RadioSwitch::E: - binCode.append("0101010100"); - break; - default: - break; - } - - // ON/OFF - if(buttonStatus){ - binCode.append("0001"); - }else{ - binCode.append("0100"); - } - - return binCode; -} diff --git a/hive/libhive/radioplugin/radioswitch.h b/hive/libhive/radioplugin/radioswitch.h deleted file mode 100644 index c4e18d45..00000000 --- a/hive/libhive/radioplugin/radioswitch.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef RADIOSWITCH_H -#define RADIOSWITCH_H - -#include -#include - -#define RadioSwitchDelay 350 - -class RadioSwitch : public RadioPlugin -{ - Q_OBJECT -public: - explicit RadioSwitch(QObject *parent = 0); - - QByteArray getBinCode(); - bool isValid(QList rawData); - - enum RadioRemoteButton{ - A = 0x0, - B = 0x1, - C = 0x2, - D = 0x3, - E = 0x4 - }; - -private: - int m_delay; - QByteArray m_binCode; - -signals: - void switchSignalReceived(const QByteArray &channel, const char &button, const bool &buttonStatus); - -public slots: - QByteArray calcBinCode(const QByteArray &channel, const RadioRemoteButton &button, const bool &buttonStatus); - -}; - -#endif // RADIOSWITCH_H diff --git a/hive/libhive/radioplugin/radiothermometer.cpp b/hive/libhive/radioplugin/radiothermometer.cpp deleted file mode 100644 index 3c15ec0e..00000000 --- a/hive/libhive/radioplugin/radiothermometer.cpp +++ /dev/null @@ -1,125 +0,0 @@ -#include "radiothermometer.h" -#include -#include -#include - -RadioThermometer::RadioThermometer(QObject *parent) : - RadioPlugin(parent) -{ - m_lastTemperature = -1111; - m_delay = 0; - m_binCode = 0; -} - -QByteArray RadioThermometer::getBinCode() -{ - if(m_binCode.isEmpty()){ - return NULL; - }else{ - return m_binCode; - } -} - -bool RadioThermometer::isValid(QList rawData) -{ - m_delay = rawData.first()/31; - QByteArray binCode; - - if(m_delay > 250 && m_delay < 260){ - - // __ - // | |________ = 0 1100000000 - // __ - // | |________________ = 1 110000000000000000 - - for(int i = 1; i <= 48; i+=2 ){ - if(rawData.at(i) < 1000 && rawData.at(i+1) < 3000 && rawData.at(i+1) > 1000){ - binCode.append('0'); - }else if(rawData.at(i) < 1000 && rawData.at(i+1) > 3000){ - binCode.append('1'); - }else{ - return false; - } - } - m_binCode = binCode; - return true; - }else{ - m_binCode.clear(); - return false; - } -} - -float RadioThermometer::getTemperature() -{ - // { ID },{-+}{ temp, },{Batt},{,temp} - // "XXXX","XXXX","X XXX","XXXX","XXXX","XXXX", - - QByteArray binCode = m_binCode; - - QList byteList; - for(int i = 4; i <= 24; i+=4){ - byteList.append(binCode.left(4)); - binCode = binCode.right(binCode.length() -4); - } - - QByteArray temperatureBin(byteList.at(2) + byteList.at(3)); - QByteArray batteryBin(byteList.at(4)); - QByteArray temperatureTenthBin(byteList.at(5)); - - QByteArray id = byteList.at(0)+byteList.at(1); - - // check if we have a sync signal (id = 11111111) - if(id.contains("11111111")){ - qDebug() << "temperatursensor sync signal"; - return 0; - } - - // check sign of temperature -> if first bit of temperature byte is 1 -> temp is negativ - int sign = 0; - if(temperatureBin.left(1).toInt() == 1){ - sign = -1; - }else{ - sign = 1; - } - - //qDebug() << temperatureBin << "=" << temperatureBin.left(1) << temperatureBin.right(7) << temperatureBin.right(7).toInt(0,2) << "," << temperatureTenthBin.toInt(0,2) ; - - // calc temperature - float temperature = sign*(temperatureBin.right(7).toInt(0,2) + (float)temperatureTenthBin.toInt(0,2)/10); - - // check if the battery is low - bool batteryStatus; - if(batteryBin.toInt(0,2) == 0){ - batteryStatus = true; - }else{ - batteryStatus = false; - } - - if(temperature == m_lastTemperature){ - qDebug() << "received same temperature from " << QString(id) << " - " << QDateTime::currentDateTime().toString("dd.MM.yyyy, hh:mm:ss"); - return temperature; - }else{ - - m_lastTemperature = temperature; - QString timeStamp = QDateTime::currentDateTime().toString("dd.MM.yyyy, hh:mm:ss"); - //qDebug() << timeStamp; - - QFile file("/root/temperature_log.ods"); - file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text); - QTextStream out(&file); - - out << id << "," << timeStamp << "," << batteryStatus << "," << temperature << "," << "\n"; - file.close(); - - qDebug() << "-----------------------------------------------------------"; - qDebug() << "| THERMOMETER signal |"; - qDebug() << "-----------------------------------------------------------"; - qDebug() << "delay :" << m_delay; - qDebug() << "bin CODE :" << m_binCode; - qDebug() << byteList; - qDebug() << timeStamp << " ID:" << id << " Temperature:" << temperature << " Battery OK: " << batteryStatus; - - emit temperatureSignalReceived(id,temperature,batteryStatus); - return temperature; - } -} diff --git a/hive/libhive/radioplugin/radiothermometer.h b/hive/libhive/radioplugin/radiothermometer.h deleted file mode 100644 index c862e37e..00000000 --- a/hive/libhive/radioplugin/radiothermometer.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef RADIOTHERMOMETER_H -#define RADIOTHERMOMETER_H - -#include -#include - -#define RadioThermometerDelay 250 - -class RadioThermometer : public RadioPlugin -{ - Q_OBJECT -public: - explicit RadioThermometer(QObject *parent = 0); - - QByteArray getBinCode(); - bool isValid(QList rawData); - float getTemperature(); - -private: - float m_lastTemperature; - int m_delay; - QByteArray m_binCode; - -signals: - void temperatureSignalReceived(const QByteArray &id, const float &temperature, const bool &batteryStatus); - -public slots: - -}; - -#endif // RADIOTHERMOMETER_H diff --git a/hive/libhive/server.cpp b/hive/libhive/server.cpp deleted file mode 100644 index 991dd770..00000000 --- a/hive/libhive/server.cpp +++ /dev/null @@ -1,101 +0,0 @@ -#include "server.h" -#include -#include - -Server::Server(QObject *parent) : - QObject(parent) -{ - - qDebug() << "----------------------------"; - qDebug() << "network interfaces:"; - foreach(const QNetworkInterface &interface, QNetworkInterface::allInterfaces()){ - qDebug() << " -------------------------"; - qDebug() << " name:" << interface.name(); - qDebug() << " mac: " << interface.hardwareAddress(); - } - qDebug() << "----------------------------"; - -} - -void Server::newClientConnected() -{ - // got a new client connected - QTcpServer *server = qobject_cast(sender()); - QTcpSocket *newConnection = server->nextPendingConnection(); - qDebug() << "new client connected:" << newConnection->peerAddress().toString(); - - // append the new client to the client list - m_clientList.append(newConnection); - - connect(newConnection, SIGNAL(readyRead()),this,SLOT(readPackage())); - connect(newConnection,SIGNAL(disconnected()),this,SLOT(clientDisconnected())); - -} - - -void Server::readPackage() -{ - QTcpSocket *client = qobject_cast(sender()); - //qDebug() << "-----------> data comming from" << client->peerAddress().toString(); - QByteArray message; - while(client->canReadLine()){ - QByteArray dataLine = client->readLine(); - //qDebug() << "line in:" << dataLine; - message.append(dataLine); - if(dataLine == "}\n"){ - //qDebug() << message; - emit jsonDataAvailable(message); - message.clear(); - } - } - -} - -void Server::clientDisconnected() -{ - QTcpSocket *client = qobject_cast(sender()); - qDebug() << "client disconnected:" << client->peerAddress().toString(); -} - -bool Server::startServer() -{ - // Listen on all Networkinterfaces - foreach(const QHostAddress &address, QNetworkInterface::allAddresses()){ - QTcpServer *server = new QTcpServer(this); - if(server->listen(address, 1234)) { - qDebug() << "server listening on" << address.toString(); - connect(server, SIGNAL(newConnection()), SLOT(newClientConnected())); - m_serverList.append(server); - } else { - qDebug() << "ERROR: can not listening to" << address.toString(); - delete server; - } - } - if(m_serverList.empty()){ - return false; - } - return true; -} - -bool Server::stopServer() -{ - // Listen on all Networkinterfaces - foreach(QTcpServer *server, m_serverList){ - qDebug() << "close server " << server->serverAddress().toString(); - server->close(); - delete server; - } - if(!m_serverList.empty()){ - return false; - } - return true; -} - -void Server::sendToAll(QByteArray data) -{ - foreach(QTcpSocket *client,m_clientList){ - client->write(data); - } -} - - diff --git a/hive/libhive/server.h b/hive/libhive/server.h deleted file mode 100644 index ca1038c8..00000000 --- a/hive/libhive/server.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef SERVER_H -#define SERVER_H - -#include -#include -#include -#include - -class Server : public QObject -{ - Q_OBJECT -public: - explicit Server(QObject *parent = 0); - -private: - QList m_serverList; - QList m_clientList; - - -signals: - void jsonDataAvailable(const QByteArray &data); - -private slots: - void newClientConnected(); - void readPackage(); - void clientDisconnected(); - -public slots: - bool startServer(); - bool stopServer(); - void sendToAll(QByteArray data); - - -}; - -#endif // SERVER_H diff --git a/hive/server/hive/hive.pro b/hive/server/hive/hive.pro deleted file mode 100644 index 6a77ddf7..00000000 --- a/hive/server/hive/hive.pro +++ /dev/null @@ -1,29 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2013-08-15T13:31:23 -# -#------------------------------------------------- - -QT += core -QT -= gui - -TARGET = hive -CONFIG += console -CONFIG -= app_bundle - -TEMPLATE = app - -SOURCES += main.cpp \ - hivecore.cpp - - - -HEADERS += \ - hivecore.h - -win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../libhive/release/ -llibhive -else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../libhive/debug/ -llibhive -else:unix: LIBS += -L$$OUT_PWD/../../libhive/ -llibhive - -INCLUDEPATH += $$PWD/../../libhive -DEPENDPATH += $$PWD/../../libhive diff --git a/hive/server/hive/hivecore.cpp b/hive/server/hive/hivecore.cpp deleted file mode 100644 index 63527662..00000000 --- a/hive/server/hive/hivecore.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "hivecore.h" - - -HiveCore::HiveCore(QObject *parent) : - QObject(parent) -{ -// m_server = new Server(this); -} diff --git a/hive/server/hive/hivecore.h b/hive/server/hive/hivecore.h deleted file mode 100644 index 890705e5..00000000 --- a/hive/server/hive/hivecore.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef HIVECORE_H -#define HIVECORE_H - -#include -//#include "server.h" - -class HiveCore : public QObject -{ - Q_OBJECT -public: - explicit HiveCore(QObject *parent = 0); - -private: -// Server *m_server; - -signals: - -public slots: - -}; - -#endif // HIVECORE_H diff --git a/hive/server/hive/main.cpp b/hive/server/hive/main.cpp deleted file mode 100644 index 160aacf8..00000000 --- a/hive/server/hive/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include "hivecore.h" - -int main(int argc, char *argv[]) -{ - QCoreApplication a(argc, argv); - - HiveCore core; - - return a.exec(); -} diff --git a/hive/server/hive_pi/hive_pi.pro b/hive/server/hive_pi/hive_pi.pro deleted file mode 100644 index d23bac9d..00000000 --- a/hive/server/hive_pi/hive_pi.pro +++ /dev/null @@ -1,38 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2013-08-15T13:14:35 -# -#------------------------------------------------- - -QT += core network -QT -= gui - -TARGET = hive - -CONFIG += console -CONFIG -= app_bundle - -target.path = /usr/bin -INSTALLS += target - -TEMPLATE = app - - -LIBS += -L$$OUT_PWD/../../libhive/ -llibhive -LIBS += -L$$RPI_SYSROOT/usr/local/lib -lwiringPi - -INCLUDEPATH += /home/timon/opt/rasp-pi-rootfs/usr/local/include -INCLUDEPATH += $$PWD/../../libhive - -DEPENDPATH += $$PWD/../../libhive - -SOURCES += main.cpp \ - hivecore.cpp \ - radio/radioreciver.cpp \ - radio/radiosender.cpp - -HEADERS += \ - hivecore.h \ - radio/radioreciver.h \ - radio/radiosender.h - diff --git a/hive/server/hive_pi/hivecore.cpp b/hive/server/hive_pi/hivecore.cpp deleted file mode 100644 index d0ce8ab2..00000000 --- a/hive/server/hive_pi/hivecore.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "hivecore.h" -#include - -HiveCore::HiveCore(QObject *parent) : - QObject(parent) -{ - // start the server - m_server = new Server(this); - m_server->startServer(); - -// m_jsonHandler = new JsonHandler(this); - -// connect(m_server,SIGNAL(jsonDataAvailable(QByteArray)),m_jsonHandler,SLOT(process(QByteArray))); - - -// // create 433.92 MHz sender -// m_sender = new RadioSender(this); -// m_sender->setFrequency(RadioSender::RF433MHz); -// m_sender->setLineCode(RadioSender::SWITCH); -// m_sender->setPulseLength(320); // pin number 13 -// m_sender->sendBin("000000000000010101010001"); - - // create 433.92 MHz receiver - m_reciver = new RadioReciver(this); - m_reciver->setFrequency(RadioReciver::RF433MHz); - m_reciver->setPin(2); // pin number 13 - m_reciver->enableReceiver(); - -} diff --git a/hive/server/hive_pi/hivecore.h b/hive/server/hive_pi/hivecore.h deleted file mode 100644 index 5e9b96fc..00000000 --- a/hive/server/hive_pi/hivecore.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef HIVECORE_H -#define HIVECORE_H - -#include -#include "server.h" -#include "devicemanager.h" -#include -#include "radio/radioreciver.h" -#include "radio/radiosender.h" - -class HiveCore : public QObject -{ - Q_OBJECT -public: - explicit HiveCore(QObject *parent = 0); - -private: - Server *m_server; - RadioReciver *m_reciver; - RadioSender *m_sender; - DeviceManager *m_deviceManager; - JsonHandler *m_jsonHandler; - -signals: - -public slots: - -}; - -#endif // HIVECORE_H diff --git a/hive/server/hive_pi/main.cpp b/hive/server/hive_pi/main.cpp deleted file mode 100644 index 10e0f91b..00000000 --- a/hive/server/hive_pi/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include - -int main(int argc, char *argv[]) -{ - QCoreApplication a(argc, argv); - - HiveCore core; - - return a.exec(); -} diff --git a/hive/server/hive_pi/radio/radioreciver.cpp b/hive/server/hive_pi/radio/radioreciver.cpp deleted file mode 100644 index 937e13b1..00000000 --- a/hive/server/hive_pi/radio/radioreciver.cpp +++ /dev/null @@ -1,231 +0,0 @@ -#include -#include -#include -#include - -#include "radioreciver.h" -#include "wiringPi.h" - - -// ##################################################################################################### -// this class handels the interrupts from the INPUT Pins -class ISRHandler{ - -private: - - static ISRHandler* s_instance; - - ISRHandler(){ - if(wiringPiSetup() == -1){ - qDebug() << "ERROR: GPIO setup for 433.92 MHz receiver failed."; - } - qDebug() << "GPIO setup for receiver ok."; - } - - // one handler for each pin - // on pin 0 - static void handleInterrupt0(){ - } - // on pin 1 - static void handleInterrupt1(){ - } - // on pin 2 - static void handleInterrupt2(){ - foreach (RadioReciver *receiver, s_receivers){ - if(receiver->getPin() == 2){ - receiver->handleInterrupt(); - } - } - } - // ... and so on -> implement if needed - - static QList s_receivers; - -public: - // create a instance if not allready created - static ISRHandler* instance(){ - if(!s_instance){ - s_instance = new ISRHandler(); - } - return s_instance; - } - - // register a receiver - void registerReceiver(RadioReciver* receiver){ - bool pinAllreadyRegistred = false; - - foreach (RadioReciver* tmpReceiver, s_receivers) { - if(tmpReceiver->getPin() == receiver->getPin()){ - pinAllreadyRegistred = true; - } - } - - int ok = 0; - - if(!pinAllreadyRegistred){ - pinMode(receiver->getPin(),INPUT); - - // TODO: for more pins I would need more interruptHandlerX... - switch (receiver->getPin()) { - case 0: - ok = wiringPiISR(receiver->getPin(), INT_EDGE_BOTH, &handleInterrupt0); - break; - case 1: - ok = wiringPiISR(receiver->getPin(), INT_EDGE_BOTH, &handleInterrupt1); - break; - case 2: - ok = wiringPiISR(receiver->getPin(), INT_EDGE_BOTH, &handleInterrupt2); - break; - default: - break; - } - } - // check if register the ISR for this pin worked, else the programm exit... - if(ok != -1){ - s_receivers.append(receiver); - } - } - - void unregisterReceiver(RadioReciver* receiver){ - // TODO: delete ISR wiringPi?? - s_receivers.removeAll(receiver); - } -}; -ISRHandler* ISRHandler::s_instance = 0; -QList ISRHandler::s_receivers; - - -// ##################################################################################################### -// The main RadioReceiver class -RadioReciver::RadioReciver(QObject *parent) : - QObject(parent) -{ - m_enable = false; - m_pin = -1; - m_duration = 0; - m_changeCount = 0; - m_lastTime = 0; - m_repeatCount = 0; - - m_thermometer = new RadioThermometer(this); - m_switch = new RadioSwitch(this); - - for(int i = 0; i < RC_MAX_CHANGES; i++ ){ - m_timings[i] = 0; - } - - connect(m_thermometer,SIGNAL(temperatureSignalReceived(QByteArray,float,bool)),this,SIGNAL(temperatureSignalReceived(QByteArray,float,bool))); - connect(m_switch,SIGNAL(switchSignalReceived(QByteArray,char,bool)),this,SIGNAL(switchSignalReceived(QByteArray,char,bool))); -} - -void RadioReciver::setFrequency(RadioReciver::Frequency frequency) -{ - m_frequency = frequency; -} - -RadioReciver::Frequency RadioReciver::getFrequency() const -{ - return m_frequency; -} - -void RadioReciver::setPin(int pin) -{ - m_pin = pin; -} - -int RadioReciver::getPin() const -{ - return m_pin; -} - - -void RadioReciver::handleInterrupt() -{ - - if(!m_enable){ - return; - } - - long currentTime = micros(); - m_duration = currentTime - m_lastTime; - - // filter nois - if (m_duration > 5000 && m_duration > m_timings[0] - 200 && m_duration < m_timings[0] + 200){ - qDebug() << "dt " << m_duration; - - m_repeatCount++; - m_changeCount--; - - if(m_repeatCount == 2) { - // if we have a regular signal (1 bit sync + 48 bit data) - if(m_changeCount == RC_MAX_CHANGES){ - // write rawdata to a List and reset values to 0 - qDebug() << "detect protokol"; - QList rawData; - for(int i = 0; i < RC_MAX_CHANGES; i++ ){ - rawData.append(m_timings[i]); - m_timings[i] = 0; - } - detectProtocol(rawData); - } - m_repeatCount = 0; - } - m_changeCount = 0; - - }else if(m_duration > 5000){ - m_changeCount = 0; - - } - if (m_changeCount >= RC_MAX_CHANGES+1) { - m_changeCount = 0; - m_repeatCount = 0; - } - m_timings[m_changeCount++] = m_duration; - m_lastTime = currentTime; -} - -bool RadioReciver::detectProtocol(QList rawData) -{ - // check if we have a valid signal, 1 sync + 48 data - if(rawData.length() != 49){ - qDebug() << rawData; - return false; - } - // check plugins - if(m_thermometer->isValid(rawData)){ - m_thermometer->getTemperature(); - return true; - }else - if(m_switch->isValid(rawData)){ - m_switch->getBinCode(); - return true; - }else{ - qDebug() << "-----------------------------------------------------------"; - qDebug() << "| GENERIC signal |"; - qDebug() << "-----------------------------------------------------------"; - qDebug() << "delay :" << rawData.first() /31; - qDebug() << rawData; - } - return false; -} - -void RadioReciver::enableReceiver() -{ - // check if we have all needed info...pin, freq... - if(m_pin == -1){ - qDebug() << "ERROR: pin not set for RadioReceiver"; - return; - } - m_enable = true; - - ISRHandler::instance()->registerReceiver(this); - qDebug() << "receiver for GPIO pin" << m_pin << "enabled."; - -} - -void RadioReciver::disableReceiver() -{ - m_enable = false; - -} - diff --git a/hive/server/hive_pi/radio/radioreciver.h b/hive/server/hive_pi/radio/radioreciver.h deleted file mode 100644 index 06f7ef3b..00000000 --- a/hive/server/hive_pi/radio/radioreciver.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef RADIORECIVER_H -#define RADIORECIVER_H - -#define RC_MAX_CHANGES 49 - -#include -#include "radioplugin/radioswitch.h" -#include "radioplugin/radiothermometer.h" - -class ISRHandler; - -class RadioReciver : public QObject -{ - Q_OBJECT -public: - explicit RadioReciver(QObject *parent = 0); - - friend class ISRHandler; - - enum Frequency{ - RF433MHz = 0x0, - RF868MHz = 0x1 - }; - - void setFrequency(Frequency frequency); - Frequency getFrequency() const; - void setPin(int pin); - int getPin() const; - -private: - void handleInterrupt(); - bool detectProtocol(QList rawData); - - bool m_enable; - int m_pin; - Frequency m_frequency; - unsigned int m_timings[RC_MAX_CHANGES]; - unsigned int m_duration; - unsigned int m_changeCount; - unsigned long m_lastTime; - unsigned int m_repeatCount; - - RadioThermometer *m_thermometer; - RadioSwitch *m_switch; - -signals: - void temperatureSignalReceived(const QByteArray &id, const float &temperature, const bool &batteryStatus); - void switchSignalReceived(const QByteArray &channel, const char &button, const bool &buttonStatus); - -public slots: - void enableReceiver(); - void disableReceiver(); -}; - -#endif // RADIORECIVER_H diff --git a/hive/server/hive_pi/radio/radiosender.cpp b/hive/server/hive_pi/radio/radiosender.cpp deleted file mode 100644 index 159b3958..00000000 --- a/hive/server/hive_pi/radio/radiosender.cpp +++ /dev/null @@ -1,167 +0,0 @@ -#include "radiosender.h" - -#include -#include "wiringPi.h" - -RadioSender::RadioSender(QObject *parent) : - QObject(parent) -{ - // set default pulselenght - m_pulseLength = 350; - - // set default radio frequency module - m_frequenze = RadioSender::RF433MHz; - -} - -void RadioSender::sendSync() -{ - // sync for UNIPOLAR: - if(m_lineCode == RadioSender::UNIPOLAR){ - - } - // sync for MANCHESTER: - if(m_lineCode == RadioSender::MANCHESTER){ - - } - // sync for differential MANCHESTER: - if(m_lineCode == RadioSender::DMANCHESTER){ - - } - // sync for SWITCH: 1 high 31 low - if(m_lineCode == RadioSender::SWITCH){ - digitalWrite(m_pin,HIGH); - delayMicroseconds(m_pulseLength); - digitalWrite(m_pin,LOW); - delayMicroseconds(m_pulseLength*31); - } - // sync for THERMOMETER: 1 high 31 low - if(m_lineCode == RadioSender::THERMOMETER){ - digitalWrite(m_pin,HIGH); - delayMicroseconds(m_pulseLength); - digitalWrite(m_pin,LOW); - delayMicroseconds(m_pulseLength*31); - } - // sync for WEATHERSTATION: - if(m_lineCode == RadioSender::WEATHERSTATION){ - - } - -} - -void RadioSender::send0() -{ - // 0 in UNIPOLAR encoding - if(m_lineCode == RadioSender::UNIPOLAR){ - digitalWrite(m_pin,LOW); - delayMicroseconds(m_pulseLength); - } - // 0 in MANCHESTER encoding - if(m_lineCode == RadioSender::MANCHESTER){ - - } - // 0 in differential MANCHESTER encoding - if(m_lineCode == RadioSender::DMANCHESTER){ - - } - // 0 in SWITCH encoding - if(m_lineCode == RadioSender::SWITCH){ - digitalWrite(m_pin,HIGH); - delayMicroseconds(m_pulseLength); - digitalWrite(m_pin,LOW); - delayMicroseconds(m_pulseLength*3); - } - // 0 in THERMOMETER encoding - if(m_lineCode == RadioSender::THERMOMETER){ - digitalWrite(m_pin,HIGH); - delayMicroseconds(m_pulseLength*2); - digitalWrite(m_pin,LOW); - delayMicroseconds(m_pulseLength*8); - } - // 0 in WEATHERSTATION encoding - if(m_lineCode == RadioSender::WEATHERSTATION){ - - } -} - -void RadioSender::send1() -{ - // 1 in UNIPOLAR encoding - if(m_lineCode == RadioSender::UNIPOLAR){ - digitalWrite(m_pin,HIGH); - delayMicroseconds(m_pulseLength); - } - // 1 in MANCHESTER encoding - if(m_lineCode == RadioSender::MANCHESTER){ - - } - // 1 in differential MANCHESTER encoding - if(m_lineCode == RadioSender::DMANCHESTER){ - - } - // 1 in SWITCH encoding - if(m_lineCode == RadioSender::SWITCH){ - digitalWrite(m_pin,HIGH); - delayMicroseconds(m_pulseLength*3); - digitalWrite(m_pin,LOW); - delayMicroseconds(m_pulseLength); - } - // 1 in THERMOMETER encoding - if(m_lineCode == RadioSender::THERMOMETER){ - digitalWrite(m_pin,HIGH); - delayMicroseconds(m_pulseLength*2); - digitalWrite(m_pin,LOW); - delayMicroseconds(m_pulseLength*16); - } - // 1 in WEATHERSTATION encoding - if(m_lineCode == RadioSender::WEATHERSTATION){ - - } -} - - - -void RadioSender::sendBin(QByteArray codeBin) -{ - qDebug() << "send" << codeBin; - for(int i = 0; i < 8; i++){ - for(int i = 0; i < codeBin.length(); i++){ - if(codeBin.at(i) == '0'){ - send0(); - } - if(codeBin.at(i) == '1'){ - send1(); - } - } - sendSync(); - } -} - -void RadioSender::setFrequency(RadioSender::Frequency frequency) -{ - m_frequenze = frequency; - - if(m_frequenze == RadioSender::RF433MHz){ - m_pin = 0; - if(wiringPiSetup() == -1){ - qDebug() << "ERROR: GPIO setup for 433.92 MHz sender failed."; - } - qDebug() << "GPIO setup for sender ok."; - pinMode(m_pin,OUTPUT); - qDebug() << "sender for GPIO pin" << m_pin << "enabled."; - } - if(m_frequenze == RadioSender::RF868MHz){ - qDebug() << "ERROR: 868 MHz Module not connected yet"; - } -} - -void RadioSender::setLineCode(RadioSender::LineCode lineCode) -{ - m_lineCode = lineCode; -} - -void RadioSender::setPulseLength(int pulseLength) -{ - m_pulseLength = pulseLength; -} - diff --git a/hive/server/hive_pi/radio/radiosender.h b/hive/server/hive_pi/radio/radiosender.h deleted file mode 100644 index 88eeb1d8..00000000 --- a/hive/server/hive_pi/radio/radiosender.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef RADIOSENDER_H -#define RADIOSENDER_H - -#include - -class RadioSender : public QObject -{ - Q_OBJECT -public: - explicit RadioSender(QObject *parent = 0); - - enum Frequency{ - RF433MHz = 0x0, - RF868MHz = 0x1 - }; - - enum LineCode{ - UNIPOLAR = 0x2, - MANCHESTER = 0x3, - DMANCHESTER = 0x4, - SWITCH = 0x5, - THERMOMETER = 0x6, - WEATHERSTATION = 0x7 - }; - - -private: - // [us = micro seconds] - int m_pulseLength; - - Frequency m_frequenze; - LineCode m_lineCode; - int m_pin; - - void sendSync(); - void send0(); - void send1(); - -signals: - -public slots: - void sendBin(QByteArray codeBin); - void setFrequency(Frequency frequency); - void setLineCode(LineCode lineCode); - void setPulseLength(int pulseLength); -}; - -#endif // RADIOSENDER_H diff --git a/hive/server/server.pro b/hive/server/server.pro deleted file mode 100644 index 007500d9..00000000 --- a/hive/server/server.pro +++ /dev/null @@ -1,7 +0,0 @@ -TEMPLATE = subdirs - -CONFIG = ordered - - - -SUBDIRS += hive_pi