diff options
author | Sven Gothel <[email protected]> | 2021-08-31 22:37:47 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2021-08-31 22:37:47 +0200 |
commit | b333478f163179fa9737d17ee30bc7d316f3de27 (patch) | |
tree | 10d16886e79e96b187ae599be3d753d547211dab | |
parent | 7ca6fea44262586d46e17efadbf268d17e242fd2 (diff) |
Properly expose runtime version C++ (DIRECT_BT_VERSION etc) and Java via BTFactory
-rw-r--r-- | api/direct_bt/DirectBT.hpp | 2 | ||||
-rw-r--r-- | api/direct_bt/version.h (renamed from include/tinyb_utils.hpp) | 27 | ||||
-rw-r--r-- | cmake/modules/version.c.in | 8 | ||||
-rw-r--r-- | examples/direct_bt_scanner10/dbt_scanner10.cpp | 2 | ||||
-rw-r--r-- | examples/java/DBTScanner10.java | 3 | ||||
-rw-r--r-- | include/BluetoothNotificationHandler.hpp | 11 | ||||
-rw-r--r-- | include/version.h | 5 | ||||
-rw-r--r-- | java/jni/BTFactory.cxx | 17 | ||||
-rw-r--r-- | java/org/direct_bt/BTFactory.java | 3 |
9 files changed, 37 insertions, 41 deletions
diff --git a/api/direct_bt/DirectBT.hpp b/api/direct_bt/DirectBT.hpp index 8e7a4bba..b573b2fe 100644 --- a/api/direct_bt/DirectBT.hpp +++ b/api/direct_bt/DirectBT.hpp @@ -40,6 +40,8 @@ #include <jau/darray.hpp> +#include "version.h" + #include "BTTypes0.hpp" #include "BTDevice.hpp" diff --git a/include/tinyb_utils.hpp b/api/direct_bt/version.h index 2365cf6d..9989cf7d 100644 --- a/include/tinyb_utils.hpp +++ b/api/direct_bt/version.h @@ -1,6 +1,7 @@ /* - * Author: Andrei Vasiliu <[email protected]> - * Copyright (c) 2015 Intel Corporation. + * Author: Sven Gothel <[email protected]> + * Copyright (c) 2020 Gothel Software e.K. + * Copyright (c) 2020 ZAFENA AB * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -22,21 +23,11 @@ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#pragma once +#ifndef DIRECT_BT_VERSION_H_ +#define DIRECT_BT_VERSION_H_ -#include "BluetoothObject.hpp" -#include "orgbluez-dbus.h" +extern const char* DIRECT_BT_VERSION; +extern const char* DIRECT_BT_VERSION_SHORT; +extern const char* DIRECT_BT_VERSION_API; -#include <cstring> -#include <vector> -#include <stdexcept> - -extern GDBusObjectManager *gdbus_manager; - -namespace tinyb { - std::vector<unsigned char> from_chars_to_vector(const gchar *chars); - std::vector<unsigned char> from_gbytes_to_vector(const GBytes *bytes); - GBytes *from_vector_to_gbytes(const std::vector<unsigned char>& array); - std::vector<unsigned char> from_iter_to_vector(GVariant *iter); - void handle_error(GError *error); -}; +#endif /* DIRECT_BT_VERSION_H_ */ diff --git a/cmake/modules/version.c.in b/cmake/modules/version.c.in index 81c07e18..0400a6c0 100644 --- a/cmake/modules/version.c.in +++ b/cmake/modules/version.c.in @@ -1,5 +1,5 @@ -#include "version.h" +#include <direct_bt/version.h> -const char* gVERSION = "@VERSION@"; -const char* gVERSION_SHORT = "@VERSION_SHORT@"; -const char* gVERSION_API = "@VERSION_API@"; +const char* DIRECT_BT_VERSION = "@VERSION@"; +const char* DIRECT_BT_VERSION_SHORT = "@VERSION_SHORT@"; +const char* DIRECT_BT_VERSION_API = "@VERSION_API@"; diff --git a/examples/direct_bt_scanner10/dbt_scanner10.cpp b/examples/direct_bt_scanner10/dbt_scanner10.cpp index 4ba38de1..6964769b 100644 --- a/examples/direct_bt_scanner10/dbt_scanner10.cpp +++ b/examples/direct_bt_scanner10/dbt_scanner10.cpp @@ -685,6 +685,8 @@ static bool myChangedAdapterSetFunc(const bool added, std::shared_ptr<BTAdapter> void test() { bool done = false; + fprintf_td(stderr, "DirectBT Native Version %s (API %s)\n", DIRECT_BT_VERSION, DIRECT_BT_VERSION_API); + timestamp_t0 = getCurrentMilliseconds(); BTManager & mngr = BTManager::get(); diff --git a/examples/java/DBTScanner10.java b/examples/java/DBTScanner10.java index a118820d..0caabfdc 100644 --- a/examples/java/DBTScanner10.java +++ b/examples/java/DBTScanner10.java @@ -776,6 +776,9 @@ public class DBTScanner10 { return; } BTUtils.println(System.err, "DirectBT BluetoothManager initialized!"); + BTUtils.println(System.err, "DirectBT Native Version "+BTFactory.getNativeVersion()+" (API "+BTFactory.getNativeAPIVersion()+")"); + BTUtils.println(System.err, "DirectBT Java Version "+BTFactory.getImplVersion()+" (API "+BTFactory.getAPIVersion()+")"); + final DBTScanner10 test = new DBTScanner10(); boolean waitForEnter=false; diff --git a/include/BluetoothNotificationHandler.hpp b/include/BluetoothNotificationHandler.hpp deleted file mode 100644 index 3acdb1d2..00000000 --- a/include/BluetoothNotificationHandler.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#include <gio/gio.h> - -class tinyb::BluetoothNotificationHandler { - -public: - static void on_properties_changed_adapter(GDBusProxy *proxy, GVariant *changed_properties, GStrv invalidated_properties, gpointer userdata); - static void on_properties_changed_device(GDBusProxy *proxy, GVariant *changed_properties, GStrv invalidated_properties, gpointer userdata); - static void on_properties_changed_characteristic(GDBusProxy *proxy, GVariant *changed_properties, GStrv invalidated_properties, gpointer userdata); - static void on_properties_changed_descriptor(GDBusProxy *proxy, GVariant *changed_properties, GStrv invalidated_properties, gpointer userdata); - -}; diff --git a/include/version.h b/include/version.h deleted file mode 100644 index 7a8a67c9..00000000 --- a/include/version.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -extern const char* gVERSION; -extern const char* gVERSION_SHORT; -extern const char* gVERSION_API; diff --git a/java/jni/BTFactory.cxx b/java/jni/BTFactory.cxx index ace0a6b3..3be7d34c 100644 --- a/java/jni/BTFactory.cxx +++ b/java/jni/BTFactory.cxx @@ -25,18 +25,31 @@ #include "org_direct_bt_BTFactory.h" -#include "version.h" +#include <direct_bt/version.h> #include "helper_base.hpp" using namespace jau; +jstring Java_org_direct_1bt_BTFactory_getNativeVersion(JNIEnv *env, jclass clazz) +{ + try { + (void) clazz; + + std::string api_version = std::string(DIRECT_BT_VERSION); + return env->NewStringUTF(api_version.c_str()); + } catch(...) { + rethrow_and_raise_java_exception(env); + } + return nullptr; +} + jstring Java_org_direct_1bt_BTFactory_getNativeAPIVersion(JNIEnv *env, jclass clazz) { try { (void) clazz; - std::string api_version = std::string(gVERSION_API); + std::string api_version = std::string(DIRECT_BT_VERSION_API); return env->NewStringUTF(api_version.c_str()); } catch(...) { rethrow_and_raise_java_exception(env); diff --git a/java/org/direct_bt/BTFactory.java b/java/org/direct_bt/BTFactory.java index 93f01b87..f66cbd5b 100644 --- a/java/org/direct_bt/BTFactory.java +++ b/java/org/direct_bt/BTFactory.java @@ -575,7 +575,8 @@ public class BTFactory { } } - private native static String getNativeAPIVersion(); + public native static String getNativeVersion(); + public native static String getNativeAPIVersion(); private native static void setenv(String name, String value, boolean overwrite); } |