diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/direct_bt_scanner10/dbt_scanner10.cpp | 7 | ||||
-rw-r--r-- | examples/java/ScannerTinyB10.java | 14 |
2 files changed, 19 insertions, 2 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) { |