aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/direct_bt/tinyb/DBTAdapter.java24
-rw-r--r--java/direct_bt/tinyb/DBTManager.java7
-rw-r--r--java/jni/direct_bt/DBTAdapter.cxx31
-rw-r--r--java/jni/tinyb/DBusAdapter.cxx22
-rw-r--r--java/jni/tinyb/DBusManager.cxx2
-rw-r--r--java/org/tinyb/BluetoothAdapter.java62
-rw-r--r--java/org/tinyb/BluetoothManager.java16
-rw-r--r--java/tinyb/dbus/DBusAdapter.java19
-rw-r--r--java/tinyb/dbus/DBusManager.java10
9 files changed, 117 insertions, 76 deletions
diff --git a/java/direct_bt/tinyb/DBTAdapter.java b/java/direct_bt/tinyb/DBTAdapter.java
index c53b712b..3e3e3973 100644
--- a/java/direct_bt/tinyb/DBTAdapter.java
+++ b/java/direct_bt/tinyb/DBTAdapter.java
@@ -199,13 +199,13 @@ public class DBTAdapter extends DBTObject implements BluetoothAdapter
public long getDiscoverableTimeout() { throw new UnsupportedOperationException(); } // FIXME
@Override
- public void setDiscoverableTimout(final long value) { throw new UnsupportedOperationException(); } // FIXME
+ public boolean setDiscoverableTimout(final long value) { return false; } // FIXME
@Override
public long getPairableTimeout() { throw new UnsupportedOperationException(); } // FIXME
@Override
- public void setPairableTimeout(final long value) { throw new UnsupportedOperationException(); } // FIXME
+ public boolean setPairableTimeout(final long value) { return false; } // FIXME
@Override
public String getModalias() { throw new UnsupportedOperationException(); } // FIXME
@@ -301,7 +301,7 @@ public class DBTAdapter extends DBTObject implements BluetoothAdapter
private native String toStringImpl();
@Override
- public native void setPowered(boolean value);
+ public native boolean setPowered(boolean value);
@Override
public final HCIStatusCode reset() {
@@ -316,13 +316,13 @@ public class DBTAdapter extends DBTObject implements BluetoothAdapter
public native void setAlias(final String value);
@Override
- public native void setDiscoverable(boolean value);
+ public native boolean setDiscoverable(boolean value);
@Override
public native BluetoothDevice connectDevice(String address, String addressType);
@Override
- public native void setPairable(boolean value);
+ public native boolean setPairable(boolean value);
@Override
public native boolean isEnabled();
@@ -336,28 +336,28 @@ public class DBTAdapter extends DBTObject implements BluetoothAdapter
@Override
public boolean startDiscovery() throws BluetoothException {
- return startDiscovery(true);
+ return HCIStatusCode.SUCCESS == startDiscovery(true);
}
@Override
- public boolean startDiscovery(final boolean keepAlive) throws BluetoothException {
+ public HCIStatusCode startDiscovery(final boolean keepAlive) throws BluetoothException {
synchronized( discoveryLock ) {
// Ignoring 'isDiscovering', as native implementation also handles change of 'keepAlive'.
// The discoveredDevices shall always get cleared.
removeDevices();
- return startDiscoveryImpl(keepAlive); // event callbacks will be generated by implementation
+ return HCIStatusCode.get( startDiscoveryImpl(keepAlive) ); // event callbacks will be generated by implementation
}
}
- private native boolean startDiscoveryImpl(boolean keepAlive) throws BluetoothException;
+ private native byte startDiscoveryImpl(boolean keepAlive) throws BluetoothException;
@Override
- public boolean stopDiscovery() throws BluetoothException {
+ public HCIStatusCode stopDiscovery() throws BluetoothException {
synchronized( discoveryLock ) {
// Ignoring 'isDiscovering', be consistent with startDiscovery
- return stopDiscoveryImpl(); // event callbacks will be generated by implementation
+ return HCIStatusCode.get( stopDiscoveryImpl() ); // event callbacks will be generated by implementation
}
}
- private native boolean stopDiscoveryImpl() throws BluetoothException;
+ private native byte stopDiscoveryImpl() throws BluetoothException;
@Override
public List<BluetoothDevice> getDevices() {
diff --git a/java/direct_bt/tinyb/DBTManager.java b/java/direct_bt/tinyb/DBTManager.java
index c903b7ba..82b25166 100644
--- a/java/direct_bt/tinyb/DBTManager.java
+++ b/java/direct_bt/tinyb/DBTManager.java
@@ -41,6 +41,7 @@ import org.tinyb.BluetoothGattService;
import org.tinyb.BluetoothObject;
import org.tinyb.BluetoothManager;
import org.tinyb.BluetoothType;
+import org.tinyb.HCIStatusCode;
public class DBTManager implements BluetoothManager
{
@@ -259,13 +260,13 @@ public class DBTManager implements BluetoothManager
public BluetoothAdapter getDefaultAdapter() { return adapters.get(defaultAdapterIndex); }
@Override
- public boolean startDiscovery() throws BluetoothException { return startDiscovery(true); }
+ public boolean startDiscovery() throws BluetoothException { return HCIStatusCode.SUCCESS == startDiscovery(true); }
@Override
- public boolean startDiscovery(final boolean keepAlive) throws BluetoothException { return getDefaultAdapter().startDiscovery(keepAlive); }
+ public HCIStatusCode startDiscovery(final boolean keepAlive) throws BluetoothException { return getDefaultAdapter().startDiscovery(keepAlive); }
@Override
- public boolean stopDiscovery() throws BluetoothException { return getDefaultAdapter().stopDiscovery(); }
+ public HCIStatusCode stopDiscovery() throws BluetoothException { return getDefaultAdapter().stopDiscovery(); }
@Override
public boolean getDiscovering() throws BluetoothException { return getDefaultAdapter().getDiscovering(); }
diff --git a/java/jni/direct_bt/DBTAdapter.cxx b/java/jni/direct_bt/DBTAdapter.cxx
index 80ca0ccb..6bdf58fa 100644
--- a/java/jni/direct_bt/DBTAdapter.cxx
+++ b/java/jni/direct_bt/DBTAdapter.cxx
@@ -230,7 +230,7 @@ class JNIAdapterStatusListener : public AdapterStatusListener {
return device == *deviceMatchRef;
}
- void adapterSettingsChanged(DBTAdapter const &a, const AdapterSetting oldmask, const AdapterSetting newmask,
+ void adapterSettingsChanged(DBTAdapter &a, const AdapterSetting oldmask, const AdapterSetting newmask,
const AdapterSetting changedmask, const uint64_t timestamp) override {
JNIEnv *env = *jni_env;
(void)a;
@@ -254,7 +254,7 @@ class JNIAdapterStatusListener : public AdapterStatusListener {
env->DeleteLocalRef(adapterSettingChanged);
}
- void discoveringChanged(DBTAdapter const &a, const bool enabled, const bool keepAlive, const uint64_t timestamp) override {
+ void discoveringChanged(DBTAdapter &a, const bool enabled, const bool keepAlive, const uint64_t timestamp) override {
JNIEnv *env = *jni_env;
(void)a;
env->CallVoidMethod(listenerObjRef.getObject(), mDiscoveringChanged, JavaGlobalObj::GetObject(adapterObjRef),
@@ -545,26 +545,26 @@ jboolean Java_direct_1bt_tinyb_DBTAdapter_isEnabled(JNIEnv *env, jobject obj)
return JNI_FALSE;
}
-jboolean Java_direct_1bt_tinyb_DBTAdapter_startDiscoveryImpl(JNIEnv *env, jobject obj, jboolean keepAlive)
+jbyte Java_direct_1bt_tinyb_DBTAdapter_startDiscoveryImpl(JNIEnv *env, jobject obj, jboolean keepAlive)
{
try {
DBTAdapter *adapter = getDBTObject<DBTAdapter>(env, obj);
- return adapter->startDiscovery(keepAlive);
+ return (jbyte) number( adapter->startDiscovery(keepAlive) );
} catch(...) {
rethrow_and_raise_java_exception(env);
}
- return JNI_FALSE;
+ return (jbyte) number(HCIStatusCode::INTERNAL_FAILURE);
}
-jboolean Java_direct_1bt_tinyb_DBTAdapter_stopDiscoveryImpl(JNIEnv *env, jobject obj)
+jbyte Java_direct_1bt_tinyb_DBTAdapter_stopDiscoveryImpl(JNIEnv *env, jobject obj)
{
try {
DBTAdapter *adapter = getDBTObject<DBTAdapter>(env, obj);
- return adapter->stopDiscovery();
+ return (jbyte) number( adapter->stopDiscovery() );
} catch(...) {
rethrow_and_raise_java_exception(env);
}
- return JNI_FALSE;
+ return (jbyte) number(HCIStatusCode::INTERNAL_FAILURE);
}
jobject Java_direct_1bt_tinyb_DBTAdapter_getDiscoveredDevicesImpl(JNIEnv *env, jobject obj)
@@ -594,14 +594,15 @@ jint Java_direct_1bt_tinyb_DBTAdapter_removeDevicesImpl(JNIEnv *env, jobject obj
// misc
//
-void Java_direct_1bt_tinyb_DBTAdapter_setPowered(JNIEnv *env, jobject obj, jboolean value) {
+jboolean Java_direct_1bt_tinyb_DBTAdapter_setPowered(JNIEnv *env, jobject obj, jboolean value) {
try {
DBTAdapter *adapter = getDBTObject<DBTAdapter>(env, obj);
JavaGlobalObj::check(adapter->getJavaObject(), E_FILE_LINE);
- adapter->setPowered(JNI_TRUE == value ? true : false);
+ return adapter->setPowered(JNI_TRUE == value ? true : false) ? JNI_TRUE : JNI_FALSE;
} catch(...) {
rethrow_and_raise_java_exception(env);
}
+ return JNI_FALSE;
}
jbyte Java_direct_1bt_tinyb_DBTAdapter_resetImpl(JNIEnv *env, jobject obj) {
@@ -638,14 +639,15 @@ void Java_direct_1bt_tinyb_DBTAdapter_setAlias(JNIEnv *env, jobject obj, jstring
}
}
-void Java_direct_1bt_tinyb_DBTAdapter_setDiscoverable(JNIEnv *env, jobject obj, jboolean value) {
+jboolean Java_direct_1bt_tinyb_DBTAdapter_setDiscoverable(JNIEnv *env, jobject obj, jboolean value) {
try {
DBTAdapter *adapter = getDBTObject<DBTAdapter>(env, obj);
JavaGlobalObj::check(adapter->getJavaObject(), E_FILE_LINE);
- adapter->setDiscoverable(JNI_TRUE == value ? true : false);
+ return adapter->setDiscoverable(JNI_TRUE == value ? true : false) ? JNI_TRUE : JNI_FALSE;
} catch(...) {
rethrow_and_raise_java_exception(env);
}
+ return JNI_FALSE;
}
jobject Java_direct_1bt_tinyb_DBTAdapter_connectDevice(JNIEnv *env, jobject obj, jstring jaddress, jstring jaddressType) {
@@ -673,14 +675,15 @@ jobject Java_direct_1bt_tinyb_DBTAdapter_connectDevice(JNIEnv *env, jobject obj,
return nullptr;
}
-void Java_direct_1bt_tinyb_DBTAdapter_setPairable(JNIEnv *env, jobject obj, jboolean value) {
+jboolean Java_direct_1bt_tinyb_DBTAdapter_setPairable(JNIEnv *env, jobject obj, jboolean value) {
try {
DBTAdapter *adapter = getDBTObject<DBTAdapter>(env, obj);
JavaGlobalObj::check(adapter->getJavaObject(), E_FILE_LINE);
- adapter->setBondable(JNI_TRUE == value ? true : false);
+ return adapter->setBondable(JNI_TRUE == value ? true : false) ? JNI_TRUE : JNI_FALSE;
} catch(...) {
rethrow_and_raise_java_exception(env);
}
+ return JNI_FALSE;
}
void Java_direct_1bt_tinyb_DBTAdapter_setDiscoveryFilter(JNIEnv *env, jobject obj, jobject juuids, jint rssi, jint pathloss, jint transportType) {
diff --git a/java/jni/tinyb/DBusAdapter.cxx b/java/jni/tinyb/DBusAdapter.cxx
index 6e0eda56..fdc40101 100644
--- a/java/jni/tinyb/DBusAdapter.cxx
+++ b/java/jni/tinyb/DBusAdapter.cxx
@@ -67,7 +67,7 @@ jboolean Java_tinyb_dbus_DBusAdapter_startDiscovery(JNIEnv *env, jobject obj)
return JNI_FALSE;
}
-jboolean Java_tinyb_dbus_DBusAdapter_stopDiscovery(JNIEnv *env, jobject obj)
+jboolean Java_tinyb_dbus_DBusAdapter_stopDiscoveryImpl(JNIEnv *env, jobject obj)
{
try {
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
@@ -192,16 +192,18 @@ jboolean Java_tinyb_dbus_DBusAdapter_getPowered(JNIEnv *env, jobject obj)
return JNI_FALSE;
}
-void Java_tinyb_dbus_DBusAdapter_setPowered(JNIEnv *env, jobject obj, jboolean val)
+jboolean Java_tinyb_dbus_DBusAdapter_setPowered(JNIEnv *env, jobject obj, jboolean val)
{
try {
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
bool val_to_write = from_jboolean_to_bool(val);
obj_adapter->set_powered(val_to_write);
+ return JNI_TRUE;
} catch(...) {
rethrow_and_raise_java_exception(env);
}
+ return JNI_FALSE;
}
void Java_tinyb_dbus_DBusAdapter_enablePoweredNotifications(JNIEnv *env, jobject obj, jobject callback)
@@ -254,16 +256,18 @@ jboolean Java_tinyb_dbus_DBusAdapter_getDiscoverable(JNIEnv *env, jobject obj)
return JNI_FALSE;
}
-void Java_tinyb_dbus_DBusAdapter_setDiscoverable(JNIEnv *env, jobject obj, jboolean val)
+jboolean Java_tinyb_dbus_DBusAdapter_setDiscoverable(JNIEnv *env, jobject obj, jboolean val)
{
try {
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
bool val_to_write = from_jboolean_to_bool(val);
obj_adapter->set_discoverable(val_to_write);
+ return JNI_TRUE;
} catch(...) {
rethrow_and_raise_java_exception(env);
}
+ return JNI_FALSE;
}
void Java_tinyb_dbus_DBusAdapter_enableDiscoverableNotifications(JNIEnv *env, jobject obj, jobject callback)
@@ -316,7 +320,7 @@ jlong Java_tinyb_dbus_DBusAdapter_getDiscoverableTimeout(JNIEnv *env, jobject ob
return 0;
}
-void Java_tinyb_dbus_DBusAdapter_setDiscoverableTimout(JNIEnv *env, jobject obj, jlong timeout)
+jboolean Java_tinyb_dbus_DBusAdapter_setDiscoverableTimout(JNIEnv *env, jobject obj, jlong timeout)
{
try {
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
@@ -326,9 +330,11 @@ void Java_tinyb_dbus_DBusAdapter_setDiscoverableTimout(JNIEnv *env, jobject obj,
throw std::invalid_argument("timeout argument is negative\n");
}
obj_adapter->set_discoverable_timeout((unsigned int)timeout);
+ return JNI_TRUE;
} catch(...) {
rethrow_and_raise_java_exception(env);
}
+ return JNI_FALSE;
}
jboolean Java_tinyb_dbus_DBusAdapter_getPairable(JNIEnv *env, jobject obj)
@@ -381,16 +387,18 @@ void Java_tinyb_dbus_DBusAdapter_disablePairableNotifications(JNIEnv *env, jobje
}
}
-void Java_tinyb_dbus_DBusAdapter_setPairable(JNIEnv *env, jobject obj, jboolean val)
+jboolean Java_tinyb_dbus_DBusAdapter_setPairable(JNIEnv *env, jobject obj, jboolean val)
{
try {
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
bool val_to_write = from_jboolean_to_bool(val);
obj_adapter->set_pairable(val_to_write);
+ return JNI_TRUE;
} catch(...) {
rethrow_and_raise_java_exception(env);
}
+ return JNI_FALSE;
}
jlong Java_tinyb_dbus_DBusAdapter_getPairableTimeout(JNIEnv *env, jobject obj)
@@ -405,7 +413,7 @@ jlong Java_tinyb_dbus_DBusAdapter_getPairableTimeout(JNIEnv *env, jobject obj)
return 0;
}
-void Java_tinyb_dbus_DBusAdapter_setPairableTimeout(JNIEnv *env, jobject obj, jlong timeout)
+jboolean Java_tinyb_dbus_DBusAdapter_setPairableTimeout(JNIEnv *env, jobject obj, jlong timeout)
{
try {
BluetoothAdapter *obj_adapter = getInstance<BluetoothAdapter>(env, obj);
@@ -415,9 +423,11 @@ void Java_tinyb_dbus_DBusAdapter_setPairableTimeout(JNIEnv *env, jobject obj, jl
throw std::invalid_argument("timeout argument is negative\n");
}
obj_adapter->set_pairable_timeout((unsigned int)timeout);
+ return JNI_TRUE;
} catch(...) {
rethrow_and_raise_java_exception(env);
}
+ return JNI_FALSE;
}
jboolean Java_tinyb_dbus_DBusAdapter_getDiscovering(JNIEnv *env, jobject obj)
diff --git a/java/jni/tinyb/DBusManager.cxx b/java/jni/tinyb/DBusManager.cxx
index 28150a13..d8ee789e 100644
--- a/java/jni/tinyb/DBusManager.cxx
+++ b/java/jni/tinyb/DBusManager.cxx
@@ -293,7 +293,7 @@ jboolean Java_tinyb_dbus_DBusManager_startDiscovery(JNIEnv *env, jobject obj)
return JNI_FALSE;
}
-jboolean Java_tinyb_dbus_DBusManager_stopDiscovery(JNIEnv *env, jobject obj)
+jboolean Java_tinyb_dbus_DBusManager_stopDiscoveryImpl(JNIEnv *env, jobject obj)
{
try {
BluetoothManager *manager = getInstance<BluetoothManager>(env, obj);
diff --git a/java/org/tinyb/BluetoothAdapter.java b/java/org/tinyb/BluetoothAdapter.java
index 5d9637a9..20915083 100644
--- a/java/org/tinyb/BluetoothAdapter.java
+++ b/java/org/tinyb/BluetoothAdapter.java
@@ -167,18 +167,21 @@ public interface BluetoothAdapter extends BluetoothObject
* Using {@link #startDiscovery(boolean) startDiscovery}({@code keepAlive=true})
* and {@link #stopDiscovery()} is the recommended workflow
* for a reliable discovery process.
- * @return TRUE if discovery was successfully enabled
+ * @return {@link HCIStatusCode#SUCCESS} if successful, otherwise the {@link HCIStatusCode} error state
* @throws BluetoothException
* @since 2.0.0
* @implNote {@code keepAlive} not implemented in tinyb.dbus
* @see #getDiscovering()
*/
- public boolean startDiscovery(final boolean keepAlive) throws BluetoothException;
+ public HCIStatusCode startDiscovery(final boolean keepAlive) throws BluetoothException;
- /** Turns off device discovery if it is enabled.
- * @return TRUE if discovery was successfully disabled
- */
- public boolean stopDiscovery() throws BluetoothException;
+ /**
+ * Turns off device discovery if it is enabled.
+ * @return {@link HCIStatusCode#SUCCESS} if successful, otherwise the {@link HCIStatusCode} error state
+ * @apiNote return {@link HCIStatusCode} since 2.0.0
+ * @since 2.0.0
+ */
+ public HCIStatusCode stopDiscovery() throws BluetoothException;
/** Returns a list of BluetoothDevices visible from this adapter.
* @return A list of BluetoothDevices visible on this adapter,
@@ -249,9 +252,12 @@ public interface BluetoothAdapter extends BluetoothObject
*/
public void disablePoweredNotifications();
- /** Sets the power state the adapter.
- */
- public void setPowered(boolean value);
+ /**
+ * Sets the power state the adapter.
+ * @apiNote return value boolean since 2.0.0
+ * @since 2.0.0
+ */
+ public boolean setPowered(boolean value);
/**
* Reset the adapter.
@@ -282,19 +288,25 @@ public interface BluetoothAdapter extends BluetoothObject
*/
public void disableDiscoverableNotifications();
- /** Sets the discoverable state the adapter.
- */
- public void setDiscoverable(boolean value);
+ /**
+ * Sets the discoverable state the adapter.
+ * @apiNote return value boolean since 2.0.0
+ * @since 2.0.0
+ */
+ public boolean setDiscoverable(boolean value);
/** Returns the discoverable timeout the adapter.
* @return The discoverable timeout of the adapter.
*/
public long getDiscoverableTimeout();
- /** Sets the discoverable timeout the adapter. A value of 0 disables
- * the timeout.
- */
- public void setDiscoverableTimout(long value);
+ /**
+ * Sets the discoverable timeout the adapter. A value of 0 disables
+ * the timeout.
+ * @apiNote return value boolean since 2.0.0
+ * @since 2.0.0
+ */
+ public boolean setDiscoverableTimout(long value);
/**
* This method connects to device without need of
@@ -342,9 +354,12 @@ public interface BluetoothAdapter extends BluetoothObject
*/
public void disablePairableNotifications();
- /** Sets the discoverable state the adapter.
- */
- public void setPairable(boolean value);
+ /**
+ * Sets the discoverable state the adapter.
+ * @apiNote return value boolean since 2.0.0
+ * @since 2.0.0
+ */
+ public boolean setPairable(boolean value);
/** Returns the timeout in seconds after which pairable state turns off
* automatically, 0 means never.
@@ -352,9 +367,12 @@ public interface BluetoothAdapter extends BluetoothObject
*/
public long getPairableTimeout();
- /** Sets the timeout after which pairable state turns off automatically, 0 means never.
- */
- public void setPairableTimeout(long value);
+ /**
+ * Sets the timeout after which pairable state turns off automatically, 0 means never.
+ * @apiNote return value boolean since 2.0.0
+ * @since 2.0.0
+ */
+ public boolean setPairableTimeout(long value);
/**
* Returns the meta discovering state (of the adapter).
diff --git a/java/org/tinyb/BluetoothManager.java b/java/org/tinyb/BluetoothManager.java
index 2ddad81e..5c7eba23 100644
--- a/java/org/tinyb/BluetoothManager.java
+++ b/java/org/tinyb/BluetoothManager.java
@@ -229,18 +229,20 @@ public interface BluetoothManager
* Using {@link #startDiscovery(boolean) startDiscovery}({@code keepAlive=true})
* and {@link #stopDiscovery()} is the recommended workflow
* for a reliable discovery process.
- * @return TRUE if discovery was successfully enabled
+ * @return {@link HCIStatusCode#SUCCESS} if successful, otherwise the {@link HCIStatusCode} error state
* @throws BluetoothException
* @since 2.0.0
* @implNote {@code keepAlive} not implemented in tinyb.dbus
*/
- public boolean startDiscovery(final boolean keepAlive) throws BluetoothException;
+ public HCIStatusCode startDiscovery(final boolean keepAlive) throws BluetoothException;
-
- /** Turns off device discovery on the default adapter if it is enabled.
- * @return TRUE if discovery was successfully disabled
- */
- public boolean stopDiscovery() throws BluetoothException;
+ /**
+ * Turns off device discovery on the default adapter if it is enabled.
+ * @return {@link HCIStatusCode#SUCCESS} if successful, otherwise the {@link HCIStatusCode} error state
+ * @apiNote return {@link HCIStatusCode} since 2.0.0
+ * @since 2.0.0
+ */
+ public HCIStatusCode stopDiscovery() throws BluetoothException;
/** Returns if the discovers is running or not.
* @return TRUE if discovery is running
diff --git a/java/tinyb/dbus/DBusAdapter.java b/java/tinyb/dbus/DBusAdapter.java
index 964ee67a..a92beafa 100644
--- a/java/tinyb/dbus/DBusAdapter.java
+++ b/java/tinyb/dbus/DBusAdapter.java
@@ -105,12 +105,15 @@ public class DBusAdapter extends DBusObject implements BluetoothAdapter
public native boolean startDiscovery() throws BluetoothException;
@Override
- public synchronized boolean startDiscovery(final boolean keepAlive) throws BluetoothException {
- return startDiscovery(); // FIXME keepAlive
+ public synchronized HCIStatusCode startDiscovery(final boolean keepAlive) throws BluetoothException {
+ return startDiscovery() ? HCIStatusCode.SUCCESS : HCIStatusCode.INTERNAL_FAILURE; // FIXME keepAlive
}
@Override
- public native boolean stopDiscovery() throws BluetoothException;
+ public HCIStatusCode stopDiscovery() throws BluetoothException {
+ return stopDiscoveryImpl() ? HCIStatusCode.SUCCESS : HCIStatusCode.INTERNAL_FAILURE;
+ }
+ private native boolean stopDiscoveryImpl() throws BluetoothException;
@Override
public native List<BluetoothDevice> getDevices();
@@ -145,7 +148,7 @@ public class DBusAdapter extends DBusObject implements BluetoothAdapter
public native void disablePoweredNotifications();
@Override
- public native void setPowered(boolean value);
+ public native boolean setPowered(boolean value);
@Override
public final HCIStatusCode reset() { return HCIStatusCode.INTERNAL_FAILURE; }
@@ -160,13 +163,13 @@ public class DBusAdapter extends DBusObject implements BluetoothAdapter
public native void disableDiscoverableNotifications();
@Override
- public native void setDiscoverable(boolean value);
+ public native boolean setDiscoverable(boolean value);
@Override
public native long getDiscoverableTimeout();
@Override
- public native void setDiscoverableTimout(long value);
+ public native boolean setDiscoverableTimout(long value);
@Override
public native BluetoothDevice connectDevice(String address, String addressType);
@@ -181,13 +184,13 @@ public class DBusAdapter extends DBusObject implements BluetoothAdapter
public native void disablePairableNotifications();
@Override
- public native void setPairable(boolean value);
+ public native boolean setPairable(boolean value);
@Override
public native long getPairableTimeout();
@Override
- public native void setPairableTimeout(long value);
+ public native boolean setPairableTimeout(long value);
@Override
public native boolean getDiscovering();
diff --git a/java/tinyb/dbus/DBusManager.java b/java/tinyb/dbus/DBusManager.java
index 61d0935d..e815aeec 100644
--- a/java/tinyb/dbus/DBusManager.java
+++ b/java/tinyb/dbus/DBusManager.java
@@ -37,6 +37,7 @@ import org.tinyb.BluetoothGattService;
import org.tinyb.BluetoothObject;
import org.tinyb.BluetoothManager;
import org.tinyb.BluetoothType;
+import org.tinyb.HCIStatusCode;
public class DBusManager implements BluetoothManager
{
@@ -109,12 +110,15 @@ public class DBusManager implements BluetoothManager
public native boolean startDiscovery() throws BluetoothException;
@Override
- public boolean startDiscovery(final boolean keepAlive) throws BluetoothException {
- return startDiscovery(); // FIXME keepAlive
+ public HCIStatusCode startDiscovery(final boolean keepAlive) throws BluetoothException {
+ return startDiscovery() ? HCIStatusCode.SUCCESS : HCIStatusCode.INTERNAL_FAILURE; // FIXME keepAlive
}
@Override
- public native boolean stopDiscovery() throws BluetoothException;
+ public HCIStatusCode stopDiscovery() throws BluetoothException {
+ return stopDiscoveryImpl() ? HCIStatusCode.SUCCESS : HCIStatusCode.INTERNAL_FAILURE;
+ }
+ private native boolean stopDiscoveryImpl() throws BluetoothException;
@Override
public native boolean getDiscovering() throws BluetoothException;