diff options
author | Sven Gothel <[email protected]> | 2020-07-24 10:00:15 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-07-24 10:00:15 +0200 |
commit | 3437e34c97c1dad0c4c0d27680371f693aadac4f (patch) | |
tree | 5e2e5ad9dd3351ad5e332ed2159a0e6f3428a92e /examples/direct_bt_scanner01 | |
parent | a1e74bf1e23f4833261556e55612f34afc8dbcf1 (diff) |
Reworking GATTCharacteristicListener (C++ and Java)
- Aligned all related C++ and Java API doc entries and made sure it matches implementation.
- Renaming SpecificGATTCharacteristicListener to AssociatedGATTCharacteristicListener,
as we refer to the associate GATTCharacteristic of a GATTCharacteristicListener
AssociatedGATTCharacteristicListener is a specialization knowing its
associated GATTCharacteristic to be used for match().
- Renamed 'configIndicationNotification(..)' to 'configNotificationIndication(..)',
matching order of arguments and the returned enabledState array.
- Exposed 'configNotificationIndication(..)' incl enabledState array to Java
- Clarified the 'add listener' and 'configNotificationIndication(..)' semantic in API doc
and implementation. Added new API entries to distinguish them.
- DBTGattCharacteristic.java skips adding its 'TinyB API compatibility' GATTCharacteristicListener
in case neither notify nor indicate property exist.
Also skip the native configNotificationIndication(..) in such case.
This reduces the overall listener load to GattHandler by factor 5!
- General: Add new method 'removeAllAssociatedCharacteristicListener(GATTCharacteristic)',
allowing removal of all GATTCharacteristic associated listener.
This is usefull to complete the GATTCharacteristic C++ dtor or Java close() operation.
- DBTDevice: Add GATTCharacteristicListener methods to align with Java API
and allow user not to deal with GATTHandler directly.
Convenience and validates the C++/Java API alignement.
- C++ JNICriticalArray: Added 2nd template typename for the java-array-type,
enabling it for other than jbyteArray. Here used for a jbooleanArray.
- The GATTCharacteristicListener Java to C++ native holding specialization JNICharacteristicListener
keeps a new global reference to the Java GATTCharacteristicListener
and the optional associated GATTCharacteristic.
This ensures the instances won't get garbage collected and hence ensures proper
object lifecycle even when passing 'throw away' listener object created just
for the add*Listener call.
- Removal and hence destruction of the listeners is always guaranteed at:
-- Device / GATTHandler disconnect
-- GattCharacteristic dtor or close
Diffstat (limited to 'examples/direct_bt_scanner01')
-rw-r--r-- | examples/direct_bt_scanner01/dbt_scanner01.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/examples/direct_bt_scanner01/dbt_scanner01.cpp b/examples/direct_bt_scanner01/dbt_scanner01.cpp index 10eca512..2fead468 100644 --- a/examples/direct_bt_scanner01/dbt_scanner01.cpp +++ b/examples/direct_bt_scanner01/dbt_scanner01.cpp @@ -290,7 +290,7 @@ int main(int argc, char *argv[]) const bool enableNotification = serviceChar.hasProperties(GATTCharacteristic::PropertyBitVal::Notify); const bool enableIndication = serviceChar.hasProperties(GATTCharacteristic::PropertyBitVal::Indicate); if( enableNotification || enableIndication ) { - bool res = gatt->configIndicationNotification(*cccd, enableNotification, enableIndication); + bool res = gatt->configNotificationIndication(*cccd, enableNotification, enableIndication); fprintf(stderr, " [%2.2d.%2.2d] Config Notification(%d), Indication(%d): Result %d\n", (int)i, (int)j, enableNotification, enableIndication, res); } |