diff options
author | Kevron Rees <kevron.m.rees@intel.com> | 2014-05-28 13:45:43 -0700 |
---|---|---|
committer | Kevron Rees <kevron.m.rees@intel.com> | 2014-05-28 13:45:43 -0700 |
commit | 5bd2ccf19c04a1d5100af84d0806cd9c5168b75c (patch) | |
tree | 8a83d9d49d6b1dfb8016e1be070c458d75a5c474 | |
parent | 2dddacdbb338b5aafd29b07fabbec34a9d21dd80 (diff) | |
download | automotive-message-broker-5bd2ccf19c04a1d5100af84d0806cd9c5168b75c.tar.gz |
added more debug to bluetooth
-rw-r--r-- | plugins/bluetooth/bluetoothplugin.cpp | 2 | ||||
-rw-r--r-- | plugins/bluetooth/testAmbBt.cpp | 19 | ||||
-rw-r--r-- | plugins/common/bluetooth5.cpp | 29 | ||||
-rw-r--r-- | plugins/common/serialport.hpp | 6 | ||||
-rw-r--r-- | plugins/websocket/protocol | 10 | ||||
-rw-r--r-- | plugins/websocket/websocketsinkmanager.cpp | 1 |
6 files changed, 48 insertions, 19 deletions
diff --git a/plugins/bluetooth/bluetoothplugin.cpp b/plugins/bluetooth/bluetoothplugin.cpp index 76c3076e..451e10d8 100644 --- a/plugins/bluetooth/bluetoothplugin.cpp +++ b/plugins/bluetooth/bluetoothplugin.cpp @@ -109,7 +109,7 @@ void BluetoothSinkPlugin::release() void BluetoothSinkPlugin::newConnection(string path, QDBusUnixFileDescriptor fd, QVariantMap props) { - DebugOut()<<"new Connection! Path: "<<path<<endl; + DebugOut()<<"new Connection! Path: "<<path<<" fd: "<<fd.fileDescriptor()<<endl; socket.setDescriptor(fd.fileDescriptor()); diff --git a/plugins/bluetooth/testAmbBt.cpp b/plugins/bluetooth/testAmbBt.cpp index f00c0466..53b470d9 100644 --- a/plugins/bluetooth/testAmbBt.cpp +++ b/plugins/bluetooth/testAmbBt.cpp @@ -3,7 +3,7 @@ #include <QCoreApplication> #include <QJsonDocument> #include <QStringList> -#include <QSocketNotifier> +#include <QDebug> #include "bluetooth5.h" #include <serialport.hpp> @@ -38,9 +38,14 @@ int main(int argc, char** argv) QString addy = app.arguments().at(1); + DebugOut::setDebugThreshhold(6); + + qDebug()<<"connecting to: "<<addy; + Bluetooth5 btdev; - btdev.getDeviceForAddress(addy.toStdString(),[](int fd){ - DebugOut(0)<<"I am connected"<<endl; + btdev.getDeviceForAddress(addy.toStdString(),[](int fd) + { + qDebug()<<"I am connected "<<fd; s->setDescriptor(fd); GIOChannel *chan = g_io_channel_unix_new(s->fileDescriptor()); @@ -48,8 +53,12 @@ int main(int argc, char** argv) g_io_channel_set_close_on_unref(chan, true); g_io_channel_unref(chan); - s->write("ping"); + s->write("ping\r\n"); }); - return app.exec(); + app.exec(); + + s->close(); + + return 1; } diff --git a/plugins/common/bluetooth5.cpp b/plugins/common/bluetooth5.cpp index 43a90580..b1934db1 100644 --- a/plugins/common/bluetooth5.cpp +++ b/plugins/common/bluetooth5.cpp @@ -42,7 +42,7 @@ static void handleMethodCall(GDBusConnection *connection, DebugOut()<<"NewConnection() called"<<endl; gchar* device; - int fd; + gint32 fd; GVariantIter* iter; g_variant_get(parameters,"(oha{sv})", &device, &fd, &iter); @@ -55,7 +55,7 @@ static void handleMethodCall(GDBusConnection *connection, } else { - g_dbus_method_invocation_return_error(invocation,G_DBUS_ERROR,G_DBUS_ERROR_UNKNOWN_METHOD, "Unknown method."); + g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD, "Unknown method."); } /// return nothing: @@ -292,15 +292,26 @@ void Bluetooth5::getDeviceForAddress(std::string address, ConnectedCallback conn GError* error = nullptr; - g_dbus_proxy_call_sync(deviceProxy,"Connect", nullptr/*g_variant_new("(s)", "00001101-0000-1000-8000-00805F9B34FB")*/,G_DBUS_CALL_FLAGS_NONE,-1, nullptr, &error); - - if(error) + g_dbus_proxy_call(deviceProxy, "Connect", nullptr, G_DBUS_CALL_FLAGS_NONE, -1, nullptr,[](GObject *source_object, + GAsyncResult *res, + gpointer user_data) { - DebugOut(DebugOut::Error)<<"error trying to connect profile: "<<error->message<<endl; - g_error_free(error); + + GError* error = nullptr; + GDBusProxy *deviceProxy = (GDBusProxy*)user_data; + + g_dbus_proxy_call_finish(G_DBUS_PROXY (source_object),res, &error); + + if(error) + { + DebugOut(DebugOut::Error)<<"error trying to connect profile: "<<error->message<<endl; + g_error_free(error); + } + g_object_unref(deviceProxy); - return; - } + }, deviceProxy); + + diff --git a/plugins/common/serialport.hpp b/plugins/common/serialport.hpp index fd049a7f..0908687e 100644 --- a/plugins/common/serialport.hpp +++ b/plugins/common/serialport.hpp @@ -12,6 +12,7 @@ #include <fcntl.h> #include <termios.h> #include <errno.h> +#include <stdio.h> class SerialPort: public AbstractIo { @@ -113,14 +114,15 @@ public: int written = ::write(fd,data.c_str(),data.length()); if(written == -1) { - DebugOut()<<"Unable to write"<<endl; + DebugOut(DebugOut::Warning)<<"Unable to write ("<<fd<<")"<<endl; + perror("write error: "); } } void setDescriptor(int d) { fd = d; - setupDevice(); + //setupDevice(); } private: ///methods diff --git a/plugins/websocket/protocol b/plugins/websocket/protocol index d28da6c5..d7089c9f 100644 --- a/plugins/websocket/protocol +++ b/plugins/websocket/protocol @@ -4,7 +4,7 @@ Property changed event: {"type":"valuechanged","name":"VehicleSpeed","data":{"value":"217","zone": 0, "timestamp":"1354521964.60253","sequence":"0"}, "transactionid":"d293f670-f0b3-11e1-aff1-0800200c9a66", } Get property request: -{"type":"method","name":"get","data":"VehicleSpeed","transactionid":"d293f670-f0b3-11e1-aff1-0800200c9a66"} +{"type":"method","name":"get","data": { "property" : "VehicleSpeed", "zone" : 0 }, "transactionid":"d293f670-f0b3-11e1-aff1-0800200c9a66"} Get property reply: {"type":"methodReply","name":"get","data":{"property":"VehicleSpeed","value":"17", "timestamp" : "1354521964.24962", "sequence": "0" },"transactionid":"d293f670-f0b3-11e1-aff1-0800200c9a66"} @@ -19,7 +19,13 @@ Subscribe to data: {"type":"method","name":"subscribe","data": {"property":"EngineSpeed", "zone": 0},"transactionid":"d293f670-f0b3-11e1-aff1-0800200c9a66"} Subscribe to data reply: -{"type":"methodReply","name":"subscribe","data":["EngineSpeed"],"transactionid":"d293f670-f0b3-11e1-aff1-0800200c9a66"} +{"type":"methodReply","name":"subscribe","data":"EngineSpeed","transactionid":"d293f670-f0b3-11e1-aff1-0800200c9a66"} Get History request: {"type":"method","name":"getRange","data": {"property":"VehicleSpeed", "timeBegin":"1368825008.35948","timeEnd":"1368825018.35948","sequenceBegin":"-1","sequenceEnd":"-1"},"transactionid":"b07589ba-417c-4604-80c6-01c0dcbd524d"} + +Set property request: +{ "type" : "method", "name" : "set", "data" : { "property" : "MachineGunTurretStatus", "value" : "true", "zone" : 0 }, "transactionid" : "4123123123" } + +Set property reply: +{ "type" : "methodReply", "name" : "set", "data" : { "property" : "MachineGunTurretStatus", "value" : "true", "zone" : 0, "success" : true }, "transactionid" : "4123123123" } diff --git a/plugins/websocket/websocketsinkmanager.cpp b/plugins/websocket/websocketsinkmanager.cpp index 7471d0f2..185620d7 100644 --- a/plugins/websocket/websocketsinkmanager.cpp +++ b/plugins/websocket/websocketsinkmanager.cpp @@ -297,6 +297,7 @@ void WebSocketSinkManager::setValue(libwebsocket* socket,VehicleProperty::Proper data["property"] = property.c_str(); data["zone"] = zone; data["source"] = reply->value->sourceUuid.c_str(); + data["success"] = reply->success; QVariantMap replyvar; replyvar["type"]="methodReply"; |