From 2da6ac425a28b243d409aac2b9faa187eac708be Mon Sep 17 00:00:00 2001 From: Kevron Rees Date: Fri, 16 May 2014 14:54:12 -0700 Subject: [PATCH] initial bluetooth plugin --- CMakeLists.txt | 2 +- plugins/CMakeLists.txt | 1 + plugins/bluetooth/CMakeLists.txt | 30 +++ plugins/bluetooth/bluetoothplugin.cpp | 113 +++++++++++ plugins/bluetooth/bluetoothplugin.h | 83 ++++++++ plugins/bluetooth/testAmbBt.cpp | 28 +++ plugins/common/bluetooth.hpp | 6 +- plugins/gpsnmea/gpsnmea.cpp | 1 - plugins/obdlinkcan/CMakeLists.txt | 14 -- plugins/obdlinkcan/obdlinkcan.cpp | 363 ---------------------------------- plugins/obdlinkcan/obdlinkcan.h | 68 ------- plugins/obdlinkcan/obdlinkmx.cpp | 1 - plugins/obdlinkcan/obdlinkmx.h | 60 ------ 13 files changed, 260 insertions(+), 510 deletions(-) create mode 100644 plugins/bluetooth/CMakeLists.txt create mode 100644 plugins/bluetooth/bluetoothplugin.cpp create mode 100644 plugins/bluetooth/bluetoothplugin.h create mode 100644 plugins/bluetooth/testAmbBt.cpp delete mode 100644 plugins/obdlinkcan/CMakeLists.txt delete mode 100644 plugins/obdlinkcan/obdlinkcan.cpp delete mode 100644 plugins/obdlinkcan/obdlinkcan.h delete mode 100644 plugins/obdlinkcan/obdlinkmx.cpp delete mode 100644 plugins/obdlinkcan/obdlinkmx.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 26bdc8d..874824f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,7 +33,7 @@ option(test_plugin "Test Plugin" ON) option(bluemonkey_plugin "bluemonkey irc plugin" OFF) option(gpsnmea_plugin "gps NMEA location plugin" OFF) option(openxc_plugin "OpenXC plugin" OFF) -option(obdlinkcan_plugin "ObdLink mx CAN plugin" OFF) +option(bluetooth_plugin "bluetooth plugin" OFF) option(cansim_plugin "Can simulator plugin" OFF) option(cangen_plugin "Can generator plugin" OFF) option(enable_icecc "Enable icecc checking, for distributed compilation" ON) diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 191955e..d983bf3 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -36,5 +36,6 @@ add_subdirectory(testplugin) add_subdirectory(bluemonkey) add_subdirectory(gpsnmea) add_subdirectory(openxc) +add_subdirectory(bluetooth) add_subdirectory(cansimplugin) add_subdirectory(cangenplugin) diff --git a/plugins/bluetooth/CMakeLists.txt b/plugins/bluetooth/CMakeLists.txt new file mode 100644 index 0000000..5000a2b --- /dev/null +++ b/plugins/bluetooth/CMakeLists.txt @@ -0,0 +1,30 @@ +if(bluetooth_plugin) + +set(bluetooth_headers bluetoothplugin.h) +set(bluetooth_sources bluetoothplugin.cpp ) + +find_package(Qt5Core REQUIRED) +find_package(Qt5DBus REQUIRED) +find_package(Qt5Network REQUIRED) + +message(STATUS ${Qt5DBus_INCLUDE_DIRS}) + +set(QT_INCLUDE_DIRS ${Qt5Core_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS}) +set(QT_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5DBus_LIBRARIES} ${Qt5Network_LIBRARIES}) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") +add_definitions(${Qt5Core_DEFINITIONS}) + +set(CMAKE_AUTOMOC ON) + +include_directories(${CMAKE_SOURCE_DIR}/lib ${include_dirs} ${gio_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/plugins/common ${QT_INCLUDE_DIRS}) + +add_library(bluetoothplugin MODULE ${bluetooth_sources}) +set_target_properties(bluetoothplugin PROPERTIES PREFIX "") +target_link_libraries(bluetoothplugin amb -L${CMAKE_CURRENT_BINARY_DIR}/lib amb-plugins-common -L${CMAKE_CURRENT_BINARY_DIR}/plugins/common ${link_libraries} ${gio_LIBRARIES} ${QT_LIBRARIES}) + +install(TARGETS bluetoothplugin LIBRARY DESTINATION lib/automotive-message-broker) + +add_executable(testAmbBt "testAmbBt.cpp") +target_link_libraries(testAmbBt ${link_libraries} amb -L${CMAKE_CURRENT_BINARY_DIR}/lib amb-plugins-common -L${CMAKE_CURRENT_BINARY_DIR}/plugins/common ${QT_LIBRARIES}) + +endif(bluetooth_plugin) diff --git a/plugins/bluetooth/bluetoothplugin.cpp b/plugins/bluetooth/bluetoothplugin.cpp new file mode 100644 index 0000000..86ca0d9 --- /dev/null +++ b/plugins/bluetooth/bluetoothplugin.cpp @@ -0,0 +1,113 @@ +/* +Copyright (C) 2012 Intel Corporation + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "bluetoothplugin.h" +#include "timestamp.h" +#include "listplusplus.h" + +#include +#include +#include +#include + +#include +#include + +using namespace std; + +#include "debugout.h" + +BluetoothSinkPlugin::BluetoothSinkPlugin(AbstractRoutingEngine* re, map config) +:AbstractSink(re, config) +{ + new BtProfileAdaptor(this); + + QDBusConnection::systemBus().registerObject("/org/bluez/spp", this); +} + + + +extern "C" AbstractSink * create(AbstractRoutingEngine* routingengine, map config) +{ + return new BluetoothSinkPlugin(routingengine, config); + +} + +const string BluetoothSinkPlugin::uuid() +{ + return "47ec4ed0-dc45-11e3-9c1a-0800200c9a66"; +} + +void BluetoothSinkPlugin::propertyChanged(AbstractPropertyType *value) +{ + +} + +void BluetoothSinkPlugin::release() +{ + DebugOut()<<"release called."<release(); +} + +void BtProfileAdaptor::NewConnection(QDBusObjectPath device, int fd, QVariantMap fd_properties) +{ + mParent->newConnection(device.path().toStdString(), fd, fd_properties); +} + +void BtProfileAdaptor::RequestDisconnection(QDBusObjectPath device) +{ + mParent->requestDisconnection(device.path().toStdString()); +} diff --git a/plugins/bluetooth/bluetoothplugin.h b/plugins/bluetooth/bluetoothplugin.h new file mode 100644 index 0000000..0754865 --- /dev/null +++ b/plugins/bluetooth/bluetoothplugin.h @@ -0,0 +1,83 @@ +/* +Copyright (C) 2012 Intel Corporation + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef BT_PLUGIN_H_ +#define BT_PLUGIN_H_ + +#include +#include + +#include +#include +#include +#include + +class BluetoothSinkPlugin; + +class BtProfileAdaptor : public QDBusAbstractAdaptor +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "org.bluez.Profile1") + +public: + + BtProfileAdaptor(BluetoothSinkPlugin* parent); + +public Q_SLOTS: + + void Release(); + + void NewConnection(QDBusObjectPath device, int fd, QVariantMap fd_properties); + + void RequestDisconnection(QDBusObjectPath device); + +private: + + BluetoothSinkPlugin* mParent; + +}; + +class BluetoothSinkPlugin: public QObject, public AbstractSink +{ +Q_OBJECT + +public: + BluetoothSinkPlugin(AbstractRoutingEngine* re, map config); + + const string uuid(); + + void supportedChanged(const PropertyList &) {} + + void propertyChanged(AbstractPropertyType* value); + + void release(); + + void newConnection(std::string path, int fd, QVariantMap props); + + void requestDisconnection(std::string path); + +private Q_SLOTS: + void canHasData(); + +private: + QTcpSocket socket; +}; + + + +#endif // EXAMPLEPLUGIN_H diff --git a/plugins/bluetooth/testAmbBt.cpp b/plugins/bluetooth/testAmbBt.cpp new file mode 100644 index 0000000..6940e40 --- /dev/null +++ b/plugins/bluetooth/testAmbBt.cpp @@ -0,0 +1,28 @@ +#include +#include +#include +#include +#include +#include + +int main(int argc, char** argv) +{ + QCoreApplication app(argc, argv); + + QString addy = app.arguments().at(1); + + BluetoothDevice dev; + std::string devPath = dev.getDeviceForAddress(addy.toStdString()); + + QFile f(devPath.c_str()); + f.open(QIODevice::ReadWrite); + + QObject::connect(&f, &QFile::readyRead, [&f](){ + QByteArray d = f.readAll(); + + DebugOut(DebugOut::Warning)<<"Data read: "< +#include + #include "bluetoothmanagerproxy.h" #include "bluetoothadapterproxy.h" #include "bluetoothserialproxy.h" diff --git a/plugins/gpsnmea/gpsnmea.cpp b/plugins/gpsnmea/gpsnmea.cpp index 75ff340..75f6e43 100644 --- a/plugins/gpsnmea/gpsnmea.cpp +++ b/plugins/gpsnmea/gpsnmea.cpp @@ -402,7 +402,6 @@ GpsNmeaSource::GpsNmeaSource(AbstractRoutingEngine *re, map conf addPropertySupport(VehicleProperty::Direction, Zone::None); addPropertySupport(GPSTIME, Zone::None); - ///test: if(config.find("test") != config.end()) diff --git a/plugins/obdlinkcan/CMakeLists.txt b/plugins/obdlinkcan/CMakeLists.txt deleted file mode 100644 index 3f2a048..0000000 --- a/plugins/obdlinkcan/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -if(obdlinkcan_plugin) - -set(obdlinkcan_headers obdlinkcan.h obdlinkmx.h) -set(obdlinkcan_sources obdlinkcan.cpp obdlinkmx.cpp) - -include_directories(${CMAKE_SOURCE_DIR}/lib ${include_dirs} ${gio_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/plugins/common) - -add_library(obdlinkcan MODULE ${obdlinkcan_sources}) -set_target_properties(obdlinkcan PROPERTIES PREFIX "") -target_link_libraries(obdlinkcan amb -L${CMAKE_CURRENT_BINARY_DIR}/lib amb-plugins-common -L${CMAKE_CURRENT_BINARY_DIR}/plugins/common ${link_libraries} boost_regex ${gio_LIBRARIES}) - -install(TARGETS obdlinkcan LIBRARY DESTINATION lib/automotive-message-broker) - -endif(obdlinkcan_plugin) diff --git a/plugins/obdlinkcan/obdlinkcan.cpp b/plugins/obdlinkcan/obdlinkcan.cpp deleted file mode 100644 index ecf2d40..0000000 --- a/plugins/obdlinkcan/obdlinkcan.cpp +++ /dev/null @@ -1,363 +0,0 @@ -/* -Copyright (C) 2012 Intel Corporation - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include "obdlinkcan.h" -#include "timestamp.h" -#include "listplusplus.h" - -#include -#include -#include - -using namespace std; - -#include "debugout.h" - - -ObdLinkCAN::ObdLinkCAN(AbstractRoutingEngine* re, map config) -:AbstractSource(re, config), velocity(0), engineSpeed(0) -{ - debugOut("setting timeout"); - g_timeout_add(1000, timeoutCallback, this ); - - addPropertySupport(VehicleProperty::EngineSpeed, Zone::None); - addPropertySupport(VehicleProperty::VehicleSpeed, Zone::None); - addPropertySupport(VehicleProperty::AccelerationX, Zone::None); - addPropertySupport(VehicleProperty::TransmissionShiftPosition, Zone::None); - addPropertySupport(VehicleProperty::SteeringWheelAngle, Zone::None); - addPropertySupport(VehicleProperty::ThrottlePosition, Zone::None); - addPropertySupport(VehicleProperty::EngineCoolantTemperature, Zone::None); - addPropertySupport(VehicleProperty::VIN, Zone::None); - addPropertySupport(VehicleProperty::WMI, Zone::None); - addPropertySupport(VehicleProperty::BatteryVoltage, Zone::None); - addPropertySupport(VehicleProperty::MachineGunTurretStatus, Zone::None); - addPropertySupport(VehicleProperty::ExteriorBrightness, Zone::None); - addPropertySupport(VehicleProperty::DoorsPerRow, Zone::None); - addPropertySupport(VehicleProperty::AirbagStatus, Zone::None); - - Zone::ZoneList airbagZones; - airbagZones.push_back(Zone::FrontLeft | Zone::FrontSide); - airbagZones.push_back(Zone::FrontRight | Zone::FrontSide); - airbagZones.push_back(Zone::RearLeft | Zone::LeftSide); - airbagZones.push_back(Zone::RearRight | Zone::RightSide); - - airbagStatus[Zone::FrontLeft | Zone::FrontSide] = Airbag::Active; - airbagStatus[Zone::FrontRight | Zone::FrontSide] = Airbag::Inactive; - airbagStatus[Zone::RearLeft | Zone::LeftSide] = Airbag::Deployed; - airbagStatus[Zone::RearRight | Zone::RightSide] = Airbag::Deployed; - - PropertyInfo airbagInfo(0,airbagZones); - - propertyInfoMap[VehicleProperty::AirbagStatus] = airbagInfo; - - addPropertySupport(VehicleProperty::AirConditioning, Zone::None); - - Zone::ZoneList acZones; - acZones.push_back(Zone::FrontLeft); - acZones.push_back(Zone::Front | Zone::Right); - - acStatus[Zone::Front | Zone::Left] = true; - acStatus[Zone::Front | Zone::Right] = false; - - PropertyInfo acInfo(0,acZones); - propertyInfoMap[VehicleProperty::AirConditioning] = acInfo; - - re->setSupported(supported(), this); -} - - - -extern "C" AbstractSource * create(AbstractRoutingEngine* routingengine, map config) -{ - return new ObdLinkCAN(routingengine, config); - -} - -const string ObdLinkCAN::uuid() -{ - return "6dd4268a-c605-4a06-9034-59c1e8344c8e"; -} - - -void ObdLinkCAN::getPropertyAsync(AsyncPropertyReply *reply) -{ - DebugOut()<<"ExampleSource: getPropertyAsync called for property: "<property<property == VehicleProperty::VehicleSpeed) - { - VehicleProperty::VehicleSpeedType temp(velocity); - reply->value = &temp; - reply->success = true; - reply->completed(reply); - } - else if(reply->property == VehicleProperty::EngineSpeed) - { - VehicleProperty::EngineSpeedType temp(engineSpeed); - reply->value = &temp; - reply->success = true; - reply->completed(reply); - } - else if(reply->property == VehicleProperty::AccelerationX) - { - VehicleProperty::AccelerationXType temp(accelerationX); - reply->value = &temp; - reply->success = true; - reply->completed(reply); - } - else if(reply->property == VehicleProperty::TransmissionShiftPosition) - { - VehicleProperty::TransmissionShiftPositionType temp(transmissionShiftPostion); - reply->value = &temp; - reply->success = true; - reply->completed(reply); - } - else if(reply->property == VehicleProperty::SteeringWheelAngle) - { - VehicleProperty::SteeringWheelAngleType temp(steeringWheelAngle); - reply->value = &temp; - reply->success = true; - reply->completed(reply); - } - else if(reply->property == VehicleProperty::VIN) - { - VehicleProperty::VINType temp("ABC00000000000000"); - reply->value = &temp; - reply->success = true; - reply->completed(reply); - } - else if(reply->property == VehicleProperty::WMI) - { - VehicleProperty::WMIType temp("abc"); - reply->value = &temp; - reply->success = true; - reply->completed(reply); - } - else if(reply->property == VehicleProperty::BatteryVoltage) - { - VehicleProperty::BatteryVoltageType temp(12.6); - reply->value = &temp; - reply->success = true; - reply->completed(reply); - } - else if(reply->property == VehicleProperty::ExteriorBrightness) - { - VehicleProperty::ExteriorBrightnessType temp(1000); - reply->value = &temp; - reply->success = true; - reply->completed(reply); - } - else if(reply->property == VehicleProperty::DoorsPerRow) - { - VehicleProperty::DoorsPerRowType temp; - - BasicPropertyType row1(2); - BasicPropertyType row2(2); - BasicPropertyType row3(1); - - temp.append(&row1); - temp.append(&row2); - temp.append(&row3); - - reply->value = &temp; - reply->success = true; - reply->completed(reply); - } - else if(reply->property == VehicleProperty::AirbagStatus) - { - if(airbagStatus.find(reply->zoneFilter) == airbagStatus.end()) - { - reply->success = false; - reply->error = AsyncPropertyReply::ZoneNotSupported; - reply->completed(reply); - } - - else - { - - VehicleProperty::AirbagStatusType temp; - temp.setValue(airbagStatus[reply->zoneFilter]); - temp.zone = reply->zoneFilter; - - reply->value = &temp; - reply->success = true; - reply->completed(reply); - } - } - else if(reply->property == VehicleProperty::MachineGunTurretStatus) - { - VehicleProperty::MachineGunTurretStatusType temp(true); - reply->value = &temp; - reply->success = true; - reply->completed(reply); - } - else if(reply->property == VehicleProperty::ThrottlePosition) - { - VehicleProperty::ThrottlePositionType temp(throttlePos); - reply->value = &temp; - reply->success = true; - reply->completed(reply); - } - else if(reply->property == VehicleProperty::EngineCoolantTemperature) - { - VehicleProperty::EngineCoolantTemperatureType temp(engineCoolant); - reply->value = &temp; - reply->success = true; - reply->completed(reply); - } - else if(reply->property == VehicleProperty::AirbagStatus) - { - if(airbagStatus.find(reply->zoneFilter) == airbagStatus.end()) - { - reply->success = false; - reply->error = AsyncPropertyReply::ZoneNotSupported; - reply->completed(reply); - } - else - { - VehicleProperty::AirbagStatusType temp(airbagStatus[reply->zoneFilter]); - reply->success = true; - reply->value = &temp; - reply->completed(reply); - } - } - else if(reply->property == VehicleProperty::AirConditioning) - { - if(acStatus.find(reply->zoneFilter) == acStatus.end()) - { - reply->success = false; - reply->error = AsyncPropertyReply::ZoneNotSupported; - reply->completed(reply); - } - else - { - VehicleProperty::AirConditioningType temp(acStatus[reply->zoneFilter]); - reply->success = true; - reply->value = &temp; - reply->completed(reply); - } - } - - else - { - reply->success=false; - reply->error = AsyncPropertyReply::InvalidOperation; - reply->completed(reply); - } -} - -void ObdLinkCAN::getRangePropertyAsync(AsyncRangePropertyReply *reply) -{ - -} - -AsyncPropertyReply *ObdLinkCAN::setProperty(AsyncSetPropertyRequest request ) -{ - AsyncPropertyReply *reply = new AsyncPropertyReply(request); - - if(reply->property == VehicleProperty::AirConditioning) - { - if(acStatus.find(reply->zoneFilter) == acStatus.end()) - { - reply->success = false; - reply->error = AsyncPropertyReply::ZoneNotSupported; - reply->completed(reply); - } - else - { - acStatus[reply->zoneFilter] = reply->value->value(); - - ///we need to update subscribers of this change: - routingEngine->updateProperty(reply->value,uuid()); - - ///Now reply to the set request: - reply->success = true; - reply->completed(reply); - - } - } -} - -void ObdLinkCAN::subscribeToPropertyChanges(VehicleProperty::Property property) -{ - mRequests.push_back(property); -} - -PropertyList ObdLinkCAN::supported() -{ - return mSupported; -} - -int ObdLinkCAN::supportedOperations() -{ - return Get | Set | GetRanged; -} - -void ObdLinkCAN::unsubscribeToPropertyChanges(VehicleProperty::Property property) -{ - if(contains(mRequests,property)) - mRequests.remove(property); -} - -void ObdLinkCAN::randomizeProperties() -{ - velocity = 1 + (255.00 * (rand() / (RAND_MAX + 1.0))); - engineSpeed = 1 + (15000.00 * (rand() / (RAND_MAX + 1.0))); - accelerationX = 1 + (15000.00 * (rand() / (RAND_MAX + 1.0))); - transmissionShiftPostion = Transmission::TransmissionPositions(1 + (6.00 * (rand() / (RAND_MAX + 1.0)))); - steeringWheelAngle = 1 + (359.00 * (rand() / (RAND_MAX + 1.0))); - throttlePos = 1 + (100.00 * (rand() / (RAND_MAX + 1.0))); - engineCoolant = 1 + (40.00 * (rand() / (RAND_MAX + 140.0))); - - DebugOut()<<"setting velocity to: "<updateProperty(&vel, uuid()); - routingEngine->updateProperty(&es, uuid()); - routingEngine->updateProperty(&ac, uuid()); - routingEngine->updateProperty(&swa, uuid()); - routingEngine->updateProperty(&tsp, uuid()); - routingEngine->updateProperty(&tp, uuid()); - routingEngine->updateProperty(&ec, uuid()); - -} - -void ObdLinkCAN::addPropertySupport(VehicleProperty::Property property, Zone::Type zone) -{ - mSupported.push_back(property); - - std::list zones; - - zones.push_back(zone); - - PropertyInfo info(0, zones); - - propertyInfoMap[property] = info; -} diff --git a/plugins/obdlinkcan/obdlinkcan.h b/plugins/obdlinkcan/obdlinkcan.h deleted file mode 100644 index 3d26260..0000000 --- a/plugins/obdlinkcan/obdlinkcan.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -Copyright (C) 2012 Intel Corporation - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef ObdLinkCANPLUGIN_H -#define ObdLinkCANPLUGIN_H - -#include -#include - -using namespace std; - -class ObdLinkCAN: public AbstractSource -{ - -public: - ObdLinkCAN(AbstractRoutingEngine* re, map config); - - const string uuid(); - void getPropertyAsync(AsyncPropertyReply *reply); - void getRangePropertyAsync(AsyncRangePropertyReply *reply); - AsyncPropertyReply * setProperty(AsyncSetPropertyRequest request); - void subscribeToPropertyChanges(VehicleProperty::Property property); - void unsubscribeToPropertyChanges(VehicleProperty::Property property); - PropertyList supported(); - - int supportedOperations(); - - void supportedChanged(PropertyList) {} - - void randomizeProperties(); - - PropertyInfo getPropertyInfo(VehicleProperty::Property property) - { - if(propertyInfoMap.find(property) != propertyInfoMap.end()) - return propertyInfoMap[property]; - - return PropertyInfo::invalid(); - } - -private: - - void addPropertySupport(VehicleProperty::Property property, Zone::Type zone); - - std::map propertyInfoMap; - std::map airbagStatus; - std::map acStatus; - PropertyList mRequests; - PropertyList mSupported; - uint16_t velocity; - uint16_t engineSpeed; -}; - -#endif // ObdLinkCANPLUGIN_H diff --git a/plugins/obdlinkcan/obdlinkmx.cpp b/plugins/obdlinkcan/obdlinkmx.cpp deleted file mode 100644 index b895565..0000000 --- a/plugins/obdlinkcan/obdlinkmx.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "obdlinkmx.h" diff --git a/plugins/obdlinkcan/obdlinkmx.h b/plugins/obdlinkcan/obdlinkmx.h deleted file mode 100644 index e2871aa..0000000 --- a/plugins/obdlinkcan/obdlinkmx.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef ObdLinkMx_H_ -#define ObdLinkMx_H_ - -#include - - -class ObdLinkMx -{ -public: - enum Protocol{ - J1850PWM = 11, - J1850VPW = 12, - ISO9141 = 21, - ISO9141_2 = 22, - ISO14230 = 23, - ISO14230_autoinit = 24, - ISO14230_fastautoinit = 24, - HSCAN_ISO11898_11bit_500kbps_varDLC = 31, - HSCAN_ISO11898_29bit_500kbps_varDLC = 32, - HSCAN_ISO15765_11bit_500kbps_DLC8 = 33, - HSCAN_ISO15765_29bit_500kbps_DLC8 = 34, - HSCAN_ISO15765_11bit_250kbps_DLC8 = 35, - HSCAN_ISO15765_29bit_250kbps_DLC8 = 36, - J1939_11bit = 41, - J1939_29bit = 42, - MSCAN_ISO11898_11bit_125kbps_varDLC = 51, - MSCAN_ISO11898_29bit_125kbps_varDLC = 52, - MSCAN_ISO15765_11bit_125kbps_DLC8 = 53, - MSCAN_ISO15765_29bit_125kbps_DLC8 = 54, - SWCAN_ISO11898_11bit_33kbps_varDLC = 61, - SWCAN_ISO11898_29bit_33kbps_varDLC = 62, - SWCAN_ISO15765_11bit_33kbps_DLC8 = 63, - SWCAN_ISO15765_29bit_33kbps_DLC8 = 64 - }; - - enum SWCanMode { - Sleep = 0, - HighSpeed, - Wakeup, - Normal - }; - - ObdLinkMx(); - - void connect(); - void disconnect(); - - void setProtocol(Protocol protocol); - - Protocol protocol(); - - std::string protocolString(); - - void setSwCanMode(SWCanMode mode); - - void monitor(); -}; - - -#endif //ObdLinkMx_H_ -- 2.7.4