summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rw-r--r--TODO17
-rw-r--r--docs/CMakeLists.txt1
-rw-r--r--docs/amb.idl37
-rw-r--r--docs/dbus.idl34
-rw-r--r--examples/CMakeLists.txt3
-rw-r--r--examples/bluemonkey/bluemonkeyconfig27
-rw-r--r--examples/bluemonkey/bluemonkeyconfig.in18
-rw-r--r--examples/configwheel16
-rw-r--r--examples/databaseconfig28
-rw-r--r--examples/databasesource16
-rw-r--r--examples/dbusconfig18
-rw-r--r--examples/exampleconfig16
-rw-r--r--examples/gpsnmea16
-rw-r--r--examples/obdsourceconfig18
-rw-r--r--examples/opencvdbusconfig27
-rw-r--r--examples/opencvluxconfig24
-rw-r--r--examples/qtmainloopconfig18
-rw-r--r--examples/testsourceconfig15
-rw-r--r--examples/websocketsink221
-rw-r--r--examples/websocketsource220
-rw-r--r--lib/abstractpropertytype.h14
-rw-r--r--lib/vehicleproperty.h9
-rw-r--r--plugins/bluemonkey/CMakeLists.txt24
-rw-r--r--plugins/bluemonkey/authenticate.cpp10
-rw-r--r--plugins/bluemonkey/bluemonkey.cpp77
-rw-r--r--plugins/bluemonkey/bluemonkey.h34
-rw-r--r--plugins/bluemonkey/config.js18
-rw-r--r--plugins/common/bluetooth5.cpp77
-rw-r--r--plugins/common/bluetooth5.h7
-rw-r--r--plugins/gpsnmea/gpsnmea.cpp3
-rw-r--r--plugins/gpsnmea/gpsnmea.h2
-rw-r--r--plugins/murphyplugin/murphysource.cpp40
-rw-r--r--plugins/obd2plugin/obd2source.cpp170
-rw-r--r--plugins/obd2plugin/obd2source.h4
-rw-r--r--plugins/testplugin/testplugin.cpp4
-rw-r--r--plugins/wheel/wheelplugin.cpp6
37 files changed, 351 insertions, 540 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 48661636..9a758652 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,7 +6,7 @@ set(CMAKE_BUILD_TYPE, Debug)
include(FindPkgConfig)
set(PROJECT_NAME "automotive-message-broker")
-set(PROJECT_VERSION "0.11.900")
+set(PROJECT_VERSION "0.11.901")
set(PROJECT_CODENAME "veyron")
set(PROJECT_QUALITY "beta")
diff --git a/TODO b/TODO
index 95f7c7f1..35687bc6 100644
--- a/TODO
+++ b/TODO
@@ -1,10 +1,6 @@
-For 0.12
+- Refactor obd2 plugin with AsyncQueue. Use thread safe-update property.
- Rewrite websocket test html
-
-
-For 0.11
-
- Implement all the DBus properties in the docs/ directory.
- update json protocol to include getPropertyInfo calls
- update json protocol to support rangerequests with PropertyList instead of a signel property (Verify)
@@ -15,17 +11,6 @@ For 0.11
- create docs for all plugins (README)
- handle badly formed messages properly (ie not crash) in websocketsink
- GetHistory must filter on source
-
-Completed:
-
-- DBus support for time and sequece being an additional api call (ie, getVehicleSpeed()). - DONE
-- DBus support for objects with multiple sources and multiple 'zones' (/${sourceID}/[${zone}/]batteryVoltage) - DONE
-- Document changes to the DBus API in the IDL - DONE
-- add API to get number of sources per a given property (ie uint AbstractRoutingEngine::getSourcesForProperty(VehicleProperty::Property)) - DONE
-- per-source property filtering in routing engine - DONE
-
-
-Other:
- grep all the TODOs in the code and do them
- improve obd2source speed via Physical Addressing (see https://www.scantool.net/forum/index.php?topic=6661.msg25024#msg25024)
- investigate and enable use of provisioning in ssl websockets
diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt
index 1e04e84e..3893326b 100644
--- a/docs/CMakeLists.txt
+++ b/docs/CMakeLists.txt
@@ -1,4 +1,5 @@
if(enable_docs)
install (DIRECTORY amb DESTINATION ${DOC_INSTALL_DIR} COMPONENT Docs)
install (DIRECTORY dbus DESTINATION ${DOC_INSTALL_DIR} COMPONENT Docs)
+ install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/amb.idl DESTINATION ${DOC_INSTALL_DIR}/dbus COMPONENT Docs)
endif(enable_docs)
diff --git a/docs/amb.idl b/docs/amb.idl
index 40e5b04c..cea54980 100644
--- a/docs/amb.idl
+++ b/docs/amb.idl
@@ -1,36 +1,7 @@
-/*!
-* \mainpage Automotive Message Broker DBus API Documentation
-*
-* \section intro Instroduction
-* AMB organizes the API into two general interfaces. First a Manager interface (see manager.txt)
-* which includes tools for using the other interfaces. Second is a series of interfaces that
-* represent vehicle data. The latter follows the schema of "org.automotive.DataType" and are
-* contained in verious DBus paths. The DBus paths are generally organized by
-* /{source}/{zone}/DataType. "source" refers to the AMB source that produces the data. "zone"
-* refers to the zone in which the data type is located in the vehicle or "0" for no zone.
-*
-* The data types are documented in the various *.txt files in this document folder. The manager
-* interface is documented in the manager.txt document.
-*
-* \section basic_usage Basic Recommended Usage
-*
-* It is recomended that the Manager interface be used to find the DBus Object that contains the
-* data type you need. This is done through the FindObject() call. It is expected that DBus
-* Object Paths may change and so it is not appropriate to hard code DBus Object Paths. The
-* DBus paths in the various documents are examples of paths and are not gauranteed.
-*
-* \section example Usage Example
-* Here is a pseudo-code example of how the api is to be used:
-*
-* \code
-* var manager = dbus.interface("org.automotive.Manager", "/");
-*
-* var speedObjectPaths = manager.FindObject("VehicleSpeed");
-*
-* var speedObject = dbus.interface("org.automotive.VehicleSpeed", speedObjectPaths[0]);
-*
-* console.log("Vehicle Speed: " + speedObject.Speed);
-* \endcode
+/*! amb.idl
+* /brief This document describes the DBus interfaces and data types for the
+* Automotive Message Broker API. The data types are intended to as-close-as-
+* possible be compatible with the W3C vehicle <a href="https://rawgit.com/w3c/automotive-bg/master/data_spec.html>data spec</a>.
*/
/*!
diff --git a/docs/dbus.idl b/docs/dbus.idl
new file mode 100644
index 00000000..8b13bcb2
--- /dev/null
+++ b/docs/dbus.idl
@@ -0,0 +1,34 @@
+/*!
+* \mainpage Automotive Message Broker DBus API Documentation
+*
+* \section intro Introduction
+* AMB organizes the API into two general interface categories. First the Manager interface (see manager.txt)
+* which includes tools for using the other interfaces. Second is a number of interfaces that
+* represent vehicle data. The latter follows the schema of "org.automotive.DataType" and are
+* contained in verious DBus paths. The DBus paths are generally organized by
+* /{source}/{zone}/DataType. "source" refers to the AMB source that produces the data. "zone"
+* refers to the zone in which the data type is located in the vehicle or "0" for no zone.
+*
+* The interfaces and data types are documented in <a href="amb_8idl_source.html">amb.idl</a>. Franca IDL
+* tools can be used to generate DBus introspection xml which can be used to generate bindings
+* for your language of choice.
+*
+* \section basic_usage Basic Recommended Usage
+*
+* It is recomended that the Manager interface be used to find the DBus Object that contains the
+* data type you need. This is done through the FindObject() call. It is expected that DBus
+* Object Paths may change and so it is not appropriate to hard code DBus Object Paths.
+*
+* \section example Usage Example
+* Here is a pseudo-code example of how the api is to be used:
+*
+* \code
+* var manager = dbus.interface("org.automotive.Manager", "/");
+*
+* var speedObjectPaths = manager.FindObject("VehicleSpeed");
+*
+* var speedObject = dbus.interface("org.automotive.VehicleSpeed", speedObjectPaths[0]);
+*
+* console.log("Vehicle Speed: " + speedObject.Speed);
+* \endcode
+*/
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 866fbb02..4d68156a 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -1,6 +1,6 @@
set(amb_examples configwheel databaseconfig databasesource dbusconfig exampleconfig
gpsnmea obdsourceconfig opencvluxconfig opencvdbusconfig qtmainloopconfig websocketsink2 websocketsource2
- testsourceconfig)
+ testsourceconfig bluemonkey/bluemonkeyconfig)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/configwheel.in ${CMAKE_CURRENT_SOURCE_DIR}/configwheel @ONLY)
@@ -16,6 +16,7 @@ configure_file (${CMAKE_CURRENT_SOURCE_DIR}/qtmainloopconfig.in ${CMAKE_CURRENT_
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/websocketsink2.in ${CMAKE_CURRENT_SOURCE_DIR}/websocketsink2 @ONLY)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/websocketsource2.in ${CMAKE_CURRENT_SOURCE_DIR}/websocketsource2 @ONLY)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/testsourceconfig.in ${CMAKE_CURRENT_SOURCE_DIR}/testsourceconfig @ONLY)
+configure_file (${CMAKE_CURRENT_SOURCE_DIR}/bluemonkey/bluemonkeyconfig.in ${CMAKE_CURRENT_SOURCE_DIR}/bluemonkey/bluemonkeyconfig @ONLY)
install (FILES ${amb_examples} DESTINATION /etc/ambd/examples)
diff --git a/examples/bluemonkey/bluemonkeyconfig b/examples/bluemonkey/bluemonkeyconfig
index 9677ba58..fb0080c8 100644
--- a/examples/bluemonkey/bluemonkeyconfig
+++ b/examples/bluemonkey/bluemonkeyconfig
@@ -1,21 +1,18 @@
{
- "mainloop" : "/usr/lib/automotive-message-broker/qtmainloopplugin.so",
+ "mainloop" : "/usr/lib/i386-linux-gnu/automotive-message-broker/automotive-message-broker/qtmainloopplugin.so",
- "sources" : [
- {
- "path" : "/usr/lib/automotive-message-broker/bluemonkeyplugin.so",
- "authSettings" : "authSettings.js",
- "ircSettings" : "ircSettings.js",
- "config" : "config.js",
- "customPrograms" : "customPrograms.js"
- }
- ],
+ "sources" : [
+ {
+ "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/automotive-message-broker/bluemonkeyplugin.so",
+ "config" : "/etc/ambd/bluemonkey/config.js"
+ }
+ ],
- "sinks" : [
+ "sinks" : [
- {
- "path" : "/usr/lib/automotive-message-broker/examplesinkplugin.so"
- }
- ]
+ {
+ "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/automotive-message-broker/examplesinkplugin.so"
+ }
+ ]
}
diff --git a/examples/bluemonkey/bluemonkeyconfig.in b/examples/bluemonkey/bluemonkeyconfig.in
new file mode 100644
index 00000000..434651bd
--- /dev/null
+++ b/examples/bluemonkey/bluemonkeyconfig.in
@@ -0,0 +1,18 @@
+{
+ "mainloop" : "@PLUGIN_INSTALL_PATH@/automotive-message-broker/qtmainloopplugin.so",
+
+ "sources" : [
+ {
+ "path" : "@PLUGIN_INSTALL_PATH@/automotive-message-broker/bluemonkeyplugin.so",
+ "config" : "/etc/ambd/bluemonkey/config.js"
+ }
+ ],
+
+ "sinks" : [
+
+ {
+ "path" : "@PLUGIN_INSTALL_PATH@/automotive-message-broker/examplesinkplugin.so"
+ }
+ ]
+}
+
diff --git a/examples/configwheel b/examples/configwheel
deleted file mode 100644
index a2e40117..00000000
--- a/examples/configwheel
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "sources" : [
- {
- "name" : "WheelSource",
- "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/wheelsourceplugin.so",
- "device" : "/dev/input/js0"
- }
- ],
- "sinks": [
- {
- "name" : "DBusSink",
- "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/dbussinkplugin.so"
- }
- ]
-}
-
diff --git a/examples/databaseconfig b/examples/databaseconfig
deleted file mode 100644
index ba4b0ada..00000000
--- a/examples/databaseconfig
+++ /dev/null
@@ -1,28 +0,0 @@
-{
- "sources" : [
- {
- "name" : "ExampleSouce",
- "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/examplesourceplugin.so"
- }
- ],
- "sinks": [
- {
- "name" : "Database",
- "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/databasesinkplugin.so",
- "properties" : "{ 'properties' : ['VehicleSpeed','EngineSpeed'] }",
- "databaseFile" : "/tmp/storage",
- "startOnLoad" : "true",
- "bufferLength" : "1",
- "frequency" : "1"
- },
- {
- "name" : "Example Sink",
- "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/examplesinkplugin.so"
- },
- {
- "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/dbussinkplugin.so"
- }
-
- ]
-}
-
diff --git a/examples/databasesource b/examples/databasesource
deleted file mode 100644
index c24e58f3..00000000
--- a/examples/databasesource
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "sources" : [
- {
- "name" : "Database Source",
- "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/databasesinkplugin.so",
- "playbackOnLoad" : "true",
- "databaseFile" : "generated.db"
- }
- ],
- "sinks": [
- {
- "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/dbussinkplugin.so"
- }
- ]
-}
-
diff --git a/examples/dbusconfig b/examples/dbusconfig
deleted file mode 100644
index c5ca01da..00000000
--- a/examples/dbusconfig
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "sources" : [
- {
- "name" : "ExampleSouce",
- "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/examplesourceplugin.so",
- "delay" : "6"
- }
- ],
- "sinks": [
- {
- "name" : "DBusSink",
- "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/dbussinkplugin.so",
- "frequency" : "30"
- }
-
- ]
-}
-
diff --git a/examples/exampleconfig b/examples/exampleconfig
deleted file mode 100644
index aab38363..00000000
--- a/examples/exampleconfig
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "sources" : [
- {
- "name" : "ExampleSouce",
- "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/examplesourceplugin.so",
- "delay" : "1"
- }
- ],
- "sinks": [
- {
- "name" : "ExampleSink",
- "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/examplesinkplugin.so"
- }
- ]
-}
-
diff --git a/examples/gpsnmea b/examples/gpsnmea
deleted file mode 100644
index 1966dd54..00000000
--- a/examples/gpsnmea
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "sources" : [
- {
- "name" : "gps nmea plugin",
- "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/gpsnmea.so",
- "test" : "true",
- "device" : "/dev/ttyACM0"
- }
- ],
- "sinks": [
- {
- "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/dbussinkplugin.so"
- }
- ]
-}
-
diff --git a/examples/obdsourceconfig b/examples/obdsourceconfig
deleted file mode 100644
index f776ab35..00000000
--- a/examples/obdsourceconfig
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "sources" : [
- {
- "name" : "OBD2Source",
- "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/obd2sourceplugin.so",
- "device" : "/dev/pts/5",
- "baud" : "115200",
- "bluetoothAdapter" : ""
- }
- ],
- "sinks": [
- {
- "name" : "ExampleSink",
- "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/examplesinkplugin.so"
- }
- ]
-}
-
diff --git a/examples/opencvdbusconfig b/examples/opencvdbusconfig
deleted file mode 100644
index e11b4420..00000000
--- a/examples/opencvdbusconfig
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "mainloop" : "/usr/lib/i386-linux-gnu/automotive-message-broker/qtmainloopplugin.so",
- "sources" : [
- {
- "name" : "OpenCV LUX",
- "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/opencvluxplugin.so",
- "threaded" : "true",
- "cuda" : "true",
- "fps" : "30",
- "pixelLowerBound" : "18",
- "pixelUpperBound" : "255",
- "device" : "0",
- "codec" : "divx",
- "logging" : "true",
- "logfile" : "/tmp/video.avi"
- },
- {
- "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/examplesourceplugin.so"
- }
- ],
- "sinks": [
- {
- "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/dbussinkplugin.so",
- },
- ]
-}
-
diff --git a/examples/opencvluxconfig b/examples/opencvluxconfig
deleted file mode 100644
index ea620717..00000000
--- a/examples/opencvluxconfig
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "mainloop" : "/usr/lib/i386-linux-gnu/automotive-message-broker/qtmainloopplugin.so",
- "sources" : [
- {
- "name" : "OpenCV Lux plugin",
- "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/opencvluxplugin.so",
- "threaded" : "true",
- "kinect" : "false",
- "opencl" : "false",
- "cuda" : "true",
- "pixelLowerBound" : "0",
- "pixelUpperBound" : "255",
- "fps" : "30",
- "device" : "0"
- }
- ],
- "sinks": [
- {
- "name" : "Example sink",
- "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/examplesinkplugin.so"
- }
- ]
-}
-
diff --git a/examples/qtmainloopconfig b/examples/qtmainloopconfig
deleted file mode 100644
index 10c252b2..00000000
--- a/examples/qtmainloopconfig
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "mainloop" : "/usr/lib/i386-linux-gnu/automotive-message-broker/qtmainloopplugin.so",
- "sources" : [
- {
- "name" : "ExampleSouce",
- "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/examplesourceplugin.so"
- }
- ],
- "sinks": [
- {
- "name" : "Example sink",
- "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/examplesinkplugin.so",
- "interface" : "lo",
- "port" : "23000"
- }
- ]
-}
-
diff --git a/examples/testsourceconfig b/examples/testsourceconfig
deleted file mode 100644
index f66b16eb..00000000
--- a/examples/testsourceconfig
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "sources" : [
- {
- "name" : "TestPlugin",
- "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/testplugin.so"
- }
- ],
- "sinks": [
- {
- "name" : "ExampleSink",
- "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/examplesinkplugin.so"
- }
- ]
-}
-
diff --git a/examples/websocketsink2 b/examples/websocketsink2
deleted file mode 100644
index af755faa..00000000
--- a/examples/websocketsink2
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "sources" : [
- {
- "name" : "ExampleSouce",
- "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/examplesourceplugin.so",
- "delay" : "6"
- }
- ],
- "sinks": [
- {
- "name" : "WebSocketSink",
- "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/websocketsink.so",
- "interface" : "eth1",
- "ssl" : "false",
- "port" : "23000",
- "binaryProtocol" : "false",
- "useExtensions" : "true"
- }
- ]
-}
-
diff --git a/examples/websocketsource2 b/examples/websocketsource2
deleted file mode 100644
index e102713d..00000000
--- a/examples/websocketsource2
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "sources" : [
- {
- "name" : "WebsocketSource",
- "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/websocketsource.so",
- "port" : "23000",
- "ssl" : "false",
- "ip" : "127.0.0.1",
- "binaryProtocol" : "false",
- "useExtensions" : "true"
- }
- ],
- "sinks": [
- {
- "name" : "ExampleSink",
- "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/examplesinkplugin.so"
- }
- ]
-}
-
diff --git a/lib/abstractpropertytype.h b/lib/abstractpropertytype.h
index f68bfca5..c22d2ff5 100644
--- a/lib/abstractpropertytype.h
+++ b/lib/abstractpropertytype.h
@@ -368,20 +368,6 @@ public:
setValue(basicValue() - 1);
}
- BasicPropertyType operator ++ (int)
- {
- BasicPropertyType<T> temp = *this;
- temp.setValue(basicValue() + 1);
- return temp;
- }
-
- BasicPropertyType operator -- (int)
- {
- BasicPropertyType<T> temp = *this;
- temp.setValue(basicValue() - 1);
- return temp;
- }
-
bool operator < (const BasicPropertyType<T>& other) const
{
return value<T>() < other.value<T>();
diff --git a/lib/vehicleproperty.h b/lib/vehicleproperty.h
index b2cfa81b..3c5b97d5 100644
--- a/lib/vehicleproperty.h
+++ b/lib/vehicleproperty.h
@@ -420,7 +420,6 @@ public:
*/
static const Property SteeringWheelAngle;
PROPERTYTYPE(SteeringWheelAngle, SteeringWheelAngleType, BasicPropertyType<uint16_t>, uint16_t)
- //typedef BasicPropertyType<uint16_t> SteeringWheelAngleType;
/// TODO: Rename to "SteeringWheel" in 0.13
static const Property SteeringWheelAngleW3C;
@@ -429,22 +428,18 @@ public:
/**< 0=off, 1=right, 2=left, 3=hazard */
static const Property TurnSignal;
PROPERTYTYPEBASIC(TurnSignal, TurnSignals::TurnSignalType)
- //typedef BasicPropertyType<TurnSignals::TurnSignalType> TurnSignalType;
/**< Clutch pedal status 0=off, 1=on */
static const Property ClutchStatus;
PROPERTYTYPE(ClutchStatus, ClutchStatusType,BasicPropertyType<bool>,bool)
- //typedef BasicPropertyType<bool> ClutchStatusType;
/**< Oil pressure TODO: units */
static const Property EngineOilPressure;
- PROPERTYTYPE(EngineOilPressure, EngineOilPressureType,BasicPropertyType<uint16_t>, uint16_t)
- //typedef BasicPropertyType<uint16_t> EngineOilPressureType;
+ PROPERTYTYPE(EngineOilPressure, EngineOilPressureType, BasicPropertyType<uint16_t>, uint16_t)
/**< Engine coolant temperature in degrees celcius **/
static const Property EngineCoolantTemperature;
PROPERTYTYPE(EngineCoolantTemperature, EngineCoolantTemperatureType, BasicPropertyType<int>, int)
- //typedef BasicPropertyType<int> EngineCoolantTemperatureType;
static const Property EngineCoolantLevel;
PROPERTYTYPE(EngineCoolantLevel, EngineCoolantLevelType, BasicPropertyType<uint>, uint)
@@ -452,12 +447,10 @@ public:
/**< 0=off, 1=on */
static const Property MachineGunTurretStatus;
PROPERTYTYPEBASIC(MachineGunTurretStatus, bool)
- //typedef BasicPropertyType<bool> MachineGunTurretStatusType;
/**< Acceleration on the 'x' axis in 1/1000 gravitational acceleration "g-force" */
static const Property AccelerationX;
PROPERTYTYPE(AccelerationX, AccelerationXType, BasicPropertyType<uint16_t>, uint16_t)
- //typedef BasicPropertyType<uint16_t> AccelerationType;
/**< Acceleration on the 'y' axis in 1/1000 gravitational acceleration "g-force" */
static const Property AccelerationY;
diff --git a/plugins/bluemonkey/CMakeLists.txt b/plugins/bluemonkey/CMakeLists.txt
index ec63f77c..0e710e27 100644
--- a/plugins/bluemonkey/CMakeLists.txt
+++ b/plugins/bluemonkey/CMakeLists.txt
@@ -2,38 +2,32 @@ if(bluemonkey_plugin)
find_package(Qt5Core REQUIRED)
find_package(Qt5Network REQUIRED)
-find_package(Qt5Script REQUIRED)
+find_package(Qt5Qml REQUIRED)
if(Qt5Core_FOUND)
message(STATUS "using Qt5")
- set(QT_INCLUDE_DIRS ${Qt5Core_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS} ${Qt5Script_INCLUDE_DIRS})
- set(QT_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Script_LIBRARIES})
+ set(QT_INCLUDE_DIRS ${Qt5Core_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS} ${Qt5Qml_INCLUDE_DIRS})
+ set(QT_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Qml_LIBRARIES})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")
- message(STATUS "size of void_p: ${CMAKE_SIZEOF_VOID_P}")
- if(CMAKE_SIZEOF_VOID_P MATCHES "8")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcmodel=large")
- endif(CMAKE_SIZEOF_VOID_P MATCHES "8")
add_definitions(${Qt5Core_DEFINITIONS})
endif(Qt5Core_FOUND)
set(CMAKE_AUTOMOC ON)
-set(communi_INCLUDE_DIRS /usr/include/qt5/Communi)
-set(communi_LIBRARIES -lCommuni)
-add_definitions(-DCOMMUNI_SHARED)
+#set(communi_INCLUDE_DIRS /usr/include/qt5/Communi)
+#set(communi_LIBRARIES -lCommuni)
+#add_definitions(-DCOMMUNI_SHARED)
include_directories(${CMAKE_SOURCE_DIR}/lib ${include_dirs} ${communi_INCLUDE_DIRS} ${QT_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/plugins/common)
-set(bluemonkeyplugin_headers bluemonkey.h irccoms.h authenticate.h agent.h)
-set(bluemonkeyplugin_sources bluemonkey.cpp irccoms.cpp authenticate.cpp agent.cpp)
+set(bluemonkeyplugin_headers bluemonkey.h authenticate.h)
+set(bluemonkeyplugin_sources bluemonkey.cpp authenticate.cpp)
add_library(bluemonkeyplugin MODULE ${bluemonkeyplugin_sources})
set_target_properties(bluemonkeyplugin PROPERTIES PREFIX "")
target_link_libraries(bluemonkeyplugin amb -L${CMAKE_CURRENT_BINARY_DIR}/lib ${link_libraries} ${QT_LIBRARIES} ${communi_LIBRARIES} amb-plugins-common -L${CMAKE_CURRENT_BINARY_DIR}/plugins/common)
-set(config_files ${CMAKE_CURRENT_SOURCE_DIR}/ircSettings.js
- ${CMAKE_CURRENT_SOURCE_DIR}/authSettings.js
- ${CMAKE_CURRENT_SOURCE_DIR}/config.js)
+set(config_files ${CMAKE_CURRENT_SOURCE_DIR}/config.js)
install(TARGETS bluemonkeyplugin LIBRARY DESTINATION ${PLUGIN_INSTALL_PATH})
install (FILES ${config_files} DESTINATION /etc/ambd/bluemonkey)
diff --git a/plugins/bluemonkey/authenticate.cpp b/plugins/bluemonkey/authenticate.cpp
index 00974569..81a540fd 100644
--- a/plugins/bluemonkey/authenticate.cpp
+++ b/plugins/bluemonkey/authenticate.cpp
@@ -1,16 +1,18 @@
#include "authenticate.h"
#include <QSettings>
-#include <QtScript>
+#include <QJSEngine>
+#include <QFile>
+#include <QtDebug>
Authenticate::Authenticate(std::map<std::string, std::string> config, QObject *parent) :
- QObject(parent)
+ QObject(parent)
{
QSettings settings;
authorized = settings.value("authorized").toStringList();
- QScriptEngine engine;
+ QJSEngine engine;
- QScriptValue eventEngineValue = engine.newQObject(this);
+ QJSValue eventEngineValue = engine.newQObject(this);
engine.globalObject().setProperty("auth", eventEngineValue);
QString str = config["authSettings"].c_str();
diff --git a/plugins/bluemonkey/bluemonkey.cpp b/plugins/bluemonkey/bluemonkey.cpp
index 4e577bb8..11b12afc 100644
--- a/plugins/bluemonkey/bluemonkey.cpp
+++ b/plugins/bluemonkey/bluemonkey.cpp
@@ -21,16 +21,14 @@
#include "abstractroutingengine.h"
#include "ambplugin.h"
#include "debugout.h"
-#include "irccoms.h"
#include <QJsonDocument>
-#include <QScriptEngine>
+#include <QJSEngine>
#include <QDateTime>
#include <QString>
#include <QFile>
#include <QTimer>
-
-Q_SCRIPT_DECLARE_QMETAOBJECT(QTimer, QObject*)
+#include <QtQml>
#define foreach Q_FOREACH
@@ -93,15 +91,15 @@ QVariant gvariantToQVariant(GVariant *value)
}
-BluemonkeySink::BluemonkeySink(AbstractRoutingEngine* e, map<string, string> config, AbstractSource &parent): QObject(0), AmbPluginImpl(e, config, parent), agent(nullptr), engine(nullptr), mSilentMode(false)
+BluemonkeySink::BluemonkeySink(AbstractRoutingEngine* e, map<string, string> config, AbstractSource &parent): QObject(0), AmbPluginImpl(e, config, parent), engine(nullptr), mSilentMode(false)
{
- irc = new IrcCommunication(config, this);
-
QTimer::singleShot(1,this,SLOT(reloadEngine()));
auth = new Authenticate(config, this);
- connect(irc, &IrcCommunication::message, [&](QString sender, QString prefix, QString codes ) {
+ qmlRegisterType<QTimer>("", 1, 0, "QTimer");
+
+/* connect(irc, &IrcCommunication::message, [&](QString sender, QString prefix, QString codes ) {
if(codes.startsWith("authenticate"))
{
@@ -135,7 +133,7 @@ BluemonkeySink::BluemonkeySink(AbstractRoutingEngine* e, map<string, string> con
irc->respond(sender, response);
}
});
-
+*/
}
@@ -169,7 +167,7 @@ QObject *BluemonkeySink::subscribeTo(QString str)
return new Property(str.toStdString(), "", routingEngine, this);
}
-QObject *BluemonkeySink::subscribeTo(QString str, QString srcFilter)
+QObject *BluemonkeySink::subscribeToSource(QString str, QString srcFilter)
{
return new Property(str.toStdString(), srcFilter, routingEngine, this);
}
@@ -219,7 +217,7 @@ void BluemonkeySink::loadConfig(QString str)
DebugOut()<<"evaluating script: "<<script.toStdString()<<endl;
- QScriptValue val = engine->evaluate(script);
+ QJSValue val = engine->evaluate(script);
DebugOut()<<val.toString().toStdString()<<endl;
}
@@ -229,32 +227,22 @@ void BluemonkeySink::reloadEngine()
if(engine)
engine->deleteLater();
- engine = new QScriptEngine(this);
-
- if(agent) delete agent;
-
- agent = new BluemonkeyAgent(engine);
-
- //engine->setAgent(agent);
+ engine = new QJSEngine(this);
- QScriptValue value = engine->newQObject(this);
+ QJSValue value = engine->newQObject(this);
engine->globalObject().setProperty("bluemonkey", value);
- QScriptValue qtimerClass = engine->scriptValueFromQMetaObject<QTimer>();
- engine->globalObject().setProperty("QTimer", qtimerClass);
-
- QScriptValue ircValue = engine->newQObject(irc);
- engine->globalObject().setProperty("irc", ircValue);
-
loadConfig(configuration["config"].c_str());
}
void BluemonkeySink::writeProgram(QString program)
{
- QScriptSyntaxCheckResult result = QScriptEngine::checkSyntax(program);
- if(result.state() != QScriptSyntaxCheckResult::Valid)
+
+ QJSEngine temp;
+ QJSValue result = temp.evaluate(program);
+ if(result.isError())
{
- DebugOut(DebugOut::Error)<<"Syntax error in program: "<<result.errorMessage().toStdString()<<endl;
+ DebugOut(DebugOut::Error)<<"Syntax error in program: "<<result.toString().toStdString()<<endl;
return;
}
@@ -277,7 +265,12 @@ void BluemonkeySink::log(QString str)
DebugOut()<<str.toStdString()<<endl;
}
-void BluemonkeySink::getHistory(QStringList properties, QDateTime begin, QDateTime end, QScriptValue cbFunction)
+QObject *BluemonkeySink::createTimer()
+{
+ return new QTimer(this);
+}
+
+void BluemonkeySink::getHistory(QStringList properties, QDateTime begin, QDateTime end, QJSValue cbFunction)
{
double b = (double)begin.toMSecsSinceEpoch() / 1000.0;
double e = (double)end.toMSecsSinceEpoch() / 1000.0;
@@ -301,7 +294,7 @@ void BluemonkeySink::getHistory(QStringList properties, QDateTime begin, QDateTi
return;
}
- if(cbFunction.isFunction())
+ if(cbFunction.isCallable())
{
QVariantList list;
@@ -312,7 +305,9 @@ void BluemonkeySink::getHistory(QStringList properties, QDateTime begin, QDateTi
list.append(gvariantToQVariant(val->toVariant()));
}
- cbFunction.call(QScriptValue(),cbFunction.engine()->newVariant(list));
+ QJSValue val = cbFunction.engine()->toScriptValue<QVariantList>(list);
+
+ cbFunction.call(QJSValueList()<<val);
}
@@ -322,7 +317,7 @@ void BluemonkeySink::getHistory(QStringList properties, QDateTime begin, QDateTi
routingEngine->getRangePropertyAsync(request);
}
-void BluemonkeySink::createCustomProperty(QString name, QScriptValue defaultValue)
+void BluemonkeySink::createCustomProperty(QString name, QJSValue defaultValue)
{
auto create = [defaultValue, name]() -> AbstractPropertyType*
@@ -382,14 +377,14 @@ void Property::setValue(QVariant v)
{
if(reply->success)
{
- propertyChanged(reply->property, reply->value, reply->value->sourceUuid);
+ propertyChanged(reply->value);
}
delete reply;
};
routingEngine->setProperty(request);
}
-void Property::getHistory(QDateTime begin, QDateTime end, QScriptValue cbFunction)
+void Property::getHistory(QDateTime begin, QDateTime end, QJSValue cbFunction)
{
double b = (double)begin.toMSecsSinceEpoch() / 1000.0;
double e = (double)end.toMSecsSinceEpoch() / 1000.0;
@@ -409,7 +404,7 @@ void Property::getHistory(QDateTime begin, QDateTime end, QScriptValue cbFunctio
return;
}
- if(cbFunction.isFunction())
+ if(cbFunction.isCallable())
{
QVariantList list;
@@ -419,8 +414,8 @@ void Property::getHistory(QDateTime begin, QDateTime end, QScriptValue cbFunctio
list.append(gvariantToQVariant(val->toVariant()));
}
-
- cbFunction.call(QScriptValue(),cbFunction.engine()->newVariant(list));
+ QJSValue val = cbFunction.engine()->toScriptValue<QVariantList>(list);
+ cbFunction.call(QJSValueList()<<val);
}
@@ -444,9 +439,9 @@ QString Property::type()
void Property::setType(QString t)
{
if(mValue && type() != "")
- routingEngine->unsubscribeToProperty(type().toStdString(),this);
+ routingEngine->unsubscribeToProperty(type().toStdString(), this);
- routingEngine->subscribeToProperty(t.toStdString(),this);
+ routingEngine->subscribeToProperty(t.toStdString(), this);
mValue = VehicleProperty::getPropertyTypeForPropertyNameValue(t.toStdString());
@@ -458,7 +453,7 @@ void Property::setType(QString t)
request.completed = [this](AsyncPropertyReply* reply)
{
if(reply->success)
- propertyChanged(reply->property, reply->value,uuid());
+ propertyChanged(reply->value);
delete reply;
};
@@ -466,7 +461,7 @@ void Property::setType(QString t)
routingEngine->getPropertyAsync(request);
}
-void Property::propertyChanged(VehicleProperty::Property property, AbstractPropertyType *value, string uuid)
+void Property::propertyChanged(AbstractPropertyType *value)
{
if(mValue)
{
diff --git a/plugins/bluemonkey/bluemonkey.h b/plugins/bluemonkey/bluemonkey.h
index e67814c4..a8df6bad 100644
--- a/plugins/bluemonkey/bluemonkey.h
+++ b/plugins/bluemonkey/bluemonkey.h
@@ -23,18 +23,26 @@
#include "abstractsource.h"
#include "ambpluginimpl.h"
+#include <map>
+
#include <QObject>
#include <QVariant>
#include <QJsonDocument>
#include <QDateTime>
-#include <QScriptValue>
+#include <QJSValue>
#include "uuidhelper.h"
#include "authenticate.h"
-#include "agent.h"
-class IrcCommunication;
-class QScriptEngine;
+class QJSEngine;
+
+class ModuleInterface
+{
+public:
+ virtual std::map<std::string, QObject*> objects(std::map<string, string> config) = 0;
+};
+
+Q_DECLARE_INTERFACE(ModuleInterface, "org.automotive.bluemonkey.moduleinterface")
class Property: public QObject, public AbstractSink
{
@@ -54,14 +62,14 @@ public:
DebugOut()<<"Bluemonkey Property Supported Changed"<<endl;
}
- virtual void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, std::string uuid);
+ virtual void propertyChanged(AbstractPropertyType* value);
virtual const std::string uuid() { return mUuid; }
QVariant value();
void setValue(QVariant v);
- void getHistory(QDateTime begin, QDateTime end, QScriptValue cbFunction);
+ void getHistory(QDateTime begin, QDateTime end, QJSValue cbFunction);
Q_SIGNALS:
void changed(QVariant val);
@@ -82,7 +90,7 @@ public:
virtual void propertyChanged(AbstractPropertyType* value);
virtual const std::string uuid() const;
- QScriptEngine* engine;
+ QJSEngine* engine;
virtual int supportedOperations();
@@ -95,7 +103,7 @@ private: //source privates
public Q_SLOTS:
QObject* subscribeTo(QString str);
- QObject* subscribeTo(QString str, QString srcFilter);
+ QObject* subscribeToSource(QString str, QString srcFilter);
QStringList sourcesForProperty(QString property);
@@ -105,27 +113,29 @@ public Q_SLOTS:
void loadConfig(QString str);
+ void loadModule(QString path);
+
void reloadEngine();
void writeProgram(QString program);
void log(QString str);
- void getHistory(QStringList properties, QDateTime begin, QDateTime end, QScriptValue cbFunction);
+ QObject* createTimer();
+
+ void getHistory(QStringList properties, QDateTime begin, QDateTime end, QJSValue cbFunction);
void setSilentMode(bool m)
{
mSilentMode = m;
}
- void createCustomProperty(QString name, QScriptValue defaultValue);
+ void createCustomProperty(QString name, QJSValue defaultValue);
private:
QStringList configsToLoad;
- IrcCommunication* irc;
Authenticate* auth;
- BluemonkeyAgent* agent;
bool mSilentMode;
};
diff --git a/plugins/bluemonkey/config.js b/plugins/bluemonkey/config.js
index 363f3f85..dd51234e 100644
--- a/plugins/bluemonkey/config.js
+++ b/plugins/bluemonkey/config.js
@@ -1,5 +1,19 @@
var speedProperty = bluemonkey.subscribeTo("VehicleSpeed");
-bluemonkey.loadConfig("customPrograms.js");
+bluemonkey.log("Javascript engine works!!!!");
-
+bluemonkey.createCustomProperty("BluemonkeyTest", false);
+
+var bluemonkeyTest = bluemonkey.subscribeTo("BluemonkeyTest");
+
+bluemonkeyTest.value = true;
+
+var timer = bluemonkey.createTimer();
+
+timer.interval = 1000;
+timer.singleShot = false;
+timer.timeout.connect(function() {
+ bluemonkeyTest.value = !bluemonkeyTest.value;
+});
+
+timer.start();
diff --git a/plugins/common/bluetooth5.cpp b/plugins/common/bluetooth5.cpp
index 5244e705..cd346c84 100644
--- a/plugins/common/bluetooth5.cpp
+++ b/plugins/common/bluetooth5.cpp
@@ -252,23 +252,52 @@ Bluetooth5::Bluetooth5()
}
}
+bool Bluetooth5::setDevice(string address)
+{
+ mPath = findDevice(address);
+
+
+ if(mPath == "")
+ {
+ DebugOut(DebugOut::Error) << "device path not found. Not paired? " << endl;
+ return false;
+ }
+
+ return true;
+}
+
void Bluetooth5::getDeviceForAddress(std::string address, ConnectedCallback connectedCallback)
{
mConnected = connectedCallback;
- std::string devicePath = findDevice(address);
+ if(!setDevice(address))
+ return;
- DebugOut() << "Bluetooth device path: " << devicePath << endl;
+ DebugOut() << "Bluetooth device path: " << mPath << endl;
- if(devicePath == "")
+ connect(connectedCallback);
+}
+
+void Bluetooth5::connected(int fd)
+{
+ try
{
- DebugOut(DebugOut::Error) << "device path not found. Not paired? " << endl;
+ mConnected(fd);
}
+ catch(...)
+ {
+ DebugOut(DebugOut::Error) << "Error calling connected callback" << endl;
+ }
+}
+
+void Bluetooth5::connect(ConnectedCallback onconnectedCallback)
+{
+ mConnected = onconnectedCallback;
GError* error = nullptr;
- GDBusProxy * deviceProxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,G_DBUS_PROXY_FLAGS_NONE,NULL,
- "org.bluez", devicePath.c_str(), "org.bluez.Device1", nullptr, &error);
+ auto deviceProxyPtr = amb::make_super(g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,G_DBUS_PROXY_FLAGS_NONE,NULL,
+ "org.bluez", mPath.c_str(), "org.bluez.Device1", nullptr, &error));
auto errorPtr = amb::make_super(error);
@@ -278,13 +307,13 @@ void Bluetooth5::getDeviceForAddress(std::string address, ConnectedCallback conn
return;
}
- g_dbus_proxy_call(deviceProxy, "Connect", nullptr, G_DBUS_CALL_FLAGS_NONE, -1, nullptr,
+ g_dbus_proxy_call(deviceProxyPtr.get(), "Connect", nullptr, G_DBUS_CALL_FLAGS_NONE, -1, nullptr,
[](GObject *source_object, GAsyncResult *res, gpointer user_data)
{
GError* error = nullptr;
- g_dbus_proxy_call_finish(G_DBUS_PROXY (source_object),res, &error);
+ g_dbus_proxy_call_finish(G_DBUS_PROXY (source_object), res, &error);
auto errorPtr = amb::make_super(error);
@@ -296,14 +325,32 @@ void Bluetooth5::getDeviceForAddress(std::string address, ConnectedCallback conn
this);
}
-void Bluetooth5::connected(int fd)
+void Bluetooth5::disconnect()
{
- //try
- {
- mConnected(fd);
- }
- //catch(...)
+ GError* error = nullptr;
+
+ auto deviceProxyPtr = amb::make_super(g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,G_DBUS_PROXY_FLAGS_NONE,NULL,
+ "org.bluez", mPath.c_str(), "org.bluez.Device1", nullptr, &error));
+
+ auto errorPtr = amb::make_super(error);
+
+ if(errorPtr)
{
- //DebugOut(DebugOut::Error) << "Error calling connected callback" << endl;
+ DebugOut(DebugOut::Error) << "Error getting bluetooth device proxy " << errorPtr->message <<endl;
+ return;
}
+
+ g_dbus_proxy_call(deviceProxyPtr.get(), "Disconnect", nullptr, G_DBUS_CALL_FLAGS_NONE, -1, nullptr,[](GObject *source_object,
+ GAsyncResult *res, gpointer user_data){
+ GError* error = nullptr;
+
+ g_dbus_proxy_call_finish(G_DBUS_PROXY (source_object), res, &error);
+
+ auto errorPtr = amb::make_super(error);
+
+ if(errorPtr)
+ {
+ DebugOut(DebugOut::Error) << "error trying to disconnect: " << errorPtr->message << endl;
+ }
+ }, nullptr);
}
diff --git a/plugins/common/bluetooth5.h b/plugins/common/bluetooth5.h
index 52170db2..0b479c32 100644
--- a/plugins/common/bluetooth5.h
+++ b/plugins/common/bluetooth5.h
@@ -11,13 +11,18 @@ class Bluetooth5
public:
Bluetooth5();
+ bool setDevice(std::string address);
void getDeviceForAddress(std::string address, ConnectedCallback onnectedCallback);
- void disconnect(std::string address, std::string adapterAddy = "");
void connected(int fd);
+ void connect( ConnectedCallback onconnectedCallback);
+ void disconnect();
+
+
private:
ConnectedCallback mConnected;
+ std::string mPath;
};
#endif
diff --git a/plugins/gpsnmea/gpsnmea.cpp b/plugins/gpsnmea/gpsnmea.cpp
index c250d2b4..1cd8647e 100644
--- a/plugins/gpsnmea/gpsnmea.cpp
+++ b/plugins/gpsnmea/gpsnmea.cpp
@@ -426,10 +426,9 @@ GpsNmeaSource::GpsNmeaSource(AbstractRoutingEngine *re, map<string, string> conf
{
std::string dev = config["device"];
-#ifdef USE_BLUEZ5
if(dev.find(":") != string::npos)
{
-
+#ifdef USE_BLUEZ5
bt = new Bluetooth5();
bt->getDeviceForAddress(dev, [this](int fd) {
DebugOut() << "fd: " << fd << endl;
diff --git a/plugins/gpsnmea/gpsnmea.h b/plugins/gpsnmea/gpsnmea.h
index 5336a978..9212224a 100644
--- a/plugins/gpsnmea/gpsnmea.h
+++ b/plugins/gpsnmea/gpsnmea.h
@@ -82,7 +82,7 @@ private:
#ifdef USE_BLUEZ5
Bluetooth5 * bt;
#else
- BluetoothDevice *bt
+ BluetoothDevice *bt;
#endif
};
diff --git a/plugins/murphyplugin/murphysource.cpp b/plugins/murphyplugin/murphysource.cpp
index 3476e85a..f3f59a57 100644
--- a/plugins/murphyplugin/murphysource.cpp
+++ b/plugins/murphyplugin/murphysource.cpp
@@ -76,7 +76,7 @@ static void recvfrom_msg(mrp_transport_t *transp, mrp_msg_t *msg,
mrp_msg_value_t value;
size_t size;
- char *property_name;
+ std::string property_name;
DebugOut()<<"Received a message from Murphy!"<<endl;
@@ -86,8 +86,6 @@ static void recvfrom_msg(mrp_transport_t *transp, mrp_msg_t *msg,
if (tag == 1 && type == MRP_MSG_FIELD_STRING)
property_name = value.str;
- string dstr(property_name);
-
if (!mrp_msg_iterate(msg, &cursor, &tag, &type, &value, &size))
return;
@@ -96,9 +94,7 @@ static void recvfrom_msg(mrp_transport_t *transp, mrp_msg_t *msg,
DebugOut() << "Property '" << property_name << "' with value: " <<endl;
- bool hasProp = contains(VehicleProperty::capabilities(), dstr);
-
- AbstractPropertyType* prop = VehicleProperty::getPropertyTypeForPropertyNameValue(dstr);
+ bool hasProp = contains(VehicleProperty::capabilities(), property_name);
stringstream val;
@@ -109,8 +105,8 @@ static void recvfrom_msg(mrp_transport_t *transp, mrp_msg_t *msg,
val << value.str;
if (!hasProp)
{
- VehicleProperty::registerProperty(dstr,
- [dstr](){return new StringPropertyType(dstr, "");});
+ VehicleProperty::registerProperty(property_name,
+ [property_name](){return new StringPropertyType(property_name, "");});
}
DebugOut() << "string:" << value.str << std::endl;
@@ -122,8 +118,8 @@ static void recvfrom_msg(mrp_transport_t *transp, mrp_msg_t *msg,
if (!hasProp)
{
- VehicleProperty::registerProperty(dstr,
- [dstr](){return new BasicPropertyType<double>(dstr, 0);});
+ VehicleProperty::registerProperty(property_name,
+ [property_name](){return new BasicPropertyType<double>(property_name, 0);});
}
DebugOut() << "double:" << value.dbl << std::endl;
@@ -135,8 +131,8 @@ static void recvfrom_msg(mrp_transport_t *transp, mrp_msg_t *msg,
if (!hasProp)
{
- VehicleProperty::registerProperty(dstr,
- [dstr](){return new BasicPropertyType<bool>(dstr, FALSE);});
+ VehicleProperty::registerProperty(property_name,
+ [property_name](){return new BasicPropertyType<bool>(property_name, FALSE);});
}
DebugOut() << "boolean:" << value.bln << std::endl;
@@ -148,8 +144,8 @@ static void recvfrom_msg(mrp_transport_t *transp, mrp_msg_t *msg,
if (!hasProp)
{
- VehicleProperty::registerProperty(dstr,
- [dstr](){return new BasicPropertyType<uint32_t>(dstr, 0);});
+ VehicleProperty::registerProperty(property_name,
+ [property_name](){return new BasicPropertyType<uint32_t>(property_name, 0);});
}
DebugOut() << "uint32:" << value.u32 << std::endl;
@@ -161,8 +157,8 @@ static void recvfrom_msg(mrp_transport_t *transp, mrp_msg_t *msg,
if (!hasProp)
{
- VehicleProperty::registerProperty(dstr,
- [dstr](){return new BasicPropertyType<uint16_t>(dstr, 0);});
+ VehicleProperty::registerProperty(property_name,
+ [property_name](){return new BasicPropertyType<uint16_t>(property_name, 0);});
}
DebugOut() << "uint16:" << value.u16 << std::endl;
@@ -175,12 +171,11 @@ static void recvfrom_msg(mrp_transport_t *transp, mrp_msg_t *msg,
if (!hasProp)
{
- VehicleProperty::registerProperty(dstr,
- [dstr](){return new BasicPropertyType<int32_t>(dstr, 0);});
+ VehicleProperty::registerProperty(property_name,
+ [property_name](){return new BasicPropertyType<int32_t>(property_name, 0);});
}
DebugOut() << "int32:" << value.s32 << std::endl;
- s->processValue(property_name, prop);
break;
}
case MRP_MSG_FIELD_INT16:
@@ -189,8 +184,8 @@ static void recvfrom_msg(mrp_transport_t *transp, mrp_msg_t *msg,
if (!hasProp)
{
- VehicleProperty::registerProperty(dstr,
- [dstr](){return new BasicPropertyType<int16_t>(dstr, 0);});
+ VehicleProperty::registerProperty(property_name,
+ [property_name](){return new BasicPropertyType<int16_t>(property_name, 0);});
}
DebugOut() << "int16:" << value.s16 << std::endl;
@@ -200,9 +195,10 @@ static void recvfrom_msg(mrp_transport_t *transp, mrp_msg_t *msg,
DebugOut()<<"Unknown type"<<endl;
}
+ AbstractPropertyType* prop = VehicleProperty::getPropertyTypeForPropertyNameValue(property_name);
+
prop->fromString(val.str());
s->processValue(property_name, prop);
-
}
static void recv_msg(mrp_transport_t *transp, mrp_msg_t *msg, void *user_data)
diff --git a/plugins/obd2plugin/obd2source.cpp b/plugins/obd2plugin/obd2source.cpp
index 3253c150..aa585b54 100644
--- a/plugins/obd2plugin/obd2source.cpp
+++ b/plugins/obd2plugin/obd2source.cpp
@@ -28,6 +28,12 @@
#include "debugout.h"
#include "bluetooth.hpp"
#include "timestamp.h"
+#include "bluetooth5.h"
+#include "superptr.hpp"
+
+#ifdef USE_BLUEZ5
+Bluetooth5 bt;
+#endif
#define __SMALLFILE__ std::string(__FILE__).substr(std::string(__FILE__).rfind("/")+1)
AbstractRoutingEngine *m_re;
@@ -39,7 +45,7 @@ int calledPersecond = 0;
bool sendElmCommand(obdLib *obd,std::string command)
{
- std::vector<unsigned char> replyVector;
+ std::vector<unsigned char> replyVector;
std::string reply;
obd->sendObdRequestString(command.append("\r").c_str(),command.length()+1,&replyVector,10,3);
for (unsigned int i=0;i<replyVector.size();i++)
@@ -72,7 +78,7 @@ bool connect(obdLib* obd, std::string device, std::string strbaud, int fd = -1)
if(fd != -1)
{
- if(obd->openPort(fd,baud) == -1)
+ if(obd->openPort(fd, baud) == -1)
return false;
}
else
@@ -123,7 +129,7 @@ bool connect(obdLib* obd, std::string device, std::string strbaud, int fd = -1)
DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Error turning off linefeeds"<<endl;
return false;
}
- obd->sendObdRequestString("010C1\r",6,&replyVector,500,5);
+ obd->sendObdRequestString("010C1\r", 6, &replyVector, 500, 5);
return true;
}
@@ -136,17 +142,16 @@ void threadLoop(gpointer data)
GAsyncQueue *privSubscriptionAddQueue = g_async_queue_ref(((OBD2Source*)data)->subscriptionAddQueue);
GAsyncQueue *privSubscriptionRemoveQueue = g_async_queue_ref(((OBD2Source*)data)->subscriptionRemoveQueue);
GAsyncQueue *privStatusQueue = g_async_queue_ref(((OBD2Source*)data)->statusQueue);
-
+
obdLib *obd = new obdLib();
OBD2Source *source = (OBD2Source*)data;
obd->setCommsCallback([](const char* mssg, void* data) { DebugOut(6)<<mssg<<endl; },NULL);
obd->setDebugCallback([](const char* mssg, void* data, obdLib::DebugLevel debugLevel) { DebugOut(debugLevel)<<mssg<<endl; },NULL);
-
+
std::list<ObdPid*> reqList;
std::list<ObdPid*> repeatReqList;
ObdPid::ByteArray replyVector;
- std::string reply;
std::string port;
std::string baud;
bool connected=false;
@@ -154,14 +159,11 @@ void threadLoop(gpointer data)
int timeoutCount = 0;
while (source->m_threadLive)
{
- //gpointer query = g_async_queue_pop(privCommandQueue);
-
-
gpointer query = g_async_queue_try_pop(privSingleShotQueue);
if (query != nullptr)
{
//printf("Got request!\n");
-
+
ObdPid *req = (ObdPid*)query;
DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Got single shot request: " << req->pid.substr(0,req->pid.length()-1) << ":" << req->property <<endl;
repeatReqList.push_back(req);
@@ -182,74 +184,78 @@ 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 (source->m_isBluetooth)
- {
-
- BluetoothDevice bt;
- std::string tempPort = bt.getDeviceForAddress(source->m_btDeviceAddress, source->m_btAdapterAddress);
- if(tempPort != "")
- {
- DebugOut(3)<<"Using bluetooth device \""<<source->m_btDeviceAddress<<"\" bound to: "<<tempPort<<endl;
- port = tempPort;
- }
- }
- else
- {
- port = req->arglist[0];
- baud = req->arglist[1];
- }
- connected = connect(obd,port,baud);
-
- if(connected)
- {
- StatusMessage *statusreq = new StatusMessage();
- statusreq->statusStr = "connected";
- g_async_queue_push(privStatusQueue,statusreq);
- }
- else
- {
- StatusMessage *statusreq = new StatusMessage();
- statusreq->statusStr = "disconnected";
- g_async_queue_push(privStatusQueue,statusreq);
- }
-
- }
- else if (req->req == "connectifnot")
+ if (req->req == "connectifnot")
{
if (!connected)
{
if (source->m_isBluetooth)
{
+#ifdef USE_BLUEZ5
+ bt.getDeviceForAddress(source->m_btDeviceAddress, [&obd, baud, &privStatusQueue](int fd)
+ {
+ bool connected = connect(obd, "", baud, fd);
+
+ if(connected)
+ {
+ StatusMessage *statusreq = new StatusMessage();
+ statusreq->statusStr = "connected";
+ g_async_queue_push(privStatusQueue, statusreq);
+ }
+ else
+ {
+ StatusMessage *statusreq = new StatusMessage();
+ statusreq->statusStr = "disconnected";
+ g_async_queue_push(privStatusQueue, statusreq);
+ }
+ });
+#else
BluetoothDevice bt;
std::string tempPort = bt.getDeviceForAddress(source->m_btDeviceAddress, source->m_btAdapterAddress);
if(tempPort != "")
{
- DebugOut(3)<<"Using bluetooth device \""<<source->m_btDeviceAddress<<"\" bound to: "<<tempPort<<endl;
+ DebugOut(3) << "Using bluetooth device \"" << source->m_btDeviceAddress << "\" bound to: " << tempPort << endl;
port = tempPort;
}
else
{
- DebugOut(DebugOut::Error)<<"Error creating bluetooth device"<<endl;
+ DebugOut(DebugOut::Error) << "Error creating bluetooth device" << endl;
continue;
}
- }
- connected = connect(obd,port,baud);
+ connected = connect(obd, port, baud);
- if(connected)
- {
- StatusMessage *statusreq = new StatusMessage();
- statusreq->statusStr = "connected";
- g_async_queue_push(privStatusQueue,statusreq);
+ if(connected)
+ {
+ StatusMessage *statusreq = new StatusMessage();
+ statusreq->statusStr = "connected";
+ g_async_queue_push(privStatusQueue, statusreq);
+ }
+ else
+ {
+ StatusMessage *statusreq = new StatusMessage();
+ statusreq->statusStr = "disconnected";
+ g_async_queue_push(privStatusQueue, statusreq);
+ }
+
+#endif
}
else
{
- StatusMessage *statusreq = new StatusMessage();
- statusreq->statusStr = "disconnected";
- g_async_queue_push(privStatusQueue,statusreq);
+
+ connected = connect(obd, port, baud);
+
+ if(connected)
+ {
+ StatusMessage *statusreq = new StatusMessage();
+ statusreq->statusStr = "connected";
+ g_async_queue_push(privStatusQueue, statusreq);
+ }
+ else
+ {
+ StatusMessage *statusreq = new StatusMessage();
+ statusreq->statusStr = "disconnected";
+ g_async_queue_push(privStatusQueue, statusreq);
+ }
}
}
}
@@ -262,8 +268,12 @@ void threadLoop(gpointer data)
{
DebugOut() << __SMALLFILE__ << ":" << __LINE__ << "Using queued disconnect" << (ulong)req << endl;
obd->closePort();
+#ifdef USE_BLUEZ5
+ bt.disconnect();
+#else
BluetoothDevice bt;
bt.disconnect(source->m_btDeviceAddress, source->m_btAdapterAddress);
+#endif
connected = false;
StatusMessage *statusreq = new StatusMessage();
statusreq->statusStr = "disconnected";
@@ -360,7 +370,7 @@ void threadLoop(gpointer data)
int count = (*source->m_blacklistPidCountMap.find((*i)->pid)).second;
if (count > 10)
{
-
+
}
source->m_blacklistPidCountMap.erase(source->m_blacklistPidCountMap.find((*i)->pid));
source->m_blacklistPidCountMap.insert(pair<std::string,int>((*i)->pid,count));
@@ -391,7 +401,7 @@ void threadLoop(gpointer data)
{
DebugOut() << __SMALLFILE__ << ":" << __LINE__ << "OBD Other error:" << obd->lastError() << endl;
}
-
+
CommandRequest *req = new CommandRequest();
DebugOut() << __SMALLFILE__ << ":" << __LINE__ << "Queuing up a disconnect" << (ulong)req << endl;
req->req = "disconnect";
@@ -436,7 +446,7 @@ void threadLoop(gpointer data)
//usleep(10000);
}
repeatReqList.clear();
-
+
}
if (connected)
{
@@ -447,19 +457,20 @@ static int updateProperties( gpointer data)
{
OBD2Source* src = (OBD2Source*)data;
-
+
while (gpointer retval = g_async_queue_try_pop(src->statusQueue))
{
StatusMessage *reply = (StatusMessage*)retval;
if (reply->statusStr == "disconnected")
{
OBD2Source::Obd2ConnectType val(Obd2Connected,false);
- src->updateProperty(Obd2Connected,&val);
+ src->updateProperty(&val);
}
else if (reply->statusStr == "connected")
{
OBD2Source::Obd2ConnectType val(Obd2Connected, true);
- src->updateProperty(Obd2Connected,&val);
+ val.priority = OBD2Source::Obd2ConnectType::Instant;
+ src->updateProperty(&val);
}
else if (reply->statusStr == "error:nodata" || reply->statusStr == "error:timeout")
{
@@ -487,20 +498,20 @@ static int updateProperties( gpointer data)
{
ObdPid *reply = (ObdPid*)retval;
-
- AbstractPropertyType* value = VehicleProperty::getPropertyTypeForPropertyNameValue(reply->property, reply->value);
- src->updateProperty(reply->property, value);
- delete value;
+ auto value = amb::make_unique(VehicleProperty::getPropertyTypeForPropertyNameValue(reply->property, reply->value));
+ value->priority = AbstractPropertyType::Instant;
+ src->updateProperty(value.get());
}
return true;
}
-void OBD2Source::updateProperty(VehicleProperty::Property property,AbstractPropertyType* value)
+void OBD2Source::updateProperty(AbstractPropertyType* value)
{
+ VehicleProperty::Property property = value->name;
if(property == Obd2Connected)
obd2Connected.setValue(value->anyValue());
-
+
if (propertyReplyMap.find(property) != propertyReplyMap.end())
{
propertyReplyMap[property]->value = value;
@@ -549,13 +560,13 @@ void OBD2Source::setConfiguration(map<string, string> config)
{
// //Config has been passed, let's start stuff up.
configuration = config;
-
+
//Default values
std::string port = "/dev/ttyUSB0";
std::string baud = "115200";
std::string btadapter = "";
m_isBluetooth = false;
-
+
//Try to load config
//printf("OBD2Source::setConfiguration\n");
for (map<string,string>::iterator i=configuration.begin();i!=configuration.end();i++)
@@ -607,7 +618,7 @@ void OBD2Source::setConfiguration(map<string, string> config)
req->arglist.push_back(port);
req->arglist.push_back(baud);
g_async_queue_push(commandQueue,req);
-
+
m_port = port;
m_baud = baud;
m_gThread = g_thread_new("mythread",(GThreadFunc)&threadLoop,this);
@@ -626,7 +637,7 @@ OBD2Source::OBD2Source(AbstractRoutingEngine *re, map<string, string> config)
}
clientConnected = false;
- m_re = re;
+ m_re = re;
m_threadLive = true;
Obd2Amb obd2amb;
@@ -670,7 +681,7 @@ int OBD2Source::supportedOperations()
extern "C" AbstractSource * create(AbstractRoutingEngine* routingengine, map<string, string> config)
{
return new OBD2Source(routingengine, config);
-
+
}
const string OBD2Source::uuid()
{
@@ -699,18 +710,19 @@ void OBD2Source::subscribeToPropertyChanges(VehicleProperty::Property property)
if(!pid)
{
+ DebugOut(DebugOut::Warning) << "We don't support this property: " << property <<endl;
return;
}
-
+
//If the pid is currently in the blacklist map, erase it. This allows for applications
//to "un-blacklist" a pid by re-subscribing to it.
if (m_blacklistPidCountMap.find(pid->pid) != m_blacklistPidCountMap.end())
{
m_blacklistPidCountMap.erase(m_blacklistPidCountMap.find(pid->pid));
}
-
-
- g_async_queue_push(subscriptionAddQueue,pid);
+
+
+ g_async_queue_push(subscriptionAddQueue, pid);
CommandRequest *req = new CommandRequest();
req->req = "connectifnot";
g_async_queue_push(commandQueue,req);
diff --git a/plugins/obd2plugin/obd2source.h b/plugins/obd2plugin/obd2source.h
index 6b20e30e..d93f1b44 100644
--- a/plugins/obd2plugin/obd2source.h
+++ b/plugins/obd2plugin/obd2source.h
@@ -114,7 +114,7 @@ public:
{
continue;
}
-
+
ObdPid* pid = (*itr)->create();
return pid;
}
@@ -181,7 +181,7 @@ public:
std::string m_btDeviceAddress;
std::string m_btAdapterAddress;
map<VehicleProperty::Property,AsyncPropertyReply*> propertyReplyMap;
- void updateProperty(VehicleProperty::Property property,AbstractPropertyType *value);
+ void updateProperty(AbstractPropertyType *value);
obdLib * obd;
bool m_threadLive;
GThread *m_gThread;
diff --git a/plugins/testplugin/testplugin.cpp b/plugins/testplugin/testplugin.cpp
index 476660cb..be3c9acb 100644
--- a/plugins/testplugin/testplugin.cpp
+++ b/plugins/testplugin/testplugin.cpp
@@ -319,11 +319,11 @@ TestPlugin::TestPlugin(AbstractRoutingEngine *re, map<string, string> config)
supportedPropertyChanges(0)
{
- cout<<"Capabilities: "<<endl;
+ DebugOut(0) << "Capabilities: " << endl;
for(auto prop : VehicleProperty::capabilities())
{
- cout<<prop<<endl;
+ DebugOut(0) << prop << endl;
}
DebugOut() << "Testing Core::setSupported... " << endl;
diff --git a/plugins/wheel/wheelplugin.cpp b/plugins/wheel/wheelplugin.cpp
index e8cb142c..f6ebdbb6 100644
--- a/plugins/wheel/wheelplugin.cpp
+++ b/plugins/wheel/wheelplugin.cpp
@@ -517,7 +517,11 @@ void WheelPrivate::changeGear(int gear)
void WheelPrivate::changeOilPressure(bool increase)
{
- (increase ? *(oilPSI)++ : *(oilPSI)--);
+ if(increase)
+ oilPSI->setValue(oilPSI->basicValue()+1);
+ else if(oilPSI->basicValue() > 0)
+ oilPSI->setValue(oilPSI->basicValue()-1);
+
this->re->updateProperty(oilPSI, mParent->uuid());
}