summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-09-22 11:20:18 +0200
committerSven Gothel <[email protected]>2020-09-22 11:20:18 +0200
commit21c1368b65e7724bee516f21a8186002020c5f3b (patch)
tree64d992f6ed8b02034ec5e19aed9bf55df1cb0bd5
parent8eb3ecb3033b28c5b6cc13807d0948f245ce9729 (diff)
Fix Java_direct_1bt_tinyb_DBTGattDescriptor_toStringImpl(..): Wrong arg list, oops. Added call to C++/Java example for validationv2.1.27
-rw-r--r--examples/direct_bt_scanner10/dbt_scanner10.cpp7
-rw-r--r--examples/java/ScannerTinyB10.java14
-rw-r--r--java/jni/direct_bt/DBTGattDescriptor.cxx8
3 files changed, 23 insertions, 6 deletions
diff --git a/examples/direct_bt_scanner10/dbt_scanner10.cpp b/examples/direct_bt_scanner10/dbt_scanner10.cpp
index 238c2fd9..c62ade8b 100644
--- a/examples/direct_bt_scanner10/dbt_scanner10.cpp
+++ b/examples/direct_bt_scanner10/dbt_scanner10.cpp
@@ -371,6 +371,13 @@ static void processConnectedDevice(std::shared_ptr<DBTDevice> device) {
}
}
}
+ std::vector<GATTDescriptorRef> & charDescList = serviceChar.descriptorList;
+ for(size_t k=0; k<charDescList.size(); k++) {
+ GATTDescriptor & charDesc = *charDescList.at(k);
+ if( !SILENT_GATT ) {
+ fprintf(stderr, " [%2.2d.%2.2d.%2.2d] Desc: %s\n", (int)i, (int)j, (int)k, charDesc.toString().c_str());
+ }
+ }
bool cccdEnableResult[2];
bool cccdRet = serviceChar.addCharacteristicListener( std::shared_ptr<GATTCharacteristicListener>( new MyGATTEventListener(&serviceChar) ),
cccdEnableResult );
diff --git a/examples/java/ScannerTinyB10.java b/examples/java/ScannerTinyB10.java
index 1c38a45f..b57c992e 100644
--- a/examples/java/ScannerTinyB10.java
+++ b/examples/java/ScannerTinyB10.java
@@ -41,6 +41,7 @@ import org.tinyb.BTMode;
import org.tinyb.BluetoothException;
import org.tinyb.BluetoothFactory;
import org.tinyb.BluetoothGattCharacteristic;
+import org.tinyb.BluetoothGattDescriptor;
import org.tinyb.BluetoothGattService;
import org.tinyb.BluetoothManager;
import org.tinyb.BluetoothNotification;
@@ -353,18 +354,19 @@ public class ScannerTinyB10 {
}
try {
- int i=0, j=0;
+ int i=0;
for(final Iterator<BluetoothGattService> srvIter = primServices.iterator(); srvIter.hasNext(); i++) {
final BluetoothGattService primService = srvIter.next();
if( !SILENT_GATT ) {
printf(" [%02d] Service %s\n", i, primService.toString());
printf(" [%02d] Service Characteristics\n", i);
}
+ int j=0;
final List<BluetoothGattCharacteristic> serviceCharacteristics = primService.getCharacteristics();
for(final Iterator<BluetoothGattCharacteristic> charIter = serviceCharacteristics.iterator(); charIter.hasNext(); j++) {
final BluetoothGattCharacteristic serviceChar = charIter.next();
if( !SILENT_GATT ) {
- printf(" [%02d.%02d] CharDec: %s\n", i, j, serviceChar.toString());
+ printf(" [%02d.%02d] CharDef: %s\n", i, j, serviceChar.toString());
}
final List<String> properties = Arrays.asList(serviceChar.getFlags());
if( properties.contains("read") ) {
@@ -375,6 +377,14 @@ public class ScannerTinyB10 {
i, j, BluetoothUtils.bytesHexString(value, true, true), svalue);
}
}
+ int k=0;
+ final List<BluetoothGattDescriptor> charDescList = serviceChar.getDescriptors();
+ for(final Iterator<BluetoothGattDescriptor> descIter = charDescList.iterator(); descIter.hasNext(); k++) {
+ final BluetoothGattDescriptor charDesc = descIter.next();
+ if( !SILENT_GATT ) {
+ printf(" [%02d.%02d.%02d] Desc: %s\n", i, j, k, charDesc.toString());
+ }
+ }
}
}
} catch( final Exception ex) {
diff --git a/java/jni/direct_bt/DBTGattDescriptor.cxx b/java/jni/direct_bt/DBTGattDescriptor.cxx
index d1462825..1dfc372f 100644
--- a/java/jni/direct_bt/DBTGattDescriptor.cxx
+++ b/java/jni/direct_bt/DBTGattDescriptor.cxx
@@ -47,12 +47,12 @@ void Java_direct_1bt_tinyb_DBTGattDescriptor_deleteImpl(JNIEnv *env, jobject obj
}
}
-jstring Java_direct_1bt_tinyb_DBTGattDescriptor_toStringImpl(JNIEnv *env, jobject obj, jlong nativeInstance) {
+jstring Java_direct_1bt_tinyb_DBTGattDescriptor_toStringImpl(JNIEnv *env, jobject obj) {
(void)obj;
try {
- GATTDescriptor *nativePtr = castInstance<GATTDescriptor>(nativeInstance);
- JavaGlobalObj::check(nativePtr->getJavaObject(), E_FILE_LINE);
- return from_string_to_jstring(env, nativePtr->toString());
+ GATTDescriptor *descriptor = getDBTObject<GATTDescriptor>(env, obj);
+ JavaGlobalObj::check(descriptor->getJavaObject(), E_FILE_LINE);
+ return from_string_to_jstring(env, descriptor->toString());
} catch(...) {
rethrow_and_raise_java_exception(env);
}