}
}
+std::list<std::string> Core::sourcesForProperty(VehicleProperty::Property property)
+{
+ std::list<std::string> l;
+
+ for(auto itr = mSources.begin(); itr != mSources.end(); itr++)
+ {
+ AbstractSource* src = *itr;
+
+ PropertyList s = src->supported();
+
+ if(ListPlusPlus<VehicleProperty::Property>(&s).contains(property))
+ {
+ l.push_back(src->uuid());
+ }
+ }
+
+ return l;
+}
+
void Core::registerSink(AbstractSink *self)
{
if(!ListPlusPlus<AbstractSink*>(&mSinks).contains(self))
/// sinks:
virtual void registerSink(AbstractSink* self) = 0;
virtual void unregisterSink(AbstractSink* self) = 0;
+
+ /**
+ * @brief sourcesForProperty
+ * @param property
+ * @return list of source uuid's that support the "property"
+ */
+ virtual std::list<std::string> sourcesForProperty(VehicleProperty::Property property) = 0;
+
+ /**
+ * @brief getPropertyAsync requests a property value from a source. This call has a timeout and will always return.
+ * @see AsyncPropertyRequest
+ * @see AsyncPropertyReply.
+ * @param request requested property.
+ * @return AsyncPropertyReply. The returned AsyncPropertyReply is owned by the caller of getPropertyAsync.
+ * @example AsyncPropertyRequest request;
+ * request.property = VehicleProperty::VehicleSpeed
+ * request.completed = [](AsyncPropertyReply* reply) { delete reply; };
+ * routingEngine->getPropertyAsync(request);
+ */
virtual AsyncPropertyReply * getPropertyAsync(AsyncPropertyRequest request) = 0;
virtual AsyncRangePropertyReply * getRangePropertyAsync(AsyncRangePropertyRequest request) = 0;
virtual AsyncPropertyReply * setProperty(AsyncSetPropertyRequest request) = 0;
//No reply found
//printf("Error!\n");
DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Error resetting ELM"<<endl;
+ return false;
}
else
{
{
//printf("Error sending echo\n");
DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Error setting auto protocol"<<endl;
+ return false;
}
if (!sendElmCommand(obd,"ATE0"))
{
//printf("Error sending echo\n");
DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Error turning off echo"<<endl;
+ return false;
}
if (!sendElmCommand(obd,"ATH0"))
{
//printf("Error sending headers off\n");
DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Error turning off headers"<<endl;
+ return false;
}
if (!sendElmCommand(obd,"ATL0"))
{
//printf("Error turning linefeeds off\n");
DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Error turning off linefeeds"<<endl;
+ return false;
}
obd->sendObdRequestString("010C1\r",6,&replyVector,500,5);
+
+ return true;
}
void threadLoop(gpointer data)
//commandMap[req->req] = req->arg;
//printf("Command: %s\n",req->req.c_str());
DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Command:" << req->req << endl;
- if (req->req == "connect")
+ if (req->req == "connect" )
{
-
+
if (source->m_isBluetooth)
{
ObdBluetoothDevice bt;
port = req->arglist[0];
baud = req->arglist[1];
}
- connected = connect(obd,port,baud);
+ bool isconnected = connect(obd,port,baud);
- if(connected)
+ if(isconnected)
{
StatusMessage *statusreq = new StatusMessage();
statusreq->statusStr = "connected";
g_async_queue_push(privStatusQueue,statusreq);
}
- else
+ else if(!isconnected && connected)
{
StatusMessage *statusreq = new StatusMessage();
statusreq->statusStr = "disconnected";
g_async_queue_push(privStatusQueue,statusreq);
}
+
+ connected = isconnected;
}
else if (req->req == "connectifnot")
DebugOut(3)<<"Using bluetooth device \""<<source->m_btDeviceAddress<<"\" bound to: "<<tempPort<<endl;
port = tempPort;
}
+ else
+ {
+ DebugOut(DebugOut::Error)<<"Error creating bluetooth device"<<endl;
+ }
}
- connected = connect(obd,port,baud);
+ bool isconnected = connect(obd,port,baud);
- if(connected)
+ if(isconnected)
{
StatusMessage *statusreq = new StatusMessage();
statusreq->statusStr = "connected";
g_async_queue_push(privStatusQueue,statusreq);
}
- else
+ else if(!isconnected && connected)
{
StatusMessage *statusreq = new StatusMessage();
statusreq->statusStr = "disconnected";
g_async_queue_push(privStatusQueue,statusreq);
}
+
+ connected = isconnected;
}
}
else if (req->req == "setportandbaud")