From 9d72cf0566d4a5ad4c31f03c7f41e3ebfa3e3b9a Mon Sep 17 00:00:00 2001 From: Michael Carpenter Date: Wed, 21 Nov 2012 17:56:21 -0500 Subject: [PATCH] Change so BT rfcomm port name is re-reqested every time a connect is requested --- plugins/obd2plugin/obd2source.cpp | 32 +++++++++++++++++++++++++++++++- plugins/obd2plugin/obd2source.h | 3 +++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/plugins/obd2plugin/obd2source.cpp b/plugins/obd2plugin/obd2source.cpp index d3899c1..8eb2c48 100644 --- a/plugins/obd2plugin/obd2source.cpp +++ b/plugins/obd2plugin/obd2source.cpp @@ -157,13 +157,39 @@ void threadLoop(gpointer data) DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Command:" << req->req << endl; if (req->req == "connect") { - connect(obd,req->arglist[0],req->arglist[1]); + + if (source->m_isBluetooth) + { + ObdBluetoothDevice bt; + std::string tempPort = bt.getDeviceForAddress(source->m_btDeviceAddress, source->m_btAdapterAddress); + if(tempPort != "") + { + DebugOut(3)<<"Using bluetooth device \""<m_btDeviceAddress<<"\" bound to: "<arglist[0]; + baud = req->arglist[1]; + } + connect(obd,port,baud); connected = true; } else if (req->req == "connectifnot") { if (!connected) { + if (source->m_isBluetooth) + { + ObdBluetoothDevice bt; + std::string tempPort = bt.getDeviceForAddress(source->m_btDeviceAddress, source->m_btAdapterAddress); + if(tempPort != "") + { + DebugOut(3)<<"Using bluetooth device \""<m_btDeviceAddress<<"\" bound to: "< config) std::string port = "/dev/ttyUSB0"; std::string baud = "115200"; std::string btadapter = ""; + m_isBluetooth = false; //Try to load config //printf("OBD2Source::setConfiguration\n"); @@ -479,6 +506,9 @@ void OBD2Source::setConfiguration(map config) if(port.find(":") != string::npos) { + m_btDeviceAddress = port; + m_btAdapterAddress = btadapter; + m_isBluetooth = true; ///TODO: bluetooth!! DebugOut()<<"bluetooth device?"< propertyReplyMap; void updateProperty(VehicleProperty::Property property,AbstractPropertyType *value); obdLib * obd; -- 2.7.4