aboutsummaryrefslogtreecommitdiffstats
path: root/java/org
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2021-09-15 10:59:36 +0200
committerSven Gothel <[email protected]>2021-09-15 10:59:36 +0200
commite4c14618bfae926adc4c12f7832b443a4b27a6d5 (patch)
treec4a1bacda565b54f8d2288ba2ab565d236020a5d /java/org
parentc3968a061a0042c6ad17938638f397ddd42b3261 (diff)
Add advertising support (start with set-data and -params, stop) via HCIHandler
Reasonable default values have been chosen from the BT spec, which can be overriden using the HCIHandler and BTAdapter operations. The extended advertising operations are also supported (Bluetooth 5.0). +++ Successfully tested running: (0) Test machine with 2 adapter - adapter-1 DC:FB:48:00:90:19 (acting as client) - adapter-2 00:1A:7D:DA:71:08 (acting as peripheral) (1) Running dbt_peripheral00.cpp or DBTPeripheral.java as the advertising peripheral on the test machine. `direct_bt/dist-amd64$ ../scripts/run-dbt_peripheral00.sh -adapter 00:1A:7D:DA:71:08` or `direct_bt/dist-amd64$ ../scripts/run-java-peripheral00.sh -adapter 00:1A:7D:DA:71:08` (2) Running dbt_scanner10.cpp or DBTScanner10.java as the listeninig and connection-initiator client on the same test machine. `direct_bt/dist-amd64$ sh ../scripts/run-dbt_scanner10.sh -adapter DC:FB:48:00:90:19 -dev 00:1A:7D:DA:71:08 -seclevel 00:1A:7D:DA:71:08 1` or `direct_bt/dist-amd64$ sh ../scripts/run-java-scanner10.sh -adapter DC:FB:48:00:90:19 -dev 00:1A:7D:DA:71:08 -seclevel 00:1A:7D:DA:71:08 1`
Diffstat (limited to 'java/org')
-rw-r--r--java/org/direct_bt/BTAdapter.java68
1 files changed, 67 insertions, 1 deletions
diff --git a/java/org/direct_bt/BTAdapter.java b/java/org/direct_bt/BTAdapter.java
index 68e9e6c0..47664e33 100644
--- a/java/org/direct_bt/BTAdapter.java
+++ b/java/org/direct_bt/BTAdapter.java
@@ -218,7 +218,73 @@ public interface BTAdapter extends BTObject
*/
public boolean removeDiscoveredDevice(final BDAddressAndType addressAndType);
- /* D-Bus property accessors: */
+
+ /**
+ * Starts advertising
+ * <pre>
+ * BT Core Spec v5.2: Vol 4 HCI, Part E HCI Functional: 7.8.53 LE Set Extended Advertising Parameters command (Bluetooth 5.0)
+ * BT Core Spec v5.2: Vol 4 HCI, Part E HCI Functional: 7.8.54 LE Set Extended Advertising Data command (Bluetooth 5.0)
+ * BT Core Spec v5.2: Vol 4 HCI, Part E HCI Functional: 7.8.55 LE Set Extended Scan Response Data command (Bluetooth 5.0)
+ * BT Core Spec v5.2: Vol 4 HCI, Part E HCI Functional: 7.8.56 LE Set Extended Advertising Enable command (Bluetooth 5.0)
+ *
+ * if available, otherwise using
+ *
+ * BT Core Spec v5.2: Vol 4 HCI, Part E HCI Functional: 7.8.5 LE Set Advertising Parameters command
+ * BT Core Spec v5.2: Vol 4 HCI, Part E HCI Functional: 7.8.7 LE Set Advertising Data command
+ * BT Core Spec v5.2: Vol 4 HCI, Part E HCI Functional: 7.8.8 LE Set Scan Response Data command
+ * BT Core Spec v5.2: Vol 4 HCI, Part E HCI Functional: 7.8.9 LE Set Advertising Enable command
+ * </pre>
+ *
+ * @param adv_interval_min in units of 0.625ms, default value 0x0800 for 1.28s; Value range [0x0020 .. 0x4000] for [20ms .. 10.24s]
+ * @param adv_interval_max in units of 0.625ms, default value 0x0800 for 1.28s; Value range [0x0020 .. 0x4000] for [20ms .. 10.24s]
+ * @param adv_type see AD_PDU_Type, default 0x00, i.e. ::AD_PDU_Type::ADV_IND
+ * @param adv_chan_map bit 0: chan 37, bit 1: chan 38, bit 2: chan 39, default is 0x07 (all 3 channels enabled)
+ * @param filter_policy 0x00 accepts all PDUs (default), 0x01 only of whitelisted, ...
+ * @return HCIStatusCode::SUCCESS if successful, otherwise the HCIStatusCode error state
+ * @see #startAdvertising()
+ * @see #stopAdvertising()
+ * @see #isAdvertising()
+ * @since 2.4.0
+ */
+ HCIStatusCode startAdvertising(final short adv_interval_min, final short adv_interval_max,
+ final byte adv_type, final byte adv_chan_map, final byte filter_policy);
+
+ /**
+ * Starts advertising using all default arguments.
+ * @return HCIStatusCode::SUCCESS if successful, otherwise the HCIStatusCode error state
+ * @see #startAdvertising(short, short, byte, byte, byte)
+ * @see #stopAdvertising()
+ * @see #isAdvertising()
+ * @since 2.4.0
+ */
+ HCIStatusCode startAdvertising(); /* {
+ return startAdvertising((short)0x0800, (short)0x0800, (byte)0, // AD_PDU_Type::ADV_IND,
+ (byte)0x07, (byte)0x00);
+ } */
+
+ /**
+ * Ends advertising.
+ * <pre>
+ * BT Core Spec v5.2: Vol 4 HCI, Part E HCI Functional: 7.8.56 LE Set Extended Advertising Enable command (Bluetooth 5.0)
+ *
+ * if available, otherwise using
+ *
+ * BT Core Spec v5.2: Vol 4 HCI, Part E HCI Functional: 7.8.9 LE Set Advertising Enable command
+ * </pre>
+ * @return HCIStatusCode::SUCCESS if successful, otherwise the HCIStatusCode error state
+ * @see #startAdvertising(short, short, byte, byte, byte)
+ * @see #isAdvertising()
+ * @since 2.4.0
+ */
+ HCIStatusCode stopAdvertising();
+
+ /**
+ * Returns the adapter's current advertising state. It can be modified through startAdvertising(..) and stopAdvertising().
+ * @see #startAdvertising(short, short, byte, byte, byte)
+ * @see #stopAdvertising()
+ * @since 2.4.0
+ */
+ boolean isAdvertising();
/**
* Returns the adapter's public BDAddressAndType.