From a37f282f6fe6f4c0ade827f16c7b3ad1486950b3 Mon Sep 17 00:00:00 2001 From: Simon Stuerz Date: Sat, 31 Aug 2013 10:44:35 +0200 Subject: [PATCH] forst gui for client to test communication --- hive/client/hive_client/hive_client.pro | 11 +- hive/client/hive_client/hiveclientcore.cpp | 49 ++++++- hive/client/hive_client/hiveclientcore.h | 14 +- hive/client/hive_client/main.cpp | 2 - .../hive_client/qml/hive_client/main.qml | 132 ++++++++++++------ .../qml/hive_client/pages/addDevicePage.qml | 8 -- hive/client/hive_client/settings.cpp | 31 ++++ hive/client/hive_client/settings.h | 32 +++++ hive/libhive/client.cpp | 17 ++- hive/libhive/client.h | 7 +- hive/libhive/jsonhandler.cpp | 39 +++++- hive/libhive/jsonhandler.h | 13 +- hive/libhive/jsonplugin/devicejsonplugin.cpp | 75 ++++++++++ hive/libhive/jsonplugin/devicejsonplugin.h | 32 +++++ hive/libhive/jsonplugin/jsonplugin.cpp | 7 + hive/libhive/jsonplugin/jsonplugin.h | 22 +++ hive/libhive/libhive.pro | 8 +- hive/libhive/server.cpp | 16 ++- hive/libhive/server.h | 2 +- hive/server/hive_pi/hivecore.cpp | 28 ++-- hive/server/hive_pi/hivecore.h | 9 +- hive/server/hive_pi/radio/radioreciver.cpp | 12 ++ 22 files changed, 476 insertions(+), 90 deletions(-) delete mode 100644 hive/client/hive_client/qml/hive_client/pages/addDevicePage.qml create mode 100644 hive/client/hive_client/settings.cpp create mode 100644 hive/client/hive_client/settings.h create mode 100644 hive/libhive/jsonplugin/devicejsonplugin.cpp create mode 100644 hive/libhive/jsonplugin/devicejsonplugin.h create mode 100644 hive/libhive/jsonplugin/jsonplugin.cpp create mode 100644 hive/libhive/jsonplugin/jsonplugin.h diff --git a/hive/client/hive_client/hive_client.pro b/hive/client/hive_client/hive_client.pro index feb897fc..6dfe4b7b 100644 --- a/hive/client/hive_client/hive_client.pro +++ b/hive/client/hive_client/hive_client.pro @@ -15,7 +15,13 @@ QML_IMPORT_PATH = # The .cpp file which was generated for your project. Feel free to hack it. SOURCES += main.cpp \ - hiveclientcore.cpp + hiveclientcore.cpp \ + settings.cpp + +HEADERS += \ + hiveclientcore.h \ + settings.h + # Installation path # target.path = @@ -24,9 +30,6 @@ SOURCES += main.cpp \ include(qtquick2applicationviewer/qtquick2applicationviewer.pri) qtcAddDeployment() -HEADERS += \ - hiveclientcore.h - win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../libhive/release/ -llibhive diff --git a/hive/client/hive_client/hiveclientcore.cpp b/hive/client/hive_client/hiveclientcore.cpp index bc99a447..341a802c 100644 --- a/hive/client/hive_client/hiveclientcore.cpp +++ b/hive/client/hive_client/hiveclientcore.cpp @@ -7,12 +7,53 @@ HiveClientCore::HiveClientCore(QObject *parent) : QObject(parent) { + m_id = 0; + + m_settings = new Settings(this); m_client = new Client(this); - m_client->connectToHost("10.10.10.40","1234"); - m_viewer = new QtQuick2ApplicationViewer; - m_viewer->setMainQmlFile(QStringLiteral("qml/hive_client/main.qml")); - m_viewer->showExpanded(); + // QML application window + m_engine = new QQmlApplicationEngine(this); + m_engine->load(QUrl("qml/hive_client/main.qml")); + m_engine->rootContext()->setContextProperty("client", m_client); + m_engine->rootContext()->setContextProperty("settings", m_settings); + + topLevel = m_engine->rootObjects().value(0); + QQuickWindow *window = qobject_cast(topLevel); + window->show(); + + connect(m_client,SIGNAL(connected()),this,SLOT(onConnected())); } + +void HiveClientCore::onConnected() +{ + //sendSomething("device", "getAll"); + sendSomething("device", "add"); + +} + +void HiveClientCore::sendSomething(QString deviceName, QString method) +{ + QVariantMap responseMap; + responseMap.insert("device", deviceName); + responseMap.insert("method", method); + responseMap.insert("id", m_id++); + + QVariantMap params; + params.insert("deviceType","actor"); + params.insert("name","Schreibtisch On"); + params.insert("protocol","RF433"); + params.insert("linecode","remote"); + params.insert("code","000000000000010101010001"); + + responseMap.insert("params", params); + + QJsonDocument doc = QJsonDocument::fromVariant(responseMap); + qDebug() << "_______________________________________"; + qDebug() << "send to hive:"; + QByteArray json = doc.toJson(); + qDebug() << json; + m_client->sendData(json); +} diff --git a/hive/client/hive_client/hiveclientcore.h b/hive/client/hive_client/hiveclientcore.h index 269eba43..43b50c83 100644 --- a/hive/client/hive_client/hiveclientcore.h +++ b/hive/client/hive_client/hiveclientcore.h @@ -2,8 +2,11 @@ #define HIVECLIENTCORE_H #include -#include "qtquick2applicationviewer.h" +#include +#include + #include "client.h" +#include "settings.h" class HiveClientCore : public QObject { @@ -13,9 +16,16 @@ public: private: Client *m_client; + Settings *m_settings; + QQmlApplicationEngine *m_engine; + QObject *topLevel; - QtQuick2ApplicationViewer *m_viewer; + int m_id; + +private slots: + void onConnected(); + void sendSomething(QString deviceName, QString method); signals: diff --git a/hive/client/hive_client/main.cpp b/hive/client/hive_client/main.cpp index f3549945..6f4e9eeb 100644 --- a/hive/client/hive_client/main.cpp +++ b/hive/client/hive_client/main.cpp @@ -1,6 +1,4 @@ #include -#include -#include #include "hiveclientcore.h" int main(int argc, char *argv[]) diff --git a/hive/client/hive_client/qml/hive_client/main.qml b/hive/client/hive_client/qml/hive_client/main.qml index 7d5b095b..9fe7c191 100644 --- a/hive/client/hive_client/qml/hive_client/main.qml +++ b/hive/client/hive_client/qml/hive_client/main.qml @@ -2,51 +2,103 @@ import QtQuick 2.0 import QtQuick.Controls 1.0 import QtQuick.Layouts 1.0 - ApplicationWindow{ - id: mainItem - - title: "Hive Client" - - width: 600 - height: 360 - -// ColumnLayout { -// id: mainLayout -// anchors.fill: parent - -// GroupBox{ -// id: connectionBox -// title: "Connection" -// anchors.horizontalCenter: parent.horizontalCenter - -// RowLayout{ -// Button{ -// id: connectionButton -// text: "Connect" -// } -// TextInput{ -// id: ipText -// text: "10.10.10.40" -// } -// TextInput{ -// id: portText -// text: "1234" -// } -// } -// } -// } - - - - - StatusBar{ + id: mainWindow + menuBar: MenuBar{ + id: mainWindowMenuBar + Menu { + title: "File" + MenuItem { + text: "Close" + shortcut: "Ctrl+Q" + onTriggered: mainWindow.close() + } + } + } + statusBar: StatusBar { id: statusBar - width: parent.width + anchors.right: parent.right + anchors.left: parent.left anchors.bottom: parent.bottom - anchors.horizontalCenter: parent.horizontalCenter + } + title: "Hive Client" + width: 600 + height: 500 + + GroupBox { + id: connectionGroupBox + anchors.right: parent.right + anchors.left: parent.left + anchors.margins: 20 + title: "Connection" + + RowLayout{ + anchors.fill: parent + Button{ + id: connectButton + text: "Connect" + onClicked: { + settings.setIPaddress(ipTextInput.text) + settings.setPort(portTextInput.text) + client.connectToHost(ipTextInput.text,portTextInput.text) + } + } + Text { + id: ipLable + text: "IP:" + horizontalAlignment: Text.AlignHCenter + } + TextField { + id: ipTextInput + text: "10.10.10.40" + horizontalAlignment: TextInput.AlignHCenter + font.pointSize: 9 + } + Text { + id: portLable + text: "Port:" + wrapMode: Text.NoWrap + verticalAlignment: Text.AlignTop + horizontalAlignment: Text.AlignHCenter + } + TextField { + id: portTextInput + text: "1234" + horizontalAlignment: TextInput.AlignHCenter + font.pointSize: 9 + } + } + } + + TabView{ + id: tabView + anchors.right: parent.right + anchors.rightMargin: 20 + anchors.left: parent.left + anchors.leftMargin: 20 + anchors.top: connectionGroupBox.bottom + anchors.bottom: statusBar.top + + Tab{ + id: actorTab + title: "Actor" + + } + Tab{ + id: sensorTab + title: "Sensor" + } + Tab{ + id: ruleTab + title: "Rules" + } + Tab{ + id: settingsTab + title: "Settings" + } } } + diff --git a/hive/client/hive_client/qml/hive_client/pages/addDevicePage.qml b/hive/client/hive_client/qml/hive_client/pages/addDevicePage.qml deleted file mode 100644 index 55c2a4e5..00000000 --- a/hive/client/hive_client/qml/hive_client/pages/addDevicePage.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 2.0 -import QtQuick.Controls 1.0 -import QtQuick.Layouts 1.0 -import QtQuick.Window 2.0 - -Rectangle{ - -} diff --git a/hive/client/hive_client/settings.cpp b/hive/client/hive_client/settings.cpp new file mode 100644 index 00000000..a1349f40 --- /dev/null +++ b/hive/client/hive_client/settings.cpp @@ -0,0 +1,31 @@ +#include "settings.h" +#include + +Settings::Settings(QObject *parent) : + QObject(parent) +{ + m_settings = new QSettings(QString(),"hiveClient",this); +} + +QString Settings::ipaddress() +{ + return m_settings->value("server","10.10.10.40").toString(); +} + +void Settings::setIPaddress(QString ipaddress) +{ + m_settings->setValue("server",ipaddress); + emit ipaddressChanged(); +} + +QString Settings::port() +{ + return m_settings->value("port","1234").toString(); +} + +void Settings::setPort(QString port) +{ + m_settings->setValue("port",port); + emit ipaddressChanged(); +} + diff --git a/hive/client/hive_client/settings.h b/hive/client/hive_client/settings.h new file mode 100644 index 00000000..69534fb1 --- /dev/null +++ b/hive/client/hive_client/settings.h @@ -0,0 +1,32 @@ +#ifndef SETTINGS_H +#define SETTINGS_H + +#include +#include + +class Settings : public QObject +{ + Q_OBJECT + +public: + explicit Settings(QObject *parent = 0); + + + +private: + QSettings* m_settings; + +signals: + void ipaddressChanged(); + void portChanged(); + +public slots: + QString ipaddress(); + QString port(); + + void setIPaddress(QString ipaddress); + void setPort(QString port); + +}; + +#endif // SETTINGS_H diff --git a/hive/libhive/client.cpp b/hive/libhive/client.cpp index 8a8a4776..6cb76264 100644 --- a/hive/libhive/client.cpp +++ b/hive/libhive/client.cpp @@ -1,5 +1,6 @@ #include "client.h" #include +#include Client::Client(QObject *parent) : QObject(parent) @@ -18,16 +19,26 @@ void Client::connectionError(QAbstractSocket::SocketError error) void Client::readData() { - + QByteArray message; + while(m_tcpSocket->canReadLine()){ + QByteArray dataLine = m_tcpSocket->readLine(); + message.append(dataLine); + if(dataLine == "}\n"){ + emit jsonDataAvailable(message); + message.clear(); + } + } } void Client::connectedToHost() { qDebug() << "connected to hive server"; + emit connected(); } void Client::connectToHost(QString ipAddress, QString port) { + qDebug() << "connecting to" << ipAddress << ":" << port; m_tcpSocket->connectToHost(QHostAddress(ipAddress), port.toInt()); } @@ -37,7 +48,7 @@ void Client::disconnectFromHost() qDebug() << "connection to hive server closed"; } -void Client::sendData(QString target, QString command) +void Client::sendData(QByteArray data) { - + m_tcpSocket->write(data); } diff --git a/hive/libhive/client.h b/hive/libhive/client.h index a4d0d159..e3bedc7a 100644 --- a/hive/libhive/client.h +++ b/hive/libhive/client.h @@ -8,7 +8,7 @@ class Client : public QObject { Q_OBJECT - //Q_PROPERTY(QString ipAddress READ ipAddress WRITE setIpAddress NOTIFY ipAddressChanged) + public: explicit Client(QObject *parent = 0); @@ -19,6 +19,9 @@ private: signals: + void connected(); + void jsonDataAvailable(const QByteArray &data); + private slots: void connectionError(QAbstractSocket::SocketError error); @@ -28,7 +31,7 @@ private slots: public slots: void connectToHost(QString ipAddress, QString port); void disconnectFromHost(); - void sendData(QString target, QString command); + void sendData(QByteArray data); }; #endif // CLIENT_H diff --git a/hive/libhive/jsonhandler.cpp b/hive/libhive/jsonhandler.cpp index 6f0d74b6..2b31b17b 100644 --- a/hive/libhive/jsonhandler.cpp +++ b/hive/libhive/jsonhandler.cpp @@ -7,9 +7,11 @@ JsonHandler::JsonHandler(QObject *parent) : QObject(parent) { - + m_device = new DeviceJsonPlugin(this); } + + QByteArray JsonHandler::process(const QByteArray &data) { QJsonParseError error; @@ -18,8 +20,43 @@ QByteArray JsonHandler::process(const QByteArray &data) 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); + }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 index 56e386e4..e530d564 100644 --- a/hive/libhive/jsonhandler.h +++ b/hive/libhive/jsonhandler.h @@ -2,6 +2,9 @@ #define JSONHANDLER_H #include +#include +#include +#include class JsonHandler : public QObject @@ -10,9 +13,6 @@ class JsonHandler : public QObject public: explicit JsonHandler(QObject *parent = 0); -private: - - signals: void notifyAll(const QByteArray &data); @@ -20,6 +20,13 @@ signals: public slots: QByteArray process(const QByteArray &data); +private: + DeviceJsonPlugin *m_device; + + + QByteArray formatResponse(const QVariantMap &command, const QVariantMap &responseParams); + QByteArray formatErrorResponse(const QVariantMap &command, const QString &error); + }; diff --git a/hive/libhive/jsonplugin/devicejsonplugin.cpp b/hive/libhive/jsonplugin/devicejsonplugin.cpp new file mode 100644 index 00000000..7e488b32 --- /dev/null +++ b/hive/libhive/jsonplugin/devicejsonplugin.cpp @@ -0,0 +1,75 @@ +#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) +{ + // check if we have a id + if(!command.contains("id")){ + qDebug() << "request contains no id.."; + } + + // check the methods + if(command.value("method").toString() == "add"){ + qDebug() << "got a ADD DEVICE command"; + add(parameters); + } + + return 0; +} + +void DeviceJsonPlugin::add(QVariantMap parameters) +{ + 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(); + } +} + +void DeviceJsonPlugin::remove() +{ + +} + +void DeviceJsonPlugin::editValue(QString value, QVariant key) +{ + +} + +void DeviceJsonPlugin::getAll() +{ + +} + +QByteArray DeviceJsonPlugin::formatResponse() +{ + +} + +QByteArray DeviceJsonPlugin::formatErrorResponse() +{ + +} diff --git a/hive/libhive/jsonplugin/devicejsonplugin.h b/hive/libhive/jsonplugin/devicejsonplugin.h new file mode 100644 index 00000000..9e008d1e --- /dev/null +++ b/hive/libhive/jsonplugin/devicejsonplugin.h @@ -0,0 +1,32 @@ +#ifndef DEVICEJSONPLUGIN_H +#define DEVICEJSONPLUGIN_H + +#include +#include +#include +#include + +class DeviceJsonPlugin : public JsonPlugin +{ +public: + explicit DeviceJsonPlugin(QObject *parent = 0); + QString deviceName(); + QByteArray process(const QVariantMap &command, const QVariantMap ¶meters); + +private: + DeviceManager *m_deviceManager; + + void add(QVariantMap parameters); + void remove(); + void editValue(QString value, QVariant key); + void getAll(); + + QByteArray formatResponse(); + QByteArray formatErrorResponse(); + +signals: + + +}; + +#endif // DEVICEJSONPLUGIN_H diff --git a/hive/libhive/jsonplugin/jsonplugin.cpp b/hive/libhive/jsonplugin/jsonplugin.cpp new file mode 100644 index 00000000..920f080b --- /dev/null +++ b/hive/libhive/jsonplugin/jsonplugin.cpp @@ -0,0 +1,7 @@ +#include "jsonplugin.h" + +JsonPlugin::JsonPlugin(QObject *parent) : + QObject(parent) +{ +} + diff --git a/hive/libhive/jsonplugin/jsonplugin.h b/hive/libhive/jsonplugin/jsonplugin.h new file mode 100644 index 00000000..49c0d0a0 --- /dev/null +++ b/hive/libhive/jsonplugin/jsonplugin.h @@ -0,0 +1,22 @@ +#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; + + +signals: + +public slots: + +}; + +#endif // JSONPLUGIN_H diff --git a/hive/libhive/libhive.pro b/hive/libhive/libhive.pro index 28dddfdf..fe8d1bc6 100644 --- a/hive/libhive/libhive.pro +++ b/hive/libhive/libhive.pro @@ -19,7 +19,9 @@ SOURCES += libhive.cpp \ devicemanager.cpp \ logwriter.cpp \ client.cpp \ - jsonhandler.cpp + jsonhandler.cpp \ + jsonplugin/jsonplugin.cpp \ + jsonplugin/devicejsonplugin.cpp HEADERS += libhive.h\ libhive_global.h \ @@ -27,7 +29,9 @@ HEADERS += libhive.h\ devicemanager.h \ logwriter.h \ client.h \ - jsonhandler.h + jsonhandler.h \ + jsonplugin/jsonplugin.h \ + jsonplugin/devicejsonplugin.h #unix:!symbian { # maemo5 { diff --git a/hive/libhive/server.cpp b/hive/libhive/server.cpp index 2ff8e00b..991dd770 100644 --- a/hive/libhive/server.cpp +++ b/hive/libhive/server.cpp @@ -1,5 +1,6 @@ #include "server.h" #include +#include Server::Server(QObject *parent) : QObject(parent) @@ -26,7 +27,7 @@ void Server::newClientConnected() // append the new client to the client list m_clientList.append(newConnection); - connect(newConnection, SIGNAL(readyRead()), SLOT(readPackage())); + connect(newConnection, SIGNAL(readyRead()),this,SLOT(readPackage())); connect(newConnection,SIGNAL(disconnected()),this,SLOT(clientDisconnected())); } @@ -35,10 +36,17 @@ void Server::newClientConnected() void Server::readPackage() { QTcpSocket *client = qobject_cast(sender()); + //qDebug() << "-----------> data comming from" << client->peerAddress().toString(); + QByteArray message; while(client->canReadLine()){ - QByteArray data = client->readLine(); - qDebug() << "data to parse:" << data.remove(data.length() - 1, 1); - emit dataLineAvailable(data); + QByteArray dataLine = client->readLine(); + //qDebug() << "line in:" << dataLine; + message.append(dataLine); + if(dataLine == "}\n"){ + //qDebug() << message; + emit jsonDataAvailable(message); + message.clear(); + } } } diff --git a/hive/libhive/server.h b/hive/libhive/server.h index add15788..ca1038c8 100644 --- a/hive/libhive/server.h +++ b/hive/libhive/server.h @@ -18,7 +18,7 @@ private: signals: - void dataLineAvailable(const QByteArray &dataLine); + void jsonDataAvailable(const QByteArray &data); private slots: void newClientConnected(); diff --git a/hive/server/hive_pi/hivecore.cpp b/hive/server/hive_pi/hivecore.cpp index 23533432..8f62ccab 100644 --- a/hive/server/hive_pi/hivecore.cpp +++ b/hive/server/hive_pi/hivecore.cpp @@ -9,20 +9,26 @@ HiveCore::HiveCore(QObject *parent) : m_server->startServer(); m_deviceManager = new DeviceManager(this); + m_deviceManager->getDevices(); + + m_jsonHandler = new JsonHandler(this); - // create 433.92 MHz sender - m_sender = new RadioSender(this); - m_sender->setFrequency(RadioSender::RF433MHz); - m_sender->setLineCode(RadioSender::REMOTE); - m_sender->setPulseLength(320); - //m_sender->sendBin("000000000000010101010001"); + connect(m_server,SIGNAL(jsonDataAvailable(QByteArray)),m_jsonHandler,SLOT(process(QByteArray))); - // create 433.92 MHz receiver - m_reciver = new RadioReciver(this); - m_reciver->setFrequency(RadioReciver::RF433MHz); - m_reciver->setPin(2); - m_reciver->enableReceiver(); +// // create 433.92 MHz sender +// m_sender = new RadioSender(this); +// m_sender->setFrequency(RadioSender::RF433MHz); +// m_sender->setLineCode(RadioSender::REMOTE); +// m_sender->setPulseLength(320); +// //m_sender->sendBin("000000000000010101010001"); + +// // create 433.92 MHz receiver +// m_reciver = new RadioReciver(this); +// m_reciver->setFrequency(RadioReciver::RF433MHz); +// m_reciver->setPin(2); +// m_reciver->enableReceiver(); + } diff --git a/hive/server/hive_pi/hivecore.h b/hive/server/hive_pi/hivecore.h index 9202b8b4..77eab66a 100644 --- a/hive/server/hive_pi/hivecore.h +++ b/hive/server/hive_pi/hivecore.h @@ -4,6 +4,7 @@ #include #include "server.h" #include "devicemanager.h" +#include #include "radio/radioreciver.h" #include "radio/radiosender.h" @@ -15,9 +16,11 @@ public: private: Server *m_server; - RadioReciver *m_reciver; - RadioSender *m_sender; - DeviceManager *m_deviceManager; + //RadioReciver *m_reciver; + //RadioSender *m_sender; + //DeviceManager *m_deviceManager; + JsonHandler *m_jsonHandler; + signals: public slots: diff --git a/hive/server/hive_pi/radio/radioreciver.cpp b/hive/server/hive_pi/radio/radioreciver.cpp index 137a8a5d..1e1e373e 100644 --- a/hive/server/hive_pi/radio/radioreciver.cpp +++ b/hive/server/hive_pi/radio/radioreciver.cpp @@ -182,8 +182,20 @@ void RadioReciver::detectProtocol(QList rawData) qDebug() <<"VALID SIGNAL (48 bit)" << " --> pulse width =" << rawData.first()/31; qDebug() << rawData; +// int pulseWidth = rawData.first()/31; + +// QList rawDataKGV; +// foreach (int timing, rawData){ +// int kgv = ((float)timing/pulseWidth)+0.5; +// rawDataKGV.append(kgv); +// } +// qDebug() << "-------= " << rawDataKGV; + } + +//void RadioReciver::detectProtocol(int signalCount) +//{ // if(signalCount < 49){ // //qDebug() << "ERROR: got a signal with just" << signalCount << "signals"; // return;