Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
BTDevice.java
Go to the documentation of this file.
1/**
2 * Author: Sven Gothel <sgothel@jausoft.com>
3 * Copyright (c) 2020 Gothel Software e.K.
4 * Copyright (c) 2020 ZAFENA AB
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 *
25 */
26package org.direct_bt;
27
28import java.util.List;
29
30/**
31 * BTDevice represents one remote Bluetooth device.
32 *
33 * @anchor BTDeviceRoles
34 * Invariable remote BTDevice roles (see {@link #getRole()})
35 *
36 * - {@link BTRole::Master}: The remote device has discovered us and maybe is connected to us. The remote device acts as a GATT client.
37 * - {@link BTRole::Slave}: The remote device has advertised and maybe we are connected to it. The remote device acts as a GATT server.
38 *
39 * Note the local {@link BTAdapter}'s [opposite role](@ref BTAdapterRoles).
40 *
41 * @see BTAdapter
42 * @see [BTAdapter roles](@ref BTAdapterRoles).
43 * @see [Bluetooth Specification](https://www.bluetooth.com/specifications/bluetooth-core-specification/)
44 * @see [Direct-BT Overview](namespaceorg_1_1direct__bt.html#details)
45 */
46public interface BTDevice extends BTObject
47{
48 /**
49 * Add the given {@link AdapterStatusListener} to the list if not already present,
50 * listening only for events matching this device.
51 *
52 * The AdapterStatusListener is released at remove() or this device's destruction.
53 * <p>
54 * The newly added {@link AdapterStatusListener} will receive an initial
55 * {@link AdapterStatusListener#adapterSettingsChanged(BTAdapter, AdapterSettings, AdapterSettings, AdapterSettings, long) adapterSettingsChanged}
56 * event, passing an {@link AdapterSettings empty oldMask and changedMask}, as well as {@link AdapterSettings current newMask}. <br>
57 * This allows the receiver to be aware of this adapter's current settings.
58 * </p>
59 * @param listener A {@link AdapterStatusListener} instance
60 * @param deviceMatch Optional {@link BTDevice} to be matched before calling any
61 * {@link AdapterStatusListener} {@code device*} methods. Pass {@code null} for no filtering.
62 * @return true if the given listener is not element of the list and has been newly added, otherwise false.
63 * @since 2.3.0
64 * @see {@link BTDevice#addStatusListener(AdapterStatusListener, BTDevice)}
65 * @see {@link #removeStatusListener(AdapterStatusListener)}
66 * @see {@link #removeAllStatusListener()}
67 */
69
70 /**
71 * Remove the given {@link AdapterStatusListener} from the list.
72 * @param listener A {@link AdapterStatusListener} instance
73 * @return true if the given listener is an element of the list and has been removed, otherwise false.
74 * @since 2.3.0
75 */
77
78 /**
79 * {@code jau.direct_bt}: Disconnect the LE or BREDR peer's GATT and HCI connection.
80 * <p>
81 * BT Core Spec v5.2: Vol 4, Part E HCI: 7.1.6 Disconnect command
82 * </p>
83 * <p>
84 * The actual disconnect event will be delivered asynchronous and
85 * the connection event can be caught via AdapterStatusListener::deviceDisconnected(..).
86 * If unacceptable, {@link HCIStatusCode#UNACCEPTABLE_CONNECTION_PARAM} is being returned.
87 * </p>
88 * <p>
89 * The device will be removed from the managing adapter's connected devices
90 * when {@link AdapterStatusListener#deviceDisconnected(BTDevice, HCIStatusCode, long)} has been received.
91 * </p>
92 * <p>
93 * An open GATT connection will also be closed.<br>
94 * The connection to this device is removed, removing all connected profiles.
95 * </p>
96 * <p>
97 * An application using one thread per device and rapid connect, should either use {@link #disconnect()} or {@link #remove()},
98 * but never issue remove() after disconnect(). Doing so would eventually delete the device being already
99 * in use by another thread due to discovery post disconnect!
100 * </p>
101 * @return {@link HCIStatusCode#SUCCESS} if the command has been accepted, otherwise {@link HCIStatusCode} may disclose reason for rejection.
102 * @since 2.1.0 change API, i.e. return value from boolean to HCIStatusCode in favor of <i>direct_bt</i>
103 * @implNote {@code jau.direct_bt} does not throw a BTException on error, only a 'general' exception in case of fatality like NPE etc (FIXME: Remove throws)
104 */
106
107 /**
108 * Returns true if this device has completed SMP pairing or keys are set via uploadKeys()
109 * @see #uploadKeys()
110 * @since 3.2.3
111 */
112 boolean isPrePaired();
113
114 /**
115 * Returns the responder SMP passkey, ranging from [0..999999].
116 * <p>
117 * Authentication (MITM) PASSKEY (produced by this responder adapter, acting as peripheral GATT server) and shall be displayed for the initiating remote device, see {@link PairingMode#PASSKEY_ENTRY_ini}
118 * </p>
119 * @see SMPPairingState#PASSKEY_NOTIFY
120 * @see SMPPairingState#COMPLETED
121 * @see AdapterStatusListener#deviceReady(BTDevice, long)
122 */
124
125 /** Returns {@link #getResponderSMPPassKey()} as a canonical string, e.g. '012345'. */
127
128 /**
129 * {@code jau.direct_bt}: Establish a default HCI connection to this device, using certain default parameter.
130 * <p>
131 * BT Core Spec v5.2: Vol 4, Part E HCI: 7.8.12 LE Create Connection command <br>
132 * BT Core Spec v5.2: Vol 4, Part E HCI: 7.1.5 Create Connection command
133 * </p>
134 * <p>
135 * Depending on this device's addressType,
136 * either a BREDR (BDADDR_BREDR) or LE (BDADDR_LE_PUBLIC, BDADDR_LE_RANDOM) connection is attempted.<br>
137 * If unacceptable, {@link HCIStatusCode#UNACCEPTABLE_CONNECTION_PARAM} is being returned.
138 * </p>
139 * <p>
140 * The actual new connection handle will be delivered asynchronous and
141 * the connection event can be caught via {@link AdapterStatusListener#deviceConnected(BTDevice, long)},
142 * or if failed via {@link AdapterStatusListener#deviceDisconnected(BTDevice, HCIStatusCode, long)}.
143 * </p>
144 * <p>
145 * The device is tracked by the managing adapter.
146 * </p>
147 * <p>
148 * flagged as auto-connectable.
149 * </p>
150 * @return {@link HCIStatusCode#SUCCESS} if the command has been accepted, otherwise {@link HCIStatusCode} may disclose reason for rejection.
151 * @see #connectLE(short, short, short, short, short, short)
152 * @since 2.1.0 change API, i.e. return value from boolean to HCIStatusCode in favor of {@code jau.direct_bt}.
153 * @implNote {@code jau.direct_bt} does not throw a BTException on error, only a 'general' exception in case of fatality like NPE etc (FIXME: Remove throws)
154 */
156
157 /**
158 * Establish a HCI BDADDR_LE_PUBLIC or BDADDR_LE_RANDOM connection to this device.
159 * <p>
160 * BT Core Spec v5.2: Vol 4, Part E HCI: 7.8.12 LE Create Connection command
161 * </p>
162 * <p>
163 * If this device's {@link #getAddressType()} is not BDADDR_LE_PUBLIC or BDADDR_LE_RANDOM,
164 * {@link HCIStatusCode#UNACCEPTABLE_CONNECTION_PARAM} is being returned.
165 * </p>
166 * <p>
167 * The actual new connection handle will be delivered asynchronous and
168 * the connection event can be caught via {@link AdapterStatusListener#deviceConnected(BTDevice, long)},
169 * or if failed via {@link AdapterStatusListener#deviceDisconnected(BTDevice, HCIStatusCode, long)}.
170 * </p>
171 * <p>
172 * The device is tracked by the managing adapter.
173 * </p>
174 * <p>
175 * Default parameter are used if {@code -1} has been passed for any of the arguments.
176 * </p>
177 * <p>
178 * Default parameter values are chosen for using public address resolution
179 * and usual connection latency, interval etc.
180 * </p>
181 * <p>
182 * Set window to the same value as the interval, enables continuous scanning.
183 * </p>
184 *
185 * @param le_scan_interval in units of 0.625ms, default value 24 for 15ms; Value range [4 .. 0x4000] for [2.5ms .. 10.24s]
186 * @param le_scan_window in units of 0.625ms, default value 24 for 15ms; Value range [4 .. 0x4000] for [2.5ms .. 10.24s]. Shall be <= le_scan_interval
187 * @param conn_interval_min in units of 1.25ms, default value 8 for 10ms; Value range [6 .. 3200] for [7.5ms .. 4000ms]
188 * @param conn_interval_max in units of 1.25ms, default value 12 for 15ms; Value range [6 .. 3200] for [7.5ms .. 4000ms]
189 * @param conn_latency slave latency in units of connection events, default value 0; Value range [0 .. 0x01F3].
190 * @param supervision_timeout in units of 10ms, default value >= 10 x conn_interval_max, we use 500 ms minimum; Value range [0xA-0x0C80] for [100ms - 32s].
191 * @return {@link HCIStatusCode#SUCCESS} if the command has been accepted, otherwise {@link HCIStatusCode} may disclose reason for rejection.
192 * @see BTUtils#getHCIConnSupervisorTimeout(int, int, int, int)
193 * @see #connectDefault()
194 */
195 HCIStatusCode connectLE(final short le_scan_interval, final short le_scan_window,
196 final short conn_interval_min, final short conn_interval_max,
197 final short conn_latency, final short supervision_timeout);
198
199
200 /**
201 * Returns the available {@link SMPKeyMask.KeyType} {@link SMPKeyMask} for the responder (LL slave) or initiator (LL master).
202 * @param responder if true, queries the responder (LL slave) key, otherwise the initiator (LL master) key.
203 * @return {@link SMPKeyMask.KeyType} {@link SMPKeyMask} result
204 * @see {@link SMPPairingState#COMPLETED}
205 * @see {@link AdapterStatusListener#deviceReady(BTDevice, long)}
206 * @since 2.2.0
207 */
208 SMPKeyMask getAvailableSMPKeys(final boolean responder);
209
210 /**
211 * Copy all keys from the given SMPKeyBin into this BTDevice.
212 *
213 * Issue uploadKeys() to upload all SMP keys to the adapter
214 * before connecting to enable pre-pairing.
215 *
216 * If this instance isValid() and initiator or responder LTK available, i.e. hasLTKInit() or hasLTKResp(),
217 * the following procedure will be applied to the given BTDevice:
218 *
219 * - If BTSecurityLevel _is_ BTSecurityLevel::NONE
220 * + Setting security to ::BTSecurityLevel::NONE and SMPIOCapability::NO_INPUT_NO_OUTPUT via BTDevice::setConnSecurity()
221 * - else if BTSecurityLevel > BTSecurityLevel::NONE
222 * + Setting security to ::BTSecurityLevel::ENC_ONLY and SMPIOCapability::NO_INPUT_NO_OUTPUT via BTDevice::setConnSecurity()
223 * - Copying all keys from SMPKeyBin to this device, without uploading to the adapter
224 *
225 * BTSecurityLevel::ENC_ONLY is set to avoid a new SMP PairingMode negotiation,
226 * which is undesired as this instances' stored LTK shall be used for PairingMode::PRE_PAIRED.
227 *
228 * @param bin
229 * @return true if successful, false if already connected (and pairing is currently in progress)
230 * @see #setLongTermKey(SMPLongTermKey)
231 * @see #setIdentityResolvingKey(SMPIdentityResolvingKey)
232 * @see #setSignatureResolvingKey(SMPSignatureResolvingKey)
233 * @see #setLinkKey(SMPLinkKey)
234 * @see #uploadKeys()
235 * @since 2.4.0
236 */
237 boolean setSMPKeyBin(final SMPKeyBin bin);
238
239 /**
240 * Upload all set keys to the adapter for pre-pairing.
241 *
242 * Must be called before connecting to this device, otherwise {@link HCIStatusCode#CONNECTION_ALREADY_EXISTS} will be returned.
243 *
244 * @return {@link HCIStatusCode#SUCCESS} if successful, otherwise the appropriate error code.
245 * @see #isPrePaired()
246 * @see #setLongTermKey(SMPLongTermKey)
247 * @see #setIdentityResolvingKey(SMPIdentityResolvingKey)
248 * @see #setSignatureResolvingKey(SMPSignatureResolvingKey)
249 * @see #setLinkKey(SMPLinkKey)
250 * @see #setSMPKeyBin(SMPKeyBin)
251 * @since 2.4.0
252 */
254
255 /**
256 * Convenient combination of setSMPKeyBin() and uploadKeys()
257 * after validating given SMPKeyBin file and SMPKeyBin::getSecLevel() > req_min_level.
258 * @param bin the SMPKeyBin file
259 * @param req_min_level SMPKeyBin::getSecLevel() shall be greater or equal to this required minimum
260 * @return ::HCIStatusCode::SUCCESS if successful, otherwise the appropriate error code.
261 * @see #isPrePaired()
262 * @see #setSMPKeyBin(SMPKeyBin)
263 * @see #uploadKeys()
264 * @since 2.4.0
265 */
266 HCIStatusCode uploadKeys(final SMPKeyBin bin, final BTSecurityLevel req_min_level);
267
268 /**
269 * Convenient combination of SMPKeyBin::read(), setSMPKeyBin() and uploadKeys()
270 * after validating given SMPKeyBin file and SMPKeyBin::getSecLevel() > req_min_level.
271 * @param smp_key_bin_path director for the SMPKeyBin file, derived by this BTDevice
272 * @param req_min_level SMPKeyBin::getSecLevel() shall be greater or equal to this required minimum
273 * @return ::HCIStatusCode::SUCCESS if successful, otherwise the appropriate error code.
274 * @see #isPrePaired()
275 * @see SMPKeyBin#read(String, BTDevice, boolean)
276 * @see #setSMPKeyBin(SMPKeyBin)
277 * @see #uploadKeys(SMPKeyBin, BTSecurityLevel)
278 * @since 2.4.0
279 */
280 HCIStatusCode uploadKeys(final String smp_key_bin_path, final BTSecurityLevel req_min_level, final boolean verbose_);
281
282 /**
283 * Returns a copy of the long term key (LTK), valid after connection and SMP pairing has been completed.
284 * @param responder true will return the responder's LTK info (remote device, LL slave), otherwise the initiator's (the LL master).
285 * @return the resulting key. {@link SMPLongTermKey#enc_size} will be zero if invalid.
286 * @see {@link SMPPairingState#COMPLETED}
287 * @see {@link AdapterStatusListener#deviceReady(BTDevice, long)}
288 * @since 2.2.0
289 */
290 SMPLongTermKey getLongTermKey(final boolean responder);
291
292 /**
293 * Sets the Long Term Key (LTK) of this device for pre-paired encryption.
294 *
295 * Issue {@link #uploadKeys()} to upload all SMP keys to the adapter
296 * before connecting to enable pre-pairing.
297 *
298 * @param ltk the pre-paired encryption LTK
299 * @see #setSMPKeyBin(SMPKeyBin)
300 * @see #uploadKeys()
301 * @since 2.4.0
302 */
304
305 /**
306 * Returns a copy of the Identity Resolving Key (IRK), valid after connection and SMP pairing has been completed.
307 * @param responder true will return the responder's IRK info (remote device, LL slave), otherwise the initiator's (the LL master).
308 * @return the resulting key
309 * @see ::SMPPairingState::COMPLETED
310 * @see AdapterStatusListener::deviceReady()
311 * @since 2.4.0
312 */
314
315 /**
316 * Sets the Identity Resolving Key (IRK) of this device for pre-paired encryption.
317 *
318 * Issue {@link #uploadKeys()} to upload all SMP keys to the adapter
319 * before connecting to enable pre-pairing.
320 *
321 * @param irk the Identity Resolving Key (IRK)
322 * @see #setSMPKeyBin(SMPKeyBin)
323 * @see #uploadKeys()
324 * @since 2.4.0
325 */
327
328 /**
329 * Returns a copy of the Signature Resolving Key (CSRK), valid after connection and SMP pairing has been completed.
330 * @param responder true will return the responder's CSRK info (remote device, LL slave), otherwise the initiator's (the LL master).
331 * @return the resulting key
332 * @see {@link SMPPairingState#COMPLETED}
333 * @see {@link AdapterStatusListener#deviceReady(BTDevice, long)}
334 * @since 2.2.0
335 */
337
338 /**
339 * Sets the Signature Resolving Key (CSRK) of this device for pre-paired encryption.
340 *
341 * Issue {@link #uploadKeys()} to upload all SMP keys to the adapter
342 * before connecting to enable pre-pairing.
343 *
344 * @param csrk the Signature Resolving Key (CSRK)
345 * @see #setSMPKeyBin(SMPKeyBin)
346 * @see #uploadKeys()
347 * @since 2.4.0
348 */
350
351 /**
352 * Returns a copy of the Link Key (LK), valid after connection and SMP pairing has been completed.
353 * @param responder true will return the responder's LTK info (remote device, LL slave), otherwise the initiator's (the LL master).
354 * @return the resulting key
355 * @see {@link SMPPairingState#COMPLETED}
356 * @see {@link AdapterStatusListener#deviceReady(BTDevice, long)}
357 * @since 2.4.0
358 */
359 SMPLinkKey getLinkKey(final boolean responder);
360
361 /**
362 * Sets the Link Key (LK) of this device for pre-paired encryption.
363 *
364 * Issue {@link #uploadKeys()} to upload all SMP keys to the adapter
365 * before connecting to enable pre-pairing.
366 *
367 * @param lk the pre-paired encryption LK
368 * @see #setSMPKeyBin(SMPKeyBin)
369 * @see #uploadKeys()
370 * @since 2.4.0
371 */
372 void setLinkKey(final SMPLinkKey lk);
373
374 /**
375 * Unpair this device from the adapter while staying connected.
376 * <p>
377 * All keys will be cleared within the adapter and host implementation.<br>
378 * Should rarely being used by user.<br>
379 * Internally being used to re-start pairing if GATT connection fails
380 * in {@link PairingMode#PRE_PAIRED} mode.
381 * </p>
382 *
383 * Unpair is performed by directly for a consistent and stable security workflow:
384 * - when a {@link BTRole#Slave} {@link BTDevice} is discovered, see {@link AdapterStatusListener#deviceFound(BTDevice, long)}.
385 * - when a {@link BTRole#Slave} {@link BTDevice} is disconnected, see {@link AdapterStatusListener#deviceDisconnected(BTDevice, HCIStatusCode, short, long)}.
386 * - when a {@link BTRole#Master} {@link BTDevice} gets connected, see {@link AdapterStatusListener#deviceConnected(BTDevice, short, long)}.
387 *
388 * @return {@link HCIStatusCode#SUCCESS} or an appropriate error status.
389 * @since 2.1.0
390 * @see AdapterStatusListener#deviceFound(BTDevice, long)
391 * @see AdapterStatusListener#deviceDisconnected(BTDevice, HCIStatusCode, short, long)
392 * @see AdapterStatusListener#deviceConnected(BTDevice, short, long)
393 */
395
396 /**
397 * Return the {@link BTSecurityLevel}, determined when the connection is established.
398 * @since 2.1.0
399 * @see BTSecurityLevel
400 * @see SMPIOCapability
401 * @see #setConnSecurityLevel(BTSecurityLevel)
402 * @see #setConnIOCapability(SMPIOCapability, boolean)
403 * @see #getConnIOCapability()
404 * @see #setConnSecurity(BTSecurityLevel, SMPIOCapability, boolean)
405 * @see #setConnSecurityBest(BTSecurityLevel, SMPIOCapability)
406 */
408
409 /**
410 * Return the {@link SMPIOCapability} value, determined when the connection is established.
411 * @since 2.1.0
412 * @see BTSecurityLevel
413 * @see SMPIOCapability
414 * @see #setConnSecurityLevel(BTSecurityLevel)
415 * @see #getConnSecurityLevel()
416 * @see #setConnIOCapability(SMPIOCapability)
417 * @see #setConnSecurity(BTSecurityLevel, SMPIOCapability)
418 * @see #setConnSecurityBest(BTSecurityLevel, SMPIOCapability)
419 */
421
422 /**
423 * Sets the given {@link BTSecurityLevel} and {@link SMPIOCapability} used to connect to this device on the upcoming connection.
424 *
425 * Implementation using following pseudo-code, validating the user settings:
426 * <pre>
427 * if( BTSecurityLevel::UNSET < sec_level && SMPIOCapability::UNSET != io_cap ) {
428 * USING: sec_level, io_cap
429 * } else if( BTSecurityLevel::UNSET < sec_level ) {
430 * if( BTSecurityLevel::ENC_ONLY >= sec_level ) {
431 * USING: sec_level, SMPIOCapability::NO_INPUT_NO_OUTPUT
432 * } else {
433 * USING: sec_level, SMPIOCapability::UNSET
434 * }
435 * } else if( SMPIOCapability::UNSET != io_cap ) {
436 * USING BTSecurityLevel::UNSET, io_cap
437 * } else {
438 * USING BTSecurityLevel::UNSET, SMPIOCapability::UNSET
439 * }
440 * </pre>
441 * <p>
442 * Method returns false if this device has already being connected,
443 * or {@link #connectLE(short, short, short, short, short, short) connectLE} or {@link #connectDefault()} has been issued already.
444 * </p>
445 * <p>
446 * Method either changes both parameter for the upcoming connection or none at all.
447 * </p>
448 * @param sec_level {@link BTSecurityLevel} to be applied.
449 * @param io_cap {@link SMPIOCapability} to be applied.
450 * @since 2.1.0
451 * @see BTSecurityLevel
452 * @see SMPIOCapability
453 * @see #setConnSecurityLevel(BTSecurityLevel)
454 * @see #getConnSecurityLevel()
455 * @see #setConnIOCapability(SMPIOCapability)
456 * @see #getConnIOCapability()
457 * @see #setConnSecurityBest(BTSecurityLevel, SMPIOCapability)
458 */
459 boolean setConnSecurity(final BTSecurityLevel sec_level, final SMPIOCapability io_cap);
460
461 /**
462 * Set automatic security negotiation of {@link BTSecurityLevel} and {@link SMPIOCapability} pairing mode.
463 * <p>
464 * Disabled by default and if set to {@link SMPIOCapability#UNSET}
465 * </p>
466 * Implementation iterates through below setup from highest security to lowest,
467 * while performing a full connection attempt for each.
468 * <pre>
469 * BTSecurityLevel::ENC_AUTH_FIPS, iocap_auto*
470 * BTSecurityLevel::ENC_AUTH, iocap_auto*
471 * BTSecurityLevel::ENC_ONLY, SMPIOCapability::NO_INPUT_NO_OUTPUT
472 * BTSecurityLevel::NONE, SMPIOCapability::NO_INPUT_NO_OUTPUT
473 *
474 * (*): user SMPIOCapability choice of for authentication IO, skipped if ::SMPIOCapability::NO_INPUT_NO_OUTPUT
475 * </pre>
476 * <p>
477 * Implementation may perform multiple connection and disconnect actions
478 * until successful pairing or failure.
479 * </p>
480 * <p>
481 * Intermediate {@link AdapterStatusListener#deviceConnected(BTDevice, short, long) deviceConnected(..)} and
482 * {@link AdapterStatusListener#deviceDisconnected(BTDevice, HCIStatusCode, short, long) deviceDisconnected(..)}
483 * callbacks are not delivered while negotiating. This avoids any interference by the user application.
484 * </p>
485 * @param auth_io_cap user {@link SMPIOCapability} choice for negotiation
486 * @since 2.2.0
487 * @see #isConnSecurityAutoEnabled()
488 * @see BTSecurityLevel
489 * @see SMPIOCapability
490 */
491 boolean setConnSecurityAuto(final SMPIOCapability iocap_auto);
492
493 /**
494 * Returns true if automatic security negotiation has been enabled via {@link #setConnSecurityAuto(SMPIOCapability)},
495 * otherwise false.
496 * @since 2.2.0
497 * @see #setConnSecurityAuto(SMPIOCapability)
498 */
500
501 /**
502 * Method sets the given passkey entry, see {@link PairingMode#PASSKEY_ENTRY_ini}.
503 * <p>
504 * Call this method if the device shall be securely paired with {@link PairingMode#PASSKEY_ENTRY_ini},
505 * i.e. when notified via {@link AdapterStatusListener#devicePairingState(BTDevice, SMPPairingState, PairingMode, long) devicePairingState}
506 * in state {@link SMPPairingState#PASSKEY_EXPECTED}.
507 * </p>
508 *
509 * @param passkey used for {@link PairingMode#PASSKEY_ENTRY_ini} method.
510 * Will be encrypted before sending to counter-party.
511 *
512 * @return {@link HCIStatusCode#SUCCESS} if the command has been accepted, otherwise {@link HCIStatusCode} may disclose reason for rejection.
513 * @see PairingMode
514 * @see SMPPairingState
515 * @see AdapterStatusListener#devicePairingState(BTDevice, SMPPairingState, PairingMode, long)
516 * @see #setPairingPasskey(int)
517 * @see #setPairingNumericComparison(boolean)
518 * @see #getPairingMode()
519 * @see #getPairingState()
520 * @since 2.1.0
521 */
523
524 /**
525 * Method replies with a negative passkey response, i.e. rejection, see {@link PairingMode#PASSKEY_ENTRY_ini}.
526 * <p>
527 * You may call this method if the device shall be securely paired with {@link PairingMode#PASSKEY_ENTRY_ini},
528 * i.e. when notified via {@link AdapterStatusListener#devicePairingState(BTDevice, SMPPairingState, PairingMode, long) devicePairingState}
529 * in state {@link SMPPairingState#PASSKEY_EXPECTED}.
530 * </p>
531 * <p>
532 * Current experience exposed a roughly 3s immediate disconnect handshake with certain devices and/or Kernel BlueZ code.
533 *
534 * Hence using {@link #setPairingPasskey(int)} with {@code passkey = 0} is recommended, especially when utilizing
535 * automatic security negotiation via {@link #setConnSecurityAuto()}!
536 * </p>
537 *
538 * @return {@link HCIStatusCode#SUCCESS} if the command has been accepted, otherwise {@link HCIStatusCode} may disclose reason for rejection.
539 * @see PairingMode
540 * @see SMPPairingState
541 * @see AdapterStatusListener#devicePairingState(BTDevice, SMPPairingState, PairingMode, long)
542 * @see #setPairingPasskey(int)
543 * @see #setPairingNumericComparison(boolean)
544 * @see #getPairingMode()
545 * @see #getPairingState()
546 * @since 2.1.0
547 */
549
550 /**
551 * Method sets the numeric comparison result, see {@link PairingMode#NUMERIC_COMPARE_ini}.
552 * <p>
553 * Call this method if the device shall be securely paired with {@link PairingMode#NUMERIC_COMPARE_ini},
554 * i.e. when notified via {@link AdapterStatusListener#devicePairingState(BTDevice, SMPPairingState, PairingMode, long) devicePairingState}
555 * in state {@link SMPPairingState#NUMERIC_COMPARE_EXPECTED}.
556 * </p>
557 *
558 * @param equal used for {@link PairingMode#NUMERIC_COMPARE_ini} method.
559 * Will be encrypted before sending to counter-party.
560 *
561 * @return {@link HCIStatusCode#SUCCESS} if the command has been accepted, otherwise {@link HCIStatusCode} may disclose reason for rejection.
562 * @see PairingMode
563 * @see SMPPairingState
564 * @see AdapterStatusListener#devicePairingState(BTDevice, SMPPairingState, PairingMode, long)
565 * @see #setPairingPasskey(int)
566 * @see #setPairingNumericComparison(boolean)
567 * @see #getPairingMode()
568 * @see #getPairingState()
569 * @since 2.1.0
570 */
572
573 /**
574 * Returns the current {@link PairingMode} used by the device.
575 * <p>
576 * If the device is not paired, the current mode is {@link PairingMode#NONE}.
577 * </p>
578 * <p>
579 * If the Pairing Feature Exchange is completed, i.e. {@link SMPPairingState#FEATURE_EXCHANGE_COMPLETED}
580 * as notified by
581 * {@link AdapterStatusListener#devicePairingState(BTDevice, SMPPairingState, PairingMode, long) devicePairingState}
582 * the current mode reflects the currently used {@link PairingMode}.
583 * </p>
584 * <p>
585 * In case the Pairing Feature Exchange is in progress, the current mode is {@link PairingMode#NEGOTIATING}.
586 * </p>
587 * @return current PairingMode.
588 * @see PairingMode
589 * @see SMPPairingState
590 * @see AdapterStatusListener#devicePairingState(BTDevice, SMPPairingState, PairingMode, long)
591 * @see #setPairingPasskey(int)
592 * @see #setPairingNumericComparison(boolean)
593 * @see #getPairingMode()
594 * @see #getPairingState()
595 * @since 2.1.0
596 */
598
599 /**
600 * Returns the current {@link SMPPairingState}.
601 * <p>
602 * If the device is not paired, the current state is {@link SMPPairingState#NONE}.
603 * </p>
604 * @see PairingMode
605 * @see SMPPairingState
606 * @see AdapterStatusListener#devicePairingState(BTDevice, SMPPairingState, PairingMode, long)
607 * @see #setPairingPasskey(int)
608 * @see #setPairingNumericComparison(boolean)
609 * @see #getPairingMode()
610 * @see #getPairingState()
611 * @since 2.1.0
612 */
614
615 /**
616 * Remove this device from the system (like an unpair).
617 * <p>
618 * Direct-BT: Disconnects this device via disconnect(..) if getConnected()==true
619 * and explicitly removes its shared references from the Adapter:
620 * connected-devices, discovered-devices and shared-devices.
621 * </p>
622 * <p>
623 * This method shall be issued to ensure no device reference will
624 * be leaked in a long lived adapter,
625 * as only its reference within connected-devices and discovered-devices are removed at disconnect.
626 * </p>
627 * <p>
628 * After calling this method, this instance is destroyed and shall not be used anymore!
629 * </p>
630 * <p>
631 * This method is automatically called @ destructor.
632 * </p>
633 * <p>
634 * This method is an atomic operation.
635 * </p>
636 * <p>
637 * An application using one thread per device and rapid connect, should either use disconnect() or remove(),
638 * but never issue remove() after disconnect() if the device is in use.
639 * </p>
640 * @return TRUE if the device has been removed
641 * @throws BTException
642 */
643 boolean remove() throws BTException;
644
645 /**
646 * Returns whether the device is valid, i.e. reference is valid
647 * but not necessarily {@link #getConnected() connected}.
648 * @return true if this device's references are valid and hasn't been {@link #remove()}'ed
649 * @see #remove()
650 * @since 2.2.0
651 */
652 boolean isValid();
653
654 /**
655 * Returns a complete list of shared BTGattService available on this device,
656 * initially retrieved via GATT discovery.
657 *
658 * In case of transmission error, zero services or no GATT GenericAccess,
659 * method will return zero services indicating an error.
660 * In this case, user can assume that the connection is or will be disconnected.
661 *
662 * Method is only functional on a remote BTDevice in {@link BTRole#Slave}, a GATT server,
663 * i.e. the local BTAdapter acting as a {@link BTRole#Master} GATT client.
664 *
665 * The HCI connectLE(..) or connectBREDR(..) must be performed first, see {@link #connectDefault()}.
666 *
667 * If this method has been called for the first time:
668 * - the client MTU exchange will be performed
669 * - a complete list of BTGattService inclusive their BTGattChar and BTGattDesc will be retrieved
670 * - the GATT GenericAccess is extracted from the services.
671 *
672 * @since 2.4.0
673 */
675
676 /**
677 * Find a {@link BTGattService} by its service_uuid.
678 *
679 * It will check objects of this connected device.
680 *
681 * It will not turn on discovery or connect to this remote device.
682 *
683 * @parameter service_uuid the UUID of the desired {@link BTGattService}
684 * @return The matching service or null if not found
685 * @since 2.4.0
686 * @see #findGattChar(String, String)
687 * @see #findGattChar(String)
688 */
689 BTGattService findGattService(String service_uuid);
690
691 /**
692 * Find a {@link BTGattChar} by its service_uuid and char_uuid.
693 *
694 * It will check objects of this connected device.
695 *
696 * It will not turn on discovery or connect to this remote device.
697 *
698 * @parameter service_uuid the UUID of the intermediate {@link BTGattService}
699 * @parameter char_uuid the UUID of the desired {@link BTGattChar}, within the intermediate {@link BTGattService}.
700 * @return The matching characteristic or null if not found
701 * @since 2.4.0
702 * @see #findGattChar(String)
703 * @see #findGattService(String)
704 */
705 BTGattChar findGattChar(String service_uuid, String char_uuid);
706
707 /**
708 * Find a {@link BTGattChar} by its char_uuid only.
709 *
710 * It will check objects of this connected device.
711 *
712 * It will not turn on discovery or connect to this remote device.
713 *
714 * This variation is less efficient than findGattChar() by service_uuid and char_uuid,
715 * since it has to traverse through all services.
716 *
717 * @parameter char_uuid the UUID of the desired {@link BTGattChar}, within the intermediate {@link BTGattService}.
718 * @return The matching characteristic or null if not found
719 * @since 2.4.0
720 * @see #findGattChar(String, String)
721 * @see #findGattService(String)
722 */
723 BTGattChar findGattChar(String char_uuid);
724
725 /**
726 * Send a notification event consisting out of the given `value` representing the given characteristic value handle
727 * to the connected BTRole::Master.
728 *
729 * This command is only valid if this BTGattHandler is in role GATTRole::Server.
730 *
731 * Implementation is not receiving any reply after sending out the indication and returns immediately.
732 *
733 * @param char_value_handle valid characteristic value handle, must be sourced from referenced DBGattServer
734 * @param value the octets to be send
735 * @return true if successful, otherwise false
736 */
737 boolean sendNotification(final short char_value_handle, final byte[] value);
738
739 /**
740 * Send an indication event consisting out of the given `value` representing the given characteristic value handle
741 * to the connected BTRole::Master.
742 *
743 * This command is only valid if this BTGattHandler is in role GATTRole::Server.
744 *
745 * Implementation awaits the indication reply after sending out the indication.
746 *
747 * @param char_value_handle valid characteristic value handle, must be sourced from referenced DBGattServer
748 * @param value the octets to be send
749 * @return true if successful, otherwise false
750 */
751 boolean sendIndication(final short char_value_handle, final byte[] value);
752
753 /**
754 * Issues a GATT ping to the device, validating whether it is still reachable.
755 * <p>
756 * This method could be periodically utilized to shorten the underlying OS disconnect period
757 * after turning the device off, which lies within 7-13s.
758 * </p>
759 * <p>
760 * In case the device is no more reachable, disconnect will be initiated due to the occurring IO error.
761 * </p>
762 * <p>
763 * GATT services must have been initialized via {@link #getServices()}, otherwise {@code false} is being returned.
764 * </p>
765 * @return {@code true} if successful or not implemented, otherwise false in case no GATT services exists or is not connected..
766 * @since 2.0.0
767 */
768 boolean pingGATT();
769
770 /**
771 * Returns the timestamp in monotonic milliseconds when this device instance has been created,
772 * either via its initial discovery or its initial direct connection.
773 *
774 * @see BTUtils#currentTimeMillis()
775 * @since 2.0.0
776 */
778
779 /**
780 * Returns the timestamp in monotonic milliseconds when this device instance has
781 * discovered or connected directly the last time.
782 *
783 * @see BTUtils#currentTimeMillis()
784 * @since 2.0.0
785 */
787
788 /**
789 * Returns the timestamp in monotonic milliseconds when this device instance underlying data
790 * has been updated the last time.
791 *
792 * @see BTUtils#currentTimeMillis()
793 * @since 2.0.0
794 */
796
797 /**
798 * If both types are of {@link BTDevice}, it compares their {@link BDAddressAndType}, see {@link #getAddressAndType()}.
799 * <p>
800 * {@inheritDoc}
801 * </p>
802 */
803 @Override
804 boolean equals(final Object obj);
805
806 /**
807 * Returns the devices' unique {@link EUI48} address and {@link BDAddressType} type tuple, might be its initially reported (resolvable) random address until pairing,
808 * i.e. {@link BDAddressType#BDADDR_LE_RANDOM} instead of {@link BDAddressType#BDADDR_LE_PUBLIC}.
809 * <p>
810 * After pairing or if the remote device uses a (static) public address,
811 * it is considered unique and {@link BDAddressType#BDADDR_LE_PUBLIC}.
812 * </p>
813 * @since 3.2.0
814 */
816
817 /**
818 * Returns the devices' visible BDAddressAndType, i.e. {@link BDAddressType#BDADDR_LE_RANDOM} or {@link BDAddressType#BDADDR_LE_PUBLIC}.
819 * <p>
820 * The devices' address as initially reported by the system might be a (resolvable) random address,
821 * i.e. {@link BDAddressType#BDADDR_LE_RANDOM} instead of {@link BDAddressType#BDADDR_LE_PUBLIC}.
822 * </p>
823 * @since 3.2.8
824 * @see #getAddressAndType()
825 */
827
828 /**
829 * Returns the remote device name.
830 *
831 * The name has been set by the advertised {@link EInfoReport} if available,
832 * otherwise by the GATT GenericAccess data post connection.
833 *
834 * @see #getEIR()
835 */
836 String getName();
837
838 /**
839 * Returns Received Signal Strength Indicator (RSSI)
840 * in dBm with ±6 dB accuracy of device as recognized at discovery and connect.
841 * <p>
842 * BT Core Spec v5.2: Vol 4, Part E HCI: 7.5.4 Read RSSI command
843 * </p>
844 * <p>
845 * Any positive RSSI value indicates how many dB the RSSI is above the upper limit,
846 * any negative value indicates how many dB the RSSI is below the lower limit.
847 * The value zero indicates that the RSSI is inside the Golden Receive Power Range.
848 * </p>
849 * <p>
850 * LE range [-127..20] with 0 inside the Golden Receive Power Range
851 * and 127 as "not available" value (core spec).
852 * </p>
853 * <pre>
854 * pathloss = Tx Power Level – RSSI
855 * </pre>
856 * @see #getTxPower()
857 */
858 short getRSSI();
859
860 /**
861 * Return the merged advertised {@link EInfoReport} for this remote device.
862 *
863 * The EInfoReport is updated by new scan-reports (update) and when disconnected (empty).
864 * @since 2.5.3
865 */
867
868 /**
869 * Return the latest advertised EInfoReport AD_IND variant for this remote device.
870 *
871 * The EInfoReport is replaced by new scan-reports only.
872 * @since 2.6.6
873 */
875
876 /**
877 * Return the latest advertised EInfoReport AD_SCAN_RSP for this remote device.
878 *
879 * The EInfoReport is replaced by new scan-reports only.
880 * @since 2.6.6
881 */
883
884 /** Returns the connected state of the device.
885 * @return The connected state of the device.
886 */
887 boolean getConnected();
888
889 /**
890 * Return the HCI connection handle to the LE or BREDR peer, zero if not connected.
891 * @since 2.1.0
892 */
894
895 /**
896 * Request and return LE_PHYs bit for the given connection.
897 * <pre>
898 * BT Core Spec v5.2: Vol 4, Part E, 7.8.47 LE Read PHY command
899 * </pre>
900 * @param resRx array for one resulting receiver LE_PHYs bit
901 * @param resTx array for one resulting transmitter LE_PHYs bit
902 * @return HCIStatusCode
903 * @see #getTxPhys()
904 * @see #getRxPhys()
905 * @see #getConnectedLE_PHY(LE_PHYs[], LE_PHYs[])
906 * @see #setConnectedLE_PHY(LE_PHYs, LE_PHYs)
907 * @see BTAdapter#setDefaultLE_PHY(LE_PHYs, LE_PHYs)
908 * @since 2.4.0
909 */
910 HCIStatusCode getConnectedLE_PHY(LE_PHYs[/*1*/] resRx, LE_PHYs[/*1*/] resTx);
911
912 /**
913 * Return the Tx LE_PHYs as notified via LE_PHY_UPDATE_COMPLETE
914 * or retrieved via {@link #getConnectedLE_PHY(LE_PHYs[], LE_PHYs[])}.
915 * @see #getTxPhys()
916 * @see #getRxPhys()
917 * @see #getConnectedLE_PHY(LE_PHYs[], LE_PHYs[])
918 * @see #setConnectedLE_PHY(LE_PHYs, LE_PHYs)
919 * @see BTAdapter#setDefaultLE_PHY(LE_PHYs, LE_PHYs)
920 * @since 2.4.0
921 */
923
924 /**
925 * Return the Rx LE_PHYs as notified via LE_PHY_UPDATE_COMPLETE
926 * or retrieved via {@link #getConnectedLE_PHY(LE_PHYs[], LE_PHYs[])}.
927 * @see #getTxPhys()
928 * @see #getRxPhys()
929 * @see #getConnectedLE_PHY(LE_PHYs[], LE_PHYs[])
930 * @see #setConnectedLE_PHY(LE_PHYs, LE_PHYs)
931 * @see BTAdapter#setDefaultLE_PHY(LE_PHYs, LE_PHYs)
932 * @since 2.4.0
933 */
935
936
937 /**
938 * Sets preference of used LE_PHYs for the given connection.
939 *
940 * BT Core Spec v5.2: Vol 4, Part E, 7.8.49 LE Set PHY command
941 *
942 * @param Tx transmitter LE_PHYs bit mask of preference if not set to zero {@link LE_PHYs#mask} (ignored).
943 * @param Rx receiver LE_PHYs bit mask of preference if not set to zero {@link LE_PHYs#mask} (ignored).
944 * @return
945 * @see #getTxPhys()
946 * @see #getRxPhys()
947 * @see #getConnectedLE_PHY(LE_PHYs[], LE_PHYs[])
948 * @see BTAdapter#setDefaultLE_PHY(LE_PHYs, LE_PHYs)
949 * @since 2.4.0
950 */
952
953 /** Returns the adapter on which this device was discovered or
954 * connected.
955 * @return The adapter.
956 */
958
959 /**
960 * Return the fixed {@link BTRole} of this remote {@link BTDevice}.
961 * @see @ref BTDeviceRoles
962 * @since 2.4.0
963 */
965
966 /**
967 * Return Tx Power Level in dBm with ±6 dB accuracy of device as recognized at discovery and connect.
968 * <p>
969 * Core Specification Supplement, Part A, Section 1.5.
970 * </p>
971 * <p>
972 * Range [-127..20] with 127 as "not available" value (core spec).
973 * </p>
974 * <pre>
975 * pathloss = Tx Power Level – RSSI
976 * </pre>
977 * @see #getRSSI()
978 */
979 short getTxPower();
980
981 /**
982 * Add the given {@link BTGattCharListener} to the listener list if not already present.
983 * <p>
984 * To enable the actual BLE notification and/or indication, one needs to call
985 * {@link BTGattChar#configNotificationIndication(boolean, boolean, boolean[])}
986 * or {@link BTGattChar#enableNotificationOrIndication(boolean[])}.
987 * </p>
988 * @param listener A {@link BTGattCharListener} instance, listening to all {@link BTGattChar} events of this device
989 * @return true if the given listener is not element of the list and has been newly added, otherwise false.
990 * @see BTGattChar#configNotificationIndication(boolean, boolean, boolean[])
991 * @see BTGattChar#enableNotificationOrIndication(boolean[])
992 * @since 2.0.0
993 */
994 boolean addCharListener(final BTGattCharListener listener);
995
996 /**
997 * Please use {@link BTGattChar#addCharListener(BTGattCharListener)} for clarity.
998 */
999 boolean addCharListener(final BTGattCharListener listener, final BTGattChar associatedCharacteristic);
1000
1001 /**
1002 * Remove the given {@link BTGattCharListener} from the listener list.
1003 * <p>
1004 * If the {@link BTDevice}'s BTGattHandler is null, i.e. not connected, {@code false} is being returned.
1005 * </p>
1006 * @param listener A {@link BTGattCharListener} instance
1007 * @return true if the given listener is an element of the list and has been removed, otherwise false.
1008 * @since 2.0.0
1009 */
1011
1012 /**
1013 * Remove all {@link BTGattCharListener} from the list, which are associated to the given {@link BTGattChar}.
1014 * <p>
1015 * Implementation tests all listener's {@link BTGattCharListener#getAssociatedChar()}
1016 * to match with the given associated characteristic.
1017 * </p>
1018 * @param associatedCharacteristic the match criteria to remove any BTGattCharListener from the list
1019 * @return number of removed listener.
1020 * @since 2.0.0
1021 */
1022 int removeAllAssociatedCharListener(final BTGattChar associatedCharacteristic);
1023
1024 /**
1025 * Remove all {@link BTGattCharListener} from the list.
1026 * @return number of removed listener.
1027 * @since 2.0.0
1028 */
1030
1031 @Override
1032 String toString();
1033}
BTAdapter status listener for remote BTDevice discovery events: Added, updated and removed; as well a...
Unique Bluetooth EUI48 address and BDAddressType tuple.
BTGattChar event listener for notification and indication events.
Collection of 'Extended Advertising Data' (EAD), 'Advertising Data' (AD) or 'Extended Inquiry Respons...
LE Transport PHY bit values (bitmask)
Definition: LE_PHYs.java:36
SMP Identity Resolving Key, used for platform agnostic persistence.
Storage for SMP keys including required connection parameter per local adapter and remote device.
Definition: SMPKeyBin.java:75
SMP Key Type for Distribution, indicates keys distributed in the Transport Specific Key Distribution ...
Definition: SMPKeyMask.java:44
Local SMP Link Key, used for platform agnostic persistence, mapping to platform specific link keys fo...
Definition: SMPLinkKey.java:42
SMP Long Term Key, used for platform agnostic persistence.
SMP Signature Resolving Key, used for platform agnostic persistence.
Bluetooth roles from the perspective of the link layer (connection initiator).
Definition: BTRole.java:36
Bluetooth Security Level.
BT Core Spec v5.2: Vol 1, Part F Controller Error Codes: 1.3 List of Error Codes.
Bluetooth secure pairing mode.
SMP IO Capability value.
SMP Pairing Process state definition.
BTAdapter represents one local Bluetooth Controller.
Definition: BTAdapter.java:48
BTDevice represents one remote Bluetooth device.
Definition: BTDevice.java:47
HCIStatusCode setPairingNumericComparison(final boolean equal)
Method sets the numeric comparison result, see PairingMode#NUMERIC_COMPARE_ini.
BTAdapter getAdapter()
Returns the adapter on which this device was discovered or connected.
boolean removeStatusListener(final AdapterStatusListener l)
Remove the given AdapterStatusListener from the list.
String getName()
Returns the remote device name.
BTSecurityLevel getConnSecurityLevel()
Return the BTSecurityLevel, determined when the connection is established.
BTRole getRole()
Return the fixed BTRole of this remote BTDevice.
BTGattService findGattService(String service_uuid)
Find a BTGattService by its service_uuid.
short getConnectionHandle()
Return the HCI connection handle to the LE or BREDR peer, zero if not connected.
boolean sendNotification(final short char_value_handle, final byte[] value)
Send a notification event consisting out of the given value representing the given characteristic val...
boolean isPrePaired()
Returns true if this device has completed SMP pairing or keys are set via uploadKeys()
EInfoReport getEIRInd()
Return the latest advertised EInfoReport AD_IND variant for this remote device.
HCIStatusCode uploadKeys()
Upload all set keys to the adapter for pre-pairing.
SMPLinkKey getLinkKey(final boolean responder)
Returns a copy of the Link Key (LK), valid after connection and SMP pairing has been completed.
int getResponderSMPPassKey()
Returns the responder SMP passkey, ranging from [0..999999].
boolean removeCharListener(final BTGattCharListener l)
Remove the given BTGattCharListener from the listener list.
boolean addCharListener(final BTGattCharListener listener)
Add the given BTGattCharListener to the listener list if not already present.
void setIdentityResolvingKey(final SMPIdentityResolvingKey irk)
Sets the Identity Resolving Key (IRK) of this device for pre-paired encryption.
EInfoReport getEIRScanRsp()
Return the latest advertised EInfoReport AD_SCAN_RSP for this remote device.
boolean setConnSecurityAuto(final SMPIOCapability iocap_auto)
Set automatic security negotiation of BTSecurityLevel and SMPIOCapability pairing mode.
long getLastUpdateTimestamp()
Returns the timestamp in monotonic milliseconds when this device instance underlying data has been up...
boolean setConnSecurity(final BTSecurityLevel sec_level, final SMPIOCapability io_cap)
Sets the given BTSecurityLevel and SMPIOCapability used to connect to this device on the upcoming con...
boolean sendIndication(final short char_value_handle, final byte[] value)
Send an indication event consisting out of the given value representing the given characteristic valu...
void setSignatureResolvingKey(final SMPSignatureResolvingKey csrk)
Sets the Signature Resolving Key (CSRK) of this device for pre-paired encryption.
boolean pingGATT()
Issues a GATT ping to the device, validating whether it is still reachable.
LE_PHYs getRxPhys()
Return the Rx LE_PHYs as notified via LE_PHY_UPDATE_COMPLETE or retrieved via getConnectedLE_PHY(LE_P...
HCIStatusCode unpair()
Unpair this device from the adapter while staying connected.
SMPIdentityResolvingKey getIdentityResolvingKey(final boolean responder)
Returns a copy of the Identity Resolving Key (IRK), valid after connection and SMP pairing has been c...
short getTxPower()
Return Tx Power Level in dBm with ±6 dB accuracy of device as recognized at discovery and connect.
HCIStatusCode connectDefault()
jau.direct_bt: Establish a default HCI connection to this device, using certain default parameter.
boolean remove()
Remove this device from the system (like an unpair).
List< BTGattService > getGattServices()
Returns a complete list of shared BTGattService available on this device, initially retrieved via GAT...
String getResponderSMPPassKeyString()
Returns getResponderSMPPassKey() as a canonical string, e.g.
boolean getConnected()
Returns the connected state of the device.
boolean equals(final Object obj)
If both types are of BTDevice, it compares their BDAddressAndType, see getAddressAndType().
SMPKeyMask getAvailableSMPKeys(final boolean responder)
Returns the available SMPKeyMask.KeyType SMPKeyMask for the responder (LL slave) or initiator (LL mas...
HCIStatusCode getConnectedLE_PHY(LE_PHYs[] resRx, LE_PHYs[] resTx)
Request and return LE_PHYs bit for the given connection.
boolean setSMPKeyBin(final SMPKeyBin bin)
Copy all keys from the given SMPKeyBin into this BTDevice.
SMPPairingState getPairingState()
Returns the current SMPPairingState.
SMPIOCapability getConnIOCapability()
Return the SMPIOCapability value, determined when the connection is established.
int removeAllCharListener()
Remove all BTGattCharListener from the list.
short getRSSI()
Returns Received Signal Strength Indicator (RSSI) in dBm with ±6 dB accuracy of device as recognized ...
EInfoReport getEIR()
Return the merged advertised EInfoReport for this remote device.
boolean isValid()
Returns whether the device is valid, i.e.
void setLinkKey(final SMPLinkKey lk)
Sets the Link Key (LK) of this device for pre-paired encryption.
long getLastDiscoveryTimestamp()
Returns the timestamp in monotonic milliseconds when this device instance has discovered or connected...
void setLongTermKey(final SMPLongTermKey ltk)
Sets the Long Term Key (LTK) of this device for pre-paired encryption.
HCIStatusCode connectLE(final short le_scan_interval, final short le_scan_window, final short conn_interval_min, final short conn_interval_max, final short conn_latency, final short supervision_timeout)
Establish a HCI BDADDR_LE_PUBLIC or BDADDR_LE_RANDOM connection to this device.
SMPSignatureResolvingKey getSignatureResolvingKey(final boolean responder)
Returns a copy of the Signature Resolving Key (CSRK), valid after connection and SMP pairing has been...
boolean isConnSecurityAutoEnabled()
Returns true if automatic security negotiation has been enabled via setConnSecurityAuto(SMPIOCapabili...
HCIStatusCode disconnect()
jau.direct_bt: Disconnect the LE or BREDR peer's GATT and HCI connection.
int removeAllAssociatedCharListener(final BTGattChar associatedCharacteristic)
Remove all BTGattCharListener from the list, which are associated to the given BTGattChar.
BTGattChar findGattChar(String service_uuid, String char_uuid)
Find a BTGattChar by its service_uuid and char_uuid.
boolean addStatusListener(final AdapterStatusListener listener)
Add the given AdapterStatusListener to the list if not already present, listening only for events mat...
HCIStatusCode setPairingPasskeyNegative()
Method replies with a negative passkey response, i.e.
HCIStatusCode setPairingPasskey(final int passkey)
Method sets the given passkey entry, see PairingMode#PASSKEY_ENTRY_ini.
long getCreationTimestamp()
Returns the timestamp in monotonic milliseconds when this device instance has been created,...
PairingMode getPairingMode()
Returns the current PairingMode used by the device.
BDAddressAndType getVisibleAddressAndType()
Returns the devices' visible BDAddressAndType, i.e.
BDAddressAndType getAddressAndType()
Returns the devices' unique EUI48 address and BDAddressType type tuple, might be its initially report...
HCIStatusCode setConnectedLE_PHY(final LE_PHYs Tx, final LE_PHYs Rx)
Sets preference of used LE_PHYs for the given connection.
SMPLongTermKey getLongTermKey(final boolean responder)
Returns a copy of the long term key (LTK), valid after connection and SMP pairing has been completed.
LE_PHYs getTxPhys()
Return the Tx LE_PHYs as notified via LE_PHY_UPDATE_COMPLETE or retrieved via getConnectedLE_PHY(LE_P...
Representing a Gatt Characteristic object from the GATT client perspective.
Definition: BTGattChar.java:49
Representing a Gatt Service object from the GATT client perspective.