Direct-BT  2.3.1
Direct-BT - Direct Bluetooth Programming.
DBTAdapter.cxx
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 
26 #include "jau_direct_bt_DBTAdapter.h"
27 
28 // #define VERBOSE_ON 1
29 #include <jau/debug.hpp>
30 
31 #include "helper_base.hpp"
32 #include "helper_dbt.hpp"
33 
34 #include "direct_bt/BTAdapter.hpp"
35 #include "direct_bt/BTManager.hpp"
36 
37 using namespace direct_bt;
38 
39 static const std::string _adapterSettingsClassName("org/direct_bt/AdapterSettings");
40 static const std::string _adapterSettingsClazzCtorArgs("(I)V");
41 static const std::string _eirDataTypeSetClassName("org/direct_bt/EIRDataTypeSet");
42 static const std::string _eirDataTypeSetClazzCtorArgs("(I)V");
43 static const std::string _hciStatusCodeClassName("org/direct_bt/HCIStatusCode");
44 static const std::string _hciStatusCodeClazzGetArgs("(B)Lorg/direct_bt/HCIStatusCode;");
45 static const std::string _scanTypeClassName("org/direct_bt/ScanType");
46 static const std::string _scanTypeClazzGetArgs("(B)Lorg/direct_bt/ScanType;");
47 static const std::string _pairingModeClassName("org/direct_bt/PairingMode");
48 static const std::string _pairingModeClazzGetArgs("(B)Lorg/direct_bt/PairingMode;");
49 static const std::string _pairingStateClassName("org/direct_bt/SMPPairingState");
50 static const std::string _pairingStateClazzGetArgs("(B)Lorg/direct_bt/SMPPairingState;");
51 static const std::string _deviceClazzCtorArgs("(JLjau/direct_bt/DBTAdapter;[BBJLjava/lang/String;)V");
52 
53 static const std::string _adapterSettingsChangedMethodArgs("(Lorg/direct_bt/BTAdapter;Lorg/direct_bt/AdapterSettings;Lorg/direct_bt/AdapterSettings;Lorg/direct_bt/AdapterSettings;J)V");
54 static const std::string _discoveringChangedMethodArgs("(Lorg/direct_bt/BTAdapter;Lorg/direct_bt/ScanType;Lorg/direct_bt/ScanType;ZZJ)V");
55 static const std::string _deviceFoundMethodArgs("(Lorg/direct_bt/BTDevice;J)Z");
56 static const std::string _deviceUpdatedMethodArgs("(Lorg/direct_bt/BTDevice;Lorg/direct_bt/EIRDataTypeSet;J)V");
57 static const std::string _deviceConnectedMethodArgs("(Lorg/direct_bt/BTDevice;SJ)V");
58 static const std::string _devicePairingStateMethodArgs("(Lorg/direct_bt/BTDevice;Lorg/direct_bt/SMPPairingState;Lorg/direct_bt/PairingMode;J)V");
59 static const std::string _deviceReadyMethodArgs("(Lorg/direct_bt/BTDevice;J)V");
60 static const std::string _deviceDisconnectedMethodArgs("(Lorg/direct_bt/BTDevice;Lorg/direct_bt/HCIStatusCode;SJ)V");
61 
63  private:
64  /**
65  public abstract class AdapterStatusListener {
66  private long nativeInstance;
67 
68  public void adapterSettingsChanged(final BluetoothAdapter adapter,
69  final AdapterSettings oldmask, final AdapterSettings newmask,
70  final AdapterSettings changedmask, final long timestamp) { }
71  public void discoveringChanged(final BluetoothAdapter adapter, final ScanType currentMeta, final ScanType changedType, final boolean changedEnabled,
72  final boolean keepAlive, final long timestamp) { }
73  public void deviceFound(final BluetoothDevice device, final long timestamp) { }
74  public void deviceUpdated(final BluetoothDevice device, final EIRDataTypeSet updateMask, final long timestamp) { }
75  public void deviceConnected(final BluetoothDevice device, final short handle, final long timestamp) { }
76  public void devicePairingState(final BluetoothDevice device, final SMPPairingState state, final PairingMode mode, final long timestamp) {}
77  public void deviceReady(final BluetoothDevice device, final long timestamp) {}
78  public void deviceDisconnected(final BluetoothDevice device, final HCIStatusCode reason, final short handle, final long timestamp) { }
79 
80  };
81  */
82  static std::atomic<int> iname_next;
83  int const iname;
84  BTDevice const * const deviceMatchRef;
85  jau::JavaGlobalObj listenerObjRef;
86 
87  std::shared_ptr<jau::JavaAnon> adapterObjRef;
88  JNIGlobalRef adapterSettingsClazzRef;
89  jmethodID adapterSettingsClazzCtor;
90  JNIGlobalRef eirDataTypeSetClazzRef;
91  jmethodID eirDataTypeSetClazzCtor;
92  JNIGlobalRef hciStatusCodeClazzRef;
93  jmethodID hciStatusCodeClazzGet;
94  JNIGlobalRef scanTypeClazzRef;
95  jmethodID scanTypeClazzGet;
96  JNIGlobalRef pairingModeClazzRef;
97  jmethodID pairingModeClazzGet;
98  JNIGlobalRef pairingStateClazzRef;
99  jmethodID pairingStateClazzGet;
100 
101  JNIGlobalRef deviceClazzRef;
102  jmethodID deviceClazzCtor;
103  jfieldID deviceClazzTSLastDiscoveryField;
104  jfieldID deviceClazzTSLastUpdateField;
105  jfieldID deviceClazzConnectionHandleField;
106  jmethodID mAdapterSettingsChanged = nullptr;
107  jmethodID mDiscoveringChanged = nullptr;
108  jmethodID mDeviceFound = nullptr;
109  jmethodID mDeviceUpdated = nullptr;
110  jmethodID mDeviceConnected= nullptr;
111  jmethodID mDevicePairingState= nullptr;
112  jmethodID mDeviceReady = nullptr;
113  jmethodID mDeviceDisconnected = nullptr;
114 
115  public:
116 
117  std::string toString() const override {
118  const std::string devMatchAddr = nullptr != deviceMatchRef ? deviceMatchRef->getAddressAndType().toString() : "nil";
119  return "JNIAdapterStatusListener[this "+jau::to_hexstring(this)+", iname "+std::to_string(iname)+", devMatchAddr "+devMatchAddr+"]";
120  }
121 
123  // listenerObjRef dtor will call notifyDelete and clears the nativeInstance handle
124  }
125 
126  JNIAdapterStatusListener(JNIEnv *env, BTAdapter *adapter,
127  jclass listenerClazz, jobject statusListenerObj, jmethodID statusListenerNotifyDeleted,
128  const BTDevice * _deviceMatchRef)
129  : iname(iname_next.fetch_add(1)), deviceMatchRef(_deviceMatchRef),
130  listenerObjRef(statusListenerObj, statusListenerNotifyDeleted)
131  {
132  adapterObjRef = adapter->getJavaObject();
133  jau::JavaGlobalObj::check(adapterObjRef, E_FILE_LINE);
134 
135  // adapterSettingsClazzRef, adapterSettingsClazzCtor
136  {
137  jclass adapterSettingsClazz = jau::search_class(env, _adapterSettingsClassName.c_str());
139  if( nullptr == adapterSettingsClazz ) {
140  throw jau::InternalError("BTDevice::java_class not found: "+_adapterSettingsClassName, E_FILE_LINE);
141  }
142  adapterSettingsClazzRef = JNIGlobalRef(adapterSettingsClazz);
143  env->DeleteLocalRef(adapterSettingsClazz);
144  }
145  adapterSettingsClazzCtor = jau::search_method(env, adapterSettingsClazzRef.getClass(), "<init>", _adapterSettingsClazzCtorArgs.c_str(), false);
147  if( nullptr == adapterSettingsClazzCtor ) {
148  throw jau::InternalError("AdapterSettings ctor not found: "+_adapterSettingsClassName+".<init>"+_adapterSettingsClazzCtorArgs, E_FILE_LINE);
149  }
150 
151  // eirDataTypeSetClazzRef, eirDataTypeSetClazzCtor
152  {
153  jclass eirDataTypeSetClazz = jau::search_class(env, _eirDataTypeSetClassName.c_str());
155  if( nullptr == eirDataTypeSetClazz ) {
156  throw jau::InternalError("BTDevice::java_class not found: "+_eirDataTypeSetClassName, E_FILE_LINE);
157  }
158  eirDataTypeSetClazzRef = JNIGlobalRef(eirDataTypeSetClazz);
159  env->DeleteLocalRef(eirDataTypeSetClazz);
160  }
161  eirDataTypeSetClazzCtor = jau::search_method(env, eirDataTypeSetClazzRef.getClass(), "<init>", _eirDataTypeSetClazzCtorArgs.c_str(), false);
163  if( nullptr == eirDataTypeSetClazzCtor ) {
164  throw jau::InternalError("EIRDataType ctor not found: "+_eirDataTypeSetClassName+".<init>"+_eirDataTypeSetClazzCtorArgs, E_FILE_LINE);
165  }
166 
167  // hciStatusCodeClazzRef, hciStatusCodeClazzGet
168  {
169  jclass hciErrorCodeClazz = jau::search_class(env, _hciStatusCodeClassName.c_str());
171  if( nullptr == hciErrorCodeClazz ) {
172  throw jau::InternalError("BTDevice::java_class not found: "+_hciStatusCodeClassName, E_FILE_LINE);
173  }
174  hciStatusCodeClazzRef = JNIGlobalRef(hciErrorCodeClazz);
175  env->DeleteLocalRef(hciErrorCodeClazz);
176  }
177  hciStatusCodeClazzGet = jau::search_method(env, hciStatusCodeClazzRef.getClass(), "get", _hciStatusCodeClazzGetArgs.c_str(), true);
179  if( nullptr == hciStatusCodeClazzGet ) {
180  throw jau::InternalError("Static method not found: "+_hciStatusCodeClassName+".get"+_hciStatusCodeClazzGetArgs, E_FILE_LINE);
181  }
182 
183  // scanTypeClazzRef, scanTypeClazzGet
184  {
185  jclass scanTypeClazz = jau::search_class(env, _scanTypeClassName.c_str());
187  if( nullptr == scanTypeClazz ) {
188  throw jau::InternalError("BTDevice::java_class not found: "+_scanTypeClassName, E_FILE_LINE);
189  }
190  scanTypeClazzRef = JNIGlobalRef(scanTypeClazz);
191  env->DeleteLocalRef(scanTypeClazz);
192  }
193  scanTypeClazzGet = jau::search_method(env, scanTypeClazzRef.getClass(), "get", _scanTypeClazzGetArgs.c_str(), true);
195  if( nullptr == scanTypeClazzGet ) {
196  throw jau::InternalError("Static method not found: "+_scanTypeClassName+".get"+_scanTypeClazzGetArgs, E_FILE_LINE);
197  }
198 
199  // pairingModeClazzRef, pairingModeClazzGet
200  {
201  jclass pairingModeClazz = jau::search_class(env, _pairingModeClassName.c_str());
203  if( nullptr == pairingModeClazz ) {
204  throw jau::InternalError("BTDevice::java_class not found: "+_pairingModeClassName, E_FILE_LINE);
205  }
206  pairingModeClazzRef = JNIGlobalRef(pairingModeClazz);
207  env->DeleteLocalRef(pairingModeClazz);
208  }
209  pairingModeClazzGet = jau::search_method(env, pairingModeClazzRef.getClass(), "get", _pairingModeClazzGetArgs.c_str(), true);
211  if( nullptr == pairingModeClazzGet ) {
212  throw jau::InternalError("Static method not found: "+_pairingModeClassName+".get"+_pairingModeClazzGetArgs, E_FILE_LINE);
213  }
214 
215  // pairingStateClazzRef, pairingStateClazzGet
216  {
217  jclass pairingStateClazz = jau::search_class(env, _pairingStateClassName.c_str());
219  if( nullptr == pairingStateClazz ) {
220  throw jau::InternalError("BTDevice::java_class not found: "+_pairingStateClassName, E_FILE_LINE);
221  }
222  pairingStateClazzRef = JNIGlobalRef(pairingStateClazz);
223  env->DeleteLocalRef(pairingStateClazz);
224  }
225  pairingStateClazzGet = jau::search_method(env, pairingStateClazzRef.getClass(), "get", _pairingStateClazzGetArgs.c_str(), true);
227  if( nullptr == pairingStateClazzGet ) {
228  throw jau::InternalError("Static method not found: "+_pairingStateClassName+".get"+_pairingStateClazzGetArgs, E_FILE_LINE);
229  }
230 
231  // deviceClazzRef, deviceClazzCtor
232  {
233  jclass deviceClazz = jau::search_class(env, BTDevice::java_class().c_str());
235  if( nullptr == deviceClazz ) {
236  throw jau::InternalError("BTDevice::java_class not found: "+BTDevice::java_class(), E_FILE_LINE);
237  }
238  deviceClazzRef = JNIGlobalRef(deviceClazz);
239  env->DeleteLocalRef(deviceClazz);
240  }
241  deviceClazzCtor = jau::search_method(env, deviceClazzRef.getClass(), "<init>", _deviceClazzCtorArgs.c_str(), false);
243  if( nullptr == deviceClazzCtor ) {
244  throw jau::InternalError("BTDevice::java_class ctor not found: "+BTDevice::java_class()+".<init>"+_deviceClazzCtorArgs, E_FILE_LINE);
245  }
246  deviceClazzTSLastDiscoveryField = env->GetFieldID(deviceClazzRef.getClass(), "ts_last_discovery", "J");
248  if( nullptr == deviceClazzTSLastDiscoveryField ) {
249  throw jau::InternalError("BTDevice::java_class field not found: "+BTDevice::java_class()+".ts_last_discovery", E_FILE_LINE);
250  }
251  deviceClazzTSLastUpdateField = env->GetFieldID(deviceClazzRef.getClass(), "ts_last_update", "J");
253  if( nullptr == deviceClazzTSLastUpdateField ) {
254  throw jau::InternalError("BTDevice::java_class field not found: "+BTDevice::java_class()+".ts_last_update", E_FILE_LINE);
255  }
256  deviceClazzConnectionHandleField = env->GetFieldID(deviceClazzRef.getClass(), "hciConnHandle", "S");
258  if( nullptr == deviceClazzConnectionHandleField ) {
259  throw jau::InternalError("BTDevice::java_class field not found: "+BTDevice::java_class()+".hciConnHandle", E_FILE_LINE);
260  }
261 
262  mAdapterSettingsChanged = jau::search_method(env, listenerClazz, "adapterSettingsChanged", _adapterSettingsChangedMethodArgs.c_str(), false);
264  if( nullptr == mAdapterSettingsChanged ) {
265  throw jau::InternalError("AdapterStatusListener has no adapterSettingsChanged"+_adapterSettingsChangedMethodArgs+" method, for "+adapter->toString(), E_FILE_LINE);
266  }
267  mDiscoveringChanged = jau::search_method(env, listenerClazz, "discoveringChanged", _discoveringChangedMethodArgs.c_str(), false);
269  if( nullptr == mDiscoveringChanged ) {
270  throw jau::InternalError("AdapterStatusListener has no discoveringChanged"+_discoveringChangedMethodArgs+" method, for "+adapter->toString(), E_FILE_LINE);
271  }
272  mDeviceFound = jau::search_method(env, listenerClazz, "deviceFound", _deviceFoundMethodArgs.c_str(), false);
274  if( nullptr == mDeviceFound ) {
275  throw jau::InternalError("AdapterStatusListener has no deviceFound"+_deviceFoundMethodArgs+" method, for "+adapter->toString(), E_FILE_LINE);
276  }
277  mDeviceUpdated = jau::search_method(env, listenerClazz, "deviceUpdated", _deviceUpdatedMethodArgs.c_str(), false);
279  if( nullptr == mDeviceUpdated ) {
280  throw jau::InternalError("AdapterStatusListener has no deviceUpdated"+_deviceUpdatedMethodArgs+" method, for "+adapter->toString(), E_FILE_LINE);
281  }
282  mDeviceConnected = jau::search_method(env, listenerClazz, "deviceConnected", _deviceConnectedMethodArgs.c_str(), false);
284  if( nullptr == mDeviceConnected ) {
285  throw jau::InternalError("AdapterStatusListener has no deviceConnected"+_deviceConnectedMethodArgs+" method, for "+adapter->toString(), E_FILE_LINE);
286  }
287  mDevicePairingState = jau::search_method(env, listenerClazz, "devicePairingState", _devicePairingStateMethodArgs.c_str(), false);
289  if( nullptr == mDevicePairingState ) {
290  throw jau::InternalError("AdapterStatusListener has no devicePairingState"+_devicePairingStateMethodArgs+" method, for "+adapter->toString(), E_FILE_LINE);
291  }
292  mDeviceReady = jau::search_method(env, listenerClazz, "deviceReady", _deviceReadyMethodArgs.c_str(), false);
294  if( nullptr == mDeviceReady ) {
295  throw jau::InternalError("AdapterStatusListener has no deviceReady"+_deviceReadyMethodArgs+" method, for "+adapter->toString(), E_FILE_LINE);
296  }
297  mDeviceDisconnected = jau::search_method(env, listenerClazz, "deviceDisconnected", _deviceDisconnectedMethodArgs.c_str(), false);
299  if( nullptr == mDeviceDisconnected ) {
300  throw jau::InternalError("AdapterStatusListener has no deviceDisconnected"+_deviceDisconnectedMethodArgs+" method, for "+adapter->toString(), E_FILE_LINE);
301  }
302  }
303 
304  bool matchDevice(const BTDevice & device) override {
305  if( nullptr == deviceMatchRef ) {
306  return true;
307  }
308  return device == *deviceMatchRef;
309  }
310 
311  void adapterSettingsChanged(BTAdapter &a, const AdapterSetting oldmask, const AdapterSetting newmask,
312  const AdapterSetting changedmask, const uint64_t timestamp) override {
313  JNIEnv *env = *jni_env;
314  (void)a;
315  jobject adapterSettingOld = env->NewObject(adapterSettingsClazzRef.getClass(), adapterSettingsClazzCtor, (jint)oldmask);
317  JNIGlobalRef::check(adapterSettingOld, E_FILE_LINE);
318 
319  jobject adapterSettingNew = env->NewObject(adapterSettingsClazzRef.getClass(), adapterSettingsClazzCtor, (jint)newmask);
321  JNIGlobalRef::check(adapterSettingNew, E_FILE_LINE);
322 
323  jobject adapterSettingChanged = env->NewObject(adapterSettingsClazzRef.getClass(), adapterSettingsClazzCtor, (jint)changedmask);
325  JNIGlobalRef::check(adapterSettingChanged, E_FILE_LINE);
326 
327  env->CallVoidMethod(listenerObjRef.getObject(), mAdapterSettingsChanged,
328  jau::JavaGlobalObj::GetObject(adapterObjRef), adapterSettingOld, adapterSettingNew, adapterSettingChanged, (jlong)timestamp);
330  env->DeleteLocalRef(adapterSettingOld);
331  env->DeleteLocalRef(adapterSettingNew);
332  env->DeleteLocalRef(adapterSettingChanged);
333  }
334 
335  void discoveringChanged(BTAdapter &a, const ScanType currentMeta, const ScanType changedType, const bool changedEnabled, const bool keepAlive, const uint64_t timestamp) override {
336  JNIEnv *env = *jni_env;
337  (void)a;
338 
339  jobject jcurrentMeta = env->CallStaticObjectMethod(scanTypeClazzRef.getClass(), scanTypeClazzGet, (jbyte)number(currentMeta));
341  JNIGlobalRef::check(jcurrentMeta, E_FILE_LINE);
342 
343  jobject jchangedType = env->CallStaticObjectMethod(scanTypeClazzRef.getClass(), scanTypeClazzGet, (jbyte)number(changedType));
345  JNIGlobalRef::check(jchangedType, E_FILE_LINE);
346 
347  env->CallVoidMethod(listenerObjRef.getObject(), mDiscoveringChanged, jau::JavaGlobalObj::GetObject(adapterObjRef),
348  jcurrentMeta, jchangedType, (jboolean)changedEnabled, (jboolean)keepAlive, (jlong)timestamp);
350  }
351 
352  private:
353 
354  jobject newJavaBTDevice(JNIEnv *env, std::shared_ptr<BTDevice> device, const uint64_t timestamp) {
355  // DBTDevice(final long nativeInstance, final DBTAdapter adptr, final byte byteAddress[/*6*/], final byte byteAddressType,
356  // final long ts_creation, final String name)
357  const EUI48 addr = device->getAddressAndType().address;
358  jbyteArray jaddr = env->NewByteArray(sizeof(addr));
359  env->SetByteArrayRegion(jaddr, 0, sizeof(addr), (const jbyte*)(addr.b));
361  const jstring name = jau::from_string_to_jstring(env, device->getName());
363  jobject tmp_jdevice = env->NewObject(deviceClazzRef.getClass(), deviceClazzCtor,
364  (jlong)device.get(), jau::JavaGlobalObj::GetObject(adapterObjRef),
365  jaddr, device->getAddressAndType().type, (jlong)timestamp, name);
367  JNIGlobalRef::check(tmp_jdevice, E_FILE_LINE);
368  std::shared_ptr<jau::JavaAnon> jDeviceRef1 = device->getJavaObject();
370  jobject jdevice = jau::JavaGlobalObj::GetObject(jDeviceRef1);
371  env->DeleteLocalRef(jaddr);
372  env->DeleteLocalRef(name);
373  env->DeleteLocalRef(tmp_jdevice);
374  return jdevice;
375  }
376 
377  public:
378 
379  bool deviceFound(std::shared_ptr<BTDevice> device, const uint64_t timestamp) override {
380  JNIEnv *env = *jni_env;
381  jobject jdevice;
382  std::shared_ptr<jau::JavaAnon> jDeviceRef0 = device->getJavaObject();
383  if( jau::JavaGlobalObj::isValid(jDeviceRef0) ) {
384  // Reuse Java instance
385  jdevice = jau::JavaGlobalObj::GetObject(jDeviceRef0);
386  } else {
387  jdevice = newJavaBTDevice(env, device, timestamp);
388  }
389  env->SetLongField(jdevice, deviceClazzTSLastDiscoveryField, (jlong)device->getLastDiscoveryTimestamp());
391  jboolean res = env->CallBooleanMethod(listenerObjRef.getObject(), mDeviceFound, jdevice, (jlong)timestamp);
393  return JNI_TRUE == res;
394  }
395 
396  void deviceUpdated(std::shared_ptr<BTDevice> device, const EIRDataType updateMask, const uint64_t timestamp) override {
397  std::shared_ptr<jau::JavaAnon> jDeviceRef = device->getJavaObject();
398  if( !jau::JavaGlobalObj::isValid(jDeviceRef) ) {
399  return; // java device has been pulled
400  }
401  JNIEnv *env = *jni_env;
402  env->SetLongField(jau::JavaGlobalObj::GetObject(jDeviceRef), deviceClazzTSLastUpdateField, (jlong)timestamp);
404 
405  jobject eirDataTypeSet = env->NewObject(eirDataTypeSetClazzRef.getClass(), eirDataTypeSetClazzCtor, (jint)updateMask);
407  JNIGlobalRef::check(eirDataTypeSet, E_FILE_LINE);
408 
409  env->CallVoidMethod(listenerObjRef.getObject(), mDeviceUpdated, jau::JavaGlobalObj::GetObject(jDeviceRef), eirDataTypeSet, (jlong)timestamp);
411  env->DeleteLocalRef(eirDataTypeSet);
412  }
413 
414  void deviceConnected(std::shared_ptr<BTDevice> device, const uint16_t handle, const uint64_t timestamp) override {
415  JNIEnv *env = *jni_env;
416 
417  jobject jdevice;
418  std::shared_ptr<jau::JavaAnon> jDeviceRef0 = device->getJavaObject();
419  if( jau::JavaGlobalObj::isValid(jDeviceRef0) ) {
420  // Reuse Java instance
421  jdevice = jau::JavaGlobalObj::GetObject(jDeviceRef0);
422  } else {
423  jdevice = newJavaBTDevice(env, device, timestamp);
424  }
425  env->SetShortField(jdevice, deviceClazzConnectionHandleField, (jshort)handle);
427  env->SetLongField(jdevice, deviceClazzTSLastDiscoveryField, (jlong)device->getLastDiscoveryTimestamp());
429  env->SetLongField(jdevice, deviceClazzTSLastUpdateField, (jlong)timestamp);
431 
432  env->CallVoidMethod(listenerObjRef.getObject(), mDeviceConnected, jdevice, (jshort)handle, (jlong)timestamp);
434  }
435  void devicePairingState(std::shared_ptr<BTDevice> device, const SMPPairingState state, const PairingMode mode, const uint64_t timestamp) override {
436  std::shared_ptr<jau::JavaAnon> jDeviceRef = device->getJavaObject();
437  if( !jau::JavaGlobalObj::isValid(jDeviceRef) ) {
438  return; // java device has been pulled
439  }
440  JNIEnv *env = *jni_env;
441 
442  jobject jdevice = jau::JavaGlobalObj::GetObject(jDeviceRef);
443  env->SetLongField(jdevice, deviceClazzTSLastUpdateField, (jlong)timestamp);
445 
446  jobject jstate = env->CallStaticObjectMethod(pairingStateClazzRef.getClass(), pairingStateClazzGet, static_cast<uint8_t>(state));
449 
450  jobject jmode = env->CallStaticObjectMethod(pairingModeClazzRef.getClass(), pairingModeClazzGet, static_cast<uint8_t>(mode));
453 
454  env->CallVoidMethod(listenerObjRef.getObject(), mDevicePairingState, jdevice, jstate, jmode, (jlong)timestamp);
456  }
457  void deviceReady(std::shared_ptr<BTDevice> device, const uint64_t timestamp) override {
458  std::shared_ptr<jau::JavaAnon> jDeviceRef = device->getJavaObject();
459  if( !jau::JavaGlobalObj::isValid(jDeviceRef) ) {
460  return; // java device has been pulled
461  }
462  JNIEnv *env = *jni_env;
463 
464  jobject jdevice = jau::JavaGlobalObj::GetObject(jDeviceRef);
465  env->SetLongField(jdevice, deviceClazzTSLastUpdateField, (jlong)timestamp);
467 
468  env->CallVoidMethod(listenerObjRef.getObject(), mDeviceReady, jdevice, (jlong)timestamp);
470  }
471  void deviceDisconnected(std::shared_ptr<BTDevice> device, const HCIStatusCode reason, const uint16_t handle, const uint64_t timestamp) override {
472  std::shared_ptr<jau::JavaAnon> jDeviceRef = device->getJavaObject();
473  if( !jau::JavaGlobalObj::isValid(jDeviceRef) ) {
474  return; // java device has been pulled
475  }
476  JNIEnv *env = *jni_env;
477 
478  jobject jdevice = jau::JavaGlobalObj::GetObject(jDeviceRef);
479  env->SetLongField(jdevice, deviceClazzTSLastUpdateField, (jlong)timestamp);
481 
482  jobject hciErrorCode = env->CallStaticObjectMethod(hciStatusCodeClazzRef.getClass(), hciStatusCodeClazzGet, (jbyte)static_cast<uint8_t>(reason));
484  JNIGlobalRef::check(hciErrorCode, E_FILE_LINE);
485 
486  env->SetShortField(jdevice, deviceClazzConnectionHandleField, (jshort)0); // zero out, disconnected
488 
489  env->CallVoidMethod(listenerObjRef.getObject(), mDeviceDisconnected, jdevice, hciErrorCode, (jshort)handle, (jlong)timestamp);
491  }
492 };
493 std::atomic<int> JNIAdapterStatusListener::iname_next(0);
494 
495 jboolean Java_jau_direct_1bt_DBTAdapter_addStatusListenerImpl(JNIEnv *env, jobject obj, jobject jdeviceOwnerAndMatch, jobject statusListener)
496 {
497  try {
498  if( nullptr == statusListener ) {
499  throw jau::IllegalArgumentException("JNIAdapterStatusListener::addStatusListener: statusListener is null", E_FILE_LINE);
500  }
501  {
502  JNIAdapterStatusListener * pre = jau::getInstanceUnchecked<JNIAdapterStatusListener>(env, statusListener);
503  if( nullptr != pre ) {
504  throw jau::IllegalStateException("JNIAdapterStatusListener::addStatusListener: statusListener's nativeInstance not null, already in use", E_FILE_LINE);
505  return false;
506  }
507  }
508  BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
510 
511  BTDevice * deviceOwnerAndMatchRef = nullptr;
512  if( nullptr != jdeviceOwnerAndMatch ) {
513  deviceOwnerAndMatchRef = jau::getJavaUplinkObject<BTDevice>(env, jdeviceOwnerAndMatch);
514  jau::JavaGlobalObj::check(deviceOwnerAndMatchRef->getJavaObject(), E_FILE_LINE);
515  }
516 
517  jclass listenerClazz = jau::search_class(env, statusListener);
519  if( nullptr == listenerClazz ) {
520  throw jau::InternalError("AdapterStatusListener not found", E_FILE_LINE);
521  }
522  jmethodID mStatusListenerNotifyDeleted = jau::search_method(env, listenerClazz, "notifyDeleted", "()V", false);
524  if( nullptr == mStatusListenerNotifyDeleted ) {
525  throw jau::InternalError("AdapterStatusListener class has no notifyDeleted() method", E_FILE_LINE);
526  }
527 
528  std::shared_ptr<AdapterStatusListener> l =
529  std::shared_ptr<AdapterStatusListener>( new JNIAdapterStatusListener(env, adapter,
530  listenerClazz, statusListener, mStatusListenerNotifyDeleted, deviceOwnerAndMatchRef) );
531 
532  env->DeleteLocalRef(listenerClazz);
533 
534  jau::setInstance(env, statusListener, l.get());
535  bool addRes;
536  if( nullptr != deviceOwnerAndMatchRef ) {
537  addRes = adapter->addStatusListener( *deviceOwnerAndMatchRef, l );
538  } else {
539  addRes = adapter->addStatusListener( l );
540  }
541  if( addRes ) {
542  return JNI_TRUE;
543  }
544  jau::clearInstance(env, statusListener);
545  ERR_PRINT("JNIAdapterStatusListener::addStatusListener: FAILED: %s", l->toString().c_str());
546  } catch(...) {
547  jau::clearInstance(env, statusListener);
549  }
550  return JNI_FALSE;
551 }
552 
553 jboolean Java_jau_direct_1bt_DBTAdapter_removeStatusListenerImpl(JNIEnv *env, jobject obj, jobject statusListener)
554 {
555  try {
556  if( nullptr == statusListener ) {
557  throw jau::IllegalArgumentException("statusListener is null", E_FILE_LINE);
558  }
559  JNIAdapterStatusListener * pre = jau::getInstanceUnchecked<JNIAdapterStatusListener>(env, statusListener);
560  if( nullptr == pre ) {
561  DBG_PRINT("JNIAdapterStatusListener::removeStatusListener: statusListener's nativeInstance is null, not in use");
562  return false;
563  }
564  jau::clearInstance(env, statusListener);
565 
566  BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
568 
569  if( ! adapter->removeStatusListener( pre ) ) {
570  WARN_PRINT("Failed to remove statusListener with nativeInstance: %p at %s", pre, adapter->toString().c_str());
571  return false;
572  }
573  {
574  JNIAdapterStatusListener * post = jau::getInstanceUnchecked<JNIAdapterStatusListener>(env, statusListener);
575  if( nullptr != post ) {
576  ERR_PRINT("JNIAdapterStatusListener::removeStatusListener: statusListener's nativeInstance not null post native removal");
577  return false;
578  }
579  }
580  return true;
581  } catch(...) {
583  }
584  return JNI_FALSE;
585 }
586 
588  try {
589  BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
591 
592  return adapter->removeAllStatusListener();
593  } catch(...) {
595  }
596  return 0;
597 }
598 
599 jboolean Java_jau_direct_1bt_DBTAdapter_isDeviceWhitelisted(JNIEnv *env, jobject obj, jbyteArray jaddress, jbyte jaddressType) {
600  try {
601  BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
603 
604  if( nullptr == jaddress ) {
605  throw jau::IllegalArgumentException("address null", E_FILE_LINE);
606  }
607  const size_t address_size = env->GetArrayLength(jaddress);
608  if( sizeof(EUI48) > address_size ) {
609  throw jau::IllegalArgumentException("address byte size "+std::to_string(address_size)+" < "+std::to_string(sizeof(SMPLongTermKeyInfo)), E_FILE_LINE);
610  }
611  JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release
612  uint8_t * address_ptr = criticalArray.get(jaddress, criticalArray.Mode::NO_UPDATE_AND_RELEASE);
613  if( NULL == address_ptr ) {
614  throw jau::InternalError("GetPrimitiveArrayCritical(address byte array) is null", E_FILE_LINE);
615  }
616  const EUI48& address = *reinterpret_cast<EUI48 *>(address_ptr);
617  const BDAddressAndType addressAndType(address, static_cast<BDAddressType>( jaddressType ));
618 
619  return adapter->isDeviceWhitelisted(addressAndType);
620  } catch(...) {
622  }
623  return JNI_FALSE;
624 }
626  jbyteArray jaddress, jbyte jaddressType, int jctype,
627  jshort min_interval, jshort max_interval,
628  jshort latency, jshort timeout) {
629  try {
630  BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
632 
633  if( nullptr == jaddress ) {
634  throw jau::IllegalArgumentException("address null", E_FILE_LINE);
635  }
636  const size_t address_size = env->GetArrayLength(jaddress);
637  if( sizeof(EUI48) > address_size ) {
638  throw jau::IllegalArgumentException("address byte size "+std::to_string(address_size)+" < "+std::to_string(sizeof(SMPLongTermKeyInfo)), E_FILE_LINE);
639  }
640  JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release
641  uint8_t * address_ptr = criticalArray.get(jaddress, criticalArray.Mode::NO_UPDATE_AND_RELEASE);
642  if( NULL == address_ptr ) {
643  throw jau::InternalError("GetPrimitiveArrayCritical(address byte array) is null", E_FILE_LINE);
644  }
645  const EUI48& address = *reinterpret_cast<EUI48 *>(address_ptr);
646 
647  const BDAddressAndType addressAndType(address, static_cast<BDAddressType>( jaddressType ));
648  const HCIWhitelistConnectType ctype = static_cast<HCIWhitelistConnectType>( jctype );
649  return adapter->addDeviceToWhitelist(addressAndType, ctype, (uint16_t)min_interval, (uint16_t)max_interval, (uint16_t)latency, (uint16_t)timeout);
650  } catch(...) {
652  }
653  return JNI_FALSE;
654 }
656  jbyteArray jaddress, jbyte jaddressType, int jctype) {
657  try {
658  BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
660 
661  if( nullptr == jaddress ) {
662  throw jau::IllegalArgumentException("address null", E_FILE_LINE);
663  }
664  const size_t address_size = env->GetArrayLength(jaddress);
665  if( sizeof(EUI48) > address_size ) {
666  throw jau::IllegalArgumentException("address byte size "+std::to_string(address_size)+" < "+std::to_string(sizeof(SMPLongTermKeyInfo)), E_FILE_LINE);
667  }
668  JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release
669  uint8_t * address_ptr = criticalArray.get(jaddress, criticalArray.Mode::NO_UPDATE_AND_RELEASE);
670  if( NULL == address_ptr ) {
671  throw jau::InternalError("GetPrimitiveArrayCritical(address byte array) is null", E_FILE_LINE);
672  }
673  const EUI48& address = *reinterpret_cast<EUI48 *>(address_ptr);
674 
675  const BDAddressAndType addressAndType(address, static_cast<BDAddressType>( jaddressType ));
676  const HCIWhitelistConnectType ctype = static_cast<HCIWhitelistConnectType>( jctype );
677  return adapter->addDeviceToWhitelist(addressAndType, ctype);
678  } catch(...) {
680  }
681  return JNI_FALSE;
682 }
683 jboolean Java_jau_direct_1bt_DBTAdapter_removeDeviceFromWhitelistImpl(JNIEnv *env, jobject obj, jbyteArray jaddress, jbyte jaddressType) {
684  try {
685  BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
687 
688  if( nullptr == jaddress ) {
689  throw jau::IllegalArgumentException("address null", E_FILE_LINE);
690  }
691  const size_t address_size = env->GetArrayLength(jaddress);
692  if( sizeof(EUI48) > address_size ) {
693  throw jau::IllegalArgumentException("address byte size "+std::to_string(address_size)+" < "+std::to_string(sizeof(SMPLongTermKeyInfo)), E_FILE_LINE);
694  }
695  JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release
696  uint8_t * address_ptr = criticalArray.get(jaddress, criticalArray.Mode::NO_UPDATE_AND_RELEASE);
697  if( NULL == address_ptr ) {
698  throw jau::InternalError("GetPrimitiveArrayCritical(address byte array) is null", E_FILE_LINE);
699  }
700  const EUI48& address = *reinterpret_cast<EUI48 *>(address_ptr);
701 
702  const BDAddressAndType addressAndType(address, static_cast<BDAddressType>( jaddressType ));
703  return adapter->removeDeviceFromWhitelist(addressAndType);
704  } catch(...) {
706  }
707  return JNI_FALSE;
708 }
709 
710 jstring Java_jau_direct_1bt_DBTAdapter_toStringImpl(JNIEnv *env, jobject obj) {
711  try {
712  BTAdapter *nativePtr = jau::getJavaUplinkObject<BTAdapter>(env, obj);
714  return jau::from_string_to_jstring(env, nativePtr->toString());
715  } catch(...) {
717  }
718  return nullptr;
719 }
720 
721 void Java_jau_direct_1bt_DBTAdapter_deleteImpl(JNIEnv *env, jobject obj, jlong nativeInstance)
722 {
723  (void)obj;
724  try {
725  BTAdapter *adapter = jau::castInstance<BTAdapter>(nativeInstance);
726  DBG_PRINT("Java_jau_direct_1bt_DBTAdapter_deleteImpl (close only) %s", adapter->toString().c_str());
727  adapter->close();
728  // No delete: BTAdapter instance owned by DBTManager
729  // However, adapter->close() cleans up most..
730  } catch(...) {
732  }
733 }
734 
735 jboolean Java_jau_direct_1bt_DBTAdapter_isPoweredImpl(JNIEnv *env, jobject obj)
736 {
737  try {
738  BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
739  return adapter->isPowered();
740  } catch(...) {
742  }
743  return JNI_FALSE;
744 }
745 
746 jboolean Java_jau_direct_1bt_DBTAdapter_isSuspendedImpl(JNIEnv *env, jobject obj)
747 {
748  try {
749  BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
750  return adapter->isSuspended();
751  } catch(...) {
753  }
754  return JNI_FALSE;
755 }
756 
757 jboolean Java_jau_direct_1bt_DBTAdapter_isValidImpl(JNIEnv *env, jobject obj)
758 {
759  try {
760  BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
761  return adapter->isValid();
762  } catch(...) {
764  }
765  return JNI_FALSE;
766 }
767 
768 jbyte Java_jau_direct_1bt_DBTAdapter_startDiscoveryImpl(JNIEnv *env, jobject obj, jboolean keepAlive, jboolean le_scan_active,
769  jshort le_scan_interval, jshort le_scan_window,
770  jbyte filter_policy)
771 {
772  try {
773  BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
774  return (jbyte) number( adapter->startDiscovery(keepAlive, le_scan_active, le_scan_interval, le_scan_window, filter_policy) );
775  } catch(...) {
777  }
778  return (jbyte) number(HCIStatusCode::INTERNAL_FAILURE);
779 }
780 
782 {
783  try {
784  BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
785  return (jbyte) number( adapter->stopDiscovery() );
786  } catch(...) {
788  }
789  return (jbyte) number(HCIStatusCode::INTERNAL_FAILURE);
790 }
791 
793 {
794  try {
795  BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
797  return convert_vector_sharedptr_to_jarraylist(env, array);
798  } catch(...) {
800  }
801  return nullptr;
802 }
803 
805 {
806  try {
807  BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
808  return adapter->removeDiscoveredDevices();
809  } catch(...) {
811  }
812  return 0;
813 }
814 
815 jboolean Java_jau_direct_1bt_DBTAdapter_removeDiscoveredDeviceImpl1(JNIEnv *env, jobject obj, jbyteArray jaddress, jbyte jaddressType)
816 {
817  try {
818  BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
820 
821  if( nullptr == jaddress ) {
822  throw jau::IllegalArgumentException("address null", E_FILE_LINE);
823  }
824  const size_t address_size = env->GetArrayLength(jaddress);
825  if( sizeof(EUI48) > address_size ) {
826  throw jau::IllegalArgumentException("address byte size "+std::to_string(address_size)+" < "+std::to_string(sizeof(SMPLongTermKeyInfo)), E_FILE_LINE);
827  }
828  JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release
829  uint8_t * address_ptr = criticalArray.get(jaddress, criticalArray.Mode::NO_UPDATE_AND_RELEASE);
830  if( NULL == address_ptr ) {
831  throw jau::InternalError("GetPrimitiveArrayCritical(address byte array) is null", E_FILE_LINE);
832  }
833  const EUI48& address = *reinterpret_cast<EUI48 *>(address_ptr);
834  const BDAddressAndType addressAndType(address, static_cast<BDAddressType>( jaddressType ));
835 
836  return adapter->removeDiscoveredDevice(addressAndType);
837  } catch(...) {
839  }
840  return JNI_FALSE;
841 }
842 
843 //
844 // misc
845 //
846 
847 jboolean Java_jau_direct_1bt_DBTAdapter_setPowered(JNIEnv *env, jobject obj, jboolean value) {
848  try {
849  BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
851  return adapter->setPowered(JNI_TRUE == value ? true : false) ? JNI_TRUE : JNI_FALSE;
852  } catch(...) {
854  }
855  return JNI_FALSE;
856 }
857 
858 jbyte Java_jau_direct_1bt_DBTAdapter_resetImpl(JNIEnv *env, jobject obj) {
859  try {
860  BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
862  HCIStatusCode res = adapter->reset();
863  return (jbyte) number(res);
864  } catch(...) {
866  }
867  return (jbyte) number(HCIStatusCode::INTERNAL_FAILURE);
868 }
869 
870 jstring Java_jau_direct_1bt_DBTAdapter_getAlias(JNIEnv *env, jobject obj) {
871  try {
872  BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
874  return jau::from_string_to_jstring(env, adapter->getLocalName().getName());
875  } catch(...) {
877  }
878  return nullptr;
879 }
880 
881 void Java_jau_direct_1bt_DBTAdapter_setAlias(JNIEnv *env, jobject obj, jstring jnewalias) {
882  try {
883  BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
885  std::string newalias = jau::from_jstring_to_string(env, jnewalias);
886  adapter->setLocalName(newalias, std::string());
887  } catch(...) {
889  }
890 }
891 
892 jboolean Java_jau_direct_1bt_DBTAdapter_setDiscoverable(JNIEnv *env, jobject obj, jboolean value) {
893  try {
894  BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
896  return adapter->setDiscoverable(JNI_TRUE == value ? true : false) ? JNI_TRUE : JNI_FALSE;
897  } catch(...) {
899  }
900  return JNI_FALSE;
901 }
902 
903 jobject Java_jau_direct_1bt_DBTAdapter_connectDeviceImpl(JNIEnv *env, jobject obj, jbyteArray jaddress, jbyte jaddressType) {
904  try {
905  BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
907 
908  if( nullptr == jaddress ) {
909  throw jau::IllegalArgumentException("address null", E_FILE_LINE);
910  }
911  const size_t address_size = env->GetArrayLength(jaddress);
912  if( sizeof(EUI48) > address_size ) {
913  throw jau::IllegalArgumentException("address byte size "+std::to_string(address_size)+" < "+std::to_string(sizeof(SMPLongTermKeyInfo)), E_FILE_LINE);
914  }
915  JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release
916  uint8_t * address_ptr = criticalArray.get(jaddress, criticalArray.Mode::NO_UPDATE_AND_RELEASE);
917  if( NULL == address_ptr ) {
918  throw jau::InternalError("GetPrimitiveArrayCritical(address byte array) is null", E_FILE_LINE);
919  }
920  const EUI48& address = *reinterpret_cast<EUI48 *>(address_ptr);
921 
922  const BDAddressType addressType = static_cast<BDAddressType>( jaddressType );
923  std::shared_ptr<BTDevice> device = adapter->findSharedDevice(address, addressType);
924  if( nullptr == device ) {
925  device = adapter->findDiscoveredDevice(address, addressType);
926  }
927  if( nullptr != device ) {
928  direct_bt::HCIHandler & hci = adapter->getHCI();
929  if( !hci.isOpen() ) {
930  throw BTException("Adapter's HCI closed "+adapter->toString(), E_FILE_LINE);
931  }
932  std::shared_ptr<jau::JavaAnon> jDeviceRef = device->getJavaObject();
934 
935  device->connectDefault();
936  return jau::JavaGlobalObj::GetObject(jDeviceRef);
937  }
938  } catch(...) {
940  }
941  return nullptr;
942 }
943 
944 jboolean Java_jau_direct_1bt_DBTAdapter_setPairable(JNIEnv *env, jobject obj, jboolean value) {
945  try {
946  BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
948  return adapter->setBondable(JNI_TRUE == value ? true : false) ? JNI_TRUE : JNI_FALSE;
949  } catch(...) {
951  }
952  return JNI_FALSE;
953 }
954 
956  try {
957  BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
959  adapter->printDeviceLists();
960  } catch(...) {
962  }
963 }
Java_jau_direct_1bt_DBTAdapter_addStatusListenerImpl
jboolean Java_jau_direct_1bt_DBTAdapter_addStatusListenerImpl(JNIEnv *env, jobject obj, jobject jdeviceOwnerAndMatch, jobject statusListener)
Definition: DBTAdapter.cxx:495
direct_bt::BTAdapter::stopDiscovery
HCIStatusCode stopDiscovery() noexcept
Closes the discovery session.
Definition: BTAdapter.cpp:756
Java_jau_direct_1bt_DBTAdapter_setPairable
jboolean Java_jau_direct_1bt_DBTAdapter_setPairable(JNIEnv *env, jobject obj, jboolean value)
Definition: DBTAdapter.cxx:944
direct_bt::BTDevice::connectDefault
HCIStatusCode connectDefault() noexcept
Establish a default HCI connection to this device, using certain default parameter.
Definition: BTDevice.cpp:532
direct_bt::AdapterSetting
AdapterSetting
Adapter Setting Bits.
Definition: BTTypes1.hpp:136
jau::from_jstring_to_string
std::string from_jstring_to_string(JNIEnv *env, jstring str)
direct_bt::BTAdapter::isDeviceWhitelisted
bool isDeviceWhitelisted(const BDAddressAndType &addressAndType) noexcept
Returns true, if the adapter's device is already whitelisted.
Definition: BTAdapter.cpp:518
direct_bt::BTAdapter::getHCI
HCIHandler & getHCI() noexcept
Returns a reference to the aggregated HCIHandler instance.
Definition: BTAdapter.hpp:575
_adapterSettingsClassName
static const std::string _adapterSettingsClassName("org/direct_bt/AdapterSettings")
jau::convert_vector_sharedptr_to_jarraylist
jobject convert_vector_sharedptr_to_jarraylist(JNIEnv *env, T &array)
Definition: helper_jni.hpp:339
_pairingStateClazzGetArgs
static const std::string _pairingStateClazzGetArgs("(B)Lorg/direct_bt/SMPPairingState;")
le_scan_interval
static const uint16_t le_scan_interval
Definition: dbt_scanner10.cpp:633
JNIAdapterStatusListener::toString
std::string toString() const override
Definition: DBTAdapter.cxx:117
direct_bt::EIRDataType
EIRDataType
Bit mask of 'Extended Inquiry Response' (EIR) data fields, indicating a set of related data.
Definition: BTTypes0.hpp:752
direct_bt::BTAdapter::reset
HCIStatusCode reset() noexcept
Reset the adapter.
Definition: BTAdapter.cpp:489
JNIAdapterStatusListener::JNIAdapterStatusListener
JNIAdapterStatusListener(JNIEnv *env, BTAdapter *adapter, jclass listenerClazz, jobject statusListenerObj, jmethodID statusListenerNotifyDeleted, const BTDevice *_deviceMatchRef)
Definition: DBTAdapter.cxx:126
_adapterSettingsChangedMethodArgs
static const std::string _adapterSettingsChangedMethodArgs("(Lorg/direct_bt/BTAdapter;Lorg/direct_bt/AdapterSettings;Lorg/direct_bt/AdapterSettings;Lorg/direct_bt/AdapterSettings;J)V")
jau::JavaGlobalObj::isValid
static bool isValid(const std::shared_ptr< JavaAnon > &shref) noexcept
Definition: helper_jni.hpp:154
BTManager.hpp
Java_jau_direct_1bt_DBTAdapter_removeDiscoveredDeviceImpl1
jboolean Java_jau_direct_1bt_DBTAdapter_removeDiscoveredDeviceImpl1(JNIEnv *env, jobject obj, jbyteArray jaddress, jbyte jaddressType)
Definition: DBTAdapter.cxx:815
jau::IllegalArgumentException
Definition: basic_types.hpp:111
direct_bt::BTAdapter::isSuspended
bool isSuspended() const noexcept
Returns whether the adapter is suspended, i.e.
Definition: BTAdapter.hpp:447
jau::from_string_to_jstring
jstring from_string_to_jstring(JNIEnv *env, const std::string &str)
direct_bt::BTAdapter::getLocalName
const NameAndShortName & getLocalName() const noexcept
Returns the local friendly name and short_name.
Definition: BTAdapter.hpp:528
helper_dbt.hpp
Java_jau_direct_1bt_DBTAdapter_getAlias
jstring Java_jau_direct_1bt_DBTAdapter_getAlias(JNIEnv *env, jobject obj)
Definition: DBTAdapter.cxx:870
helper_base.hpp
direct_bt
Definition: ATTPDUTypes.hpp:171
Java_jau_direct_1bt_DBTAdapter_printDeviceListsImpl
void Java_jau_direct_1bt_DBTAdapter_printDeviceListsImpl(JNIEnv *env, jobject obj)
Definition: DBTAdapter.cxx:955
_deviceFoundMethodArgs
static const std::string _deviceFoundMethodArgs("(Lorg/direct_bt/BTDevice;J)Z")
jau::InternalError
Definition: basic_types.hpp:93
direct_bt::AdapterStatusListener
BTAdapter status listener for BTDevice discovery events: Added, updated and removed; as well as for c...
Definition: BTAdapter.hpp:67
direct_bt::BTAdapter::removeDiscoveredDevices
int removeDiscoveredDevices() noexcept
Discards all discovered devices.
Definition: BTAdapter.cpp:877
direct_bt::HCIWhitelistConnectType
HCIWhitelistConnectType
HCI Whitelist connection type.
Definition: BTTypes0.hpp:415
Java_jau_direct_1bt_DBTAdapter_setAlias
void Java_jau_direct_1bt_DBTAdapter_setAlias(JNIEnv *env, jobject obj, jstring jnewalias)
Definition: DBTAdapter.cxx:881
JNIAdapterStatusListener::~JNIAdapterStatusListener
~JNIAdapterStatusListener() override
Definition: DBTAdapter.cxx:122
JNIGlobalRef
Definition: jni_mem.hpp:75
direct_bt::BTDevice::getLastDiscoveryTimestamp
uint64_t getLastDiscoveryTimestamp() const noexcept
Returns the timestamp in monotonic milliseconds when this device instance has discovered or connected...
Definition: BTDevice.hpp:260
_deviceConnectedMethodArgs
static const std::string _deviceConnectedMethodArgs("(Lorg/direct_bt/BTDevice;SJ)V")
direct_bt::BTAdapter::setBondable
bool setBondable(bool value) noexcept
Set the bondable (aka pairable) state of the adapter.
Definition: BTAdapter.cpp:357
direct_bt::BTAdapter::setPowered
bool setPowered(bool value) noexcept
Set the power state of the adapter.
Definition: BTAdapter.cpp:362
direct_bt::BDAddressAndType::toString
std::string toString() const noexcept
Definition: BTTypes0.cpp:333
direct_bt::BTAdapter::printDeviceLists
void printDeviceLists() noexcept
Print the internally maintained BTDevice lists to stderr:
Definition: BTAdapter.cpp:325
direct_bt::BTAdapter::close
void close() noexcept
Closes this instance, usually being called by destructor or when this adapter is being removed as rec...
Definition: BTAdapter.cpp:252
direct_bt::BTAdapter::getDiscoveredDevices
jau::darray< std::shared_ptr< BTDevice > > getDiscoveredDevices() const noexcept
Returns discovered devices from the last discovery.
Definition: BTAdapter.cpp:901
Java_jau_direct_1bt_DBTAdapter_removeStatusListenerImpl
jboolean Java_jau_direct_1bt_DBTAdapter_removeStatusListenerImpl(JNIEnv *env, jobject obj, jobject statusListener)
Definition: DBTAdapter.cxx:553
direct_bt::BTException
Definition: BTTypes0.hpp:43
JNIAdapterStatusListener::devicePairingState
void devicePairingState(std::shared_ptr< BTDevice > device, const SMPPairingState state, const PairingMode mode, const uint64_t timestamp) override
An already connected BTDevice's ::SMPPairingState has changed.
Definition: DBTAdapter.cxx:435
direct_bt::ScanType
ScanType
Meta ScanType as derived from BTMode, with defined value mask consisting of BDAddressType bits.
Definition: BTTypes0.hpp:294
jau::search_class
jclass search_class(JNIEnv *env, const char *clazz_name)
_discoveringChangedMethodArgs
static const std::string _discoveringChangedMethodArgs("(Lorg/direct_bt/BTAdapter;Lorg/direct_bt/ScanType;Lorg/direct_bt/ScanType;ZZJ)V")
direct_bt::BTAdapter::removeDiscoveredDevice
bool removeDiscoveredDevice(const BDAddressAndType &addressAndType) noexcept
Discards matching discovered devices.
Definition: BTAdapter.cpp:860
Java_jau_direct_1bt_DBTAdapter_resetImpl
jbyte Java_jau_direct_1bt_DBTAdapter_resetImpl(JNIEnv *env, jobject obj)
Definition: DBTAdapter.cxx:858
direct_bt::BTDevice::getAddressAndType
constexpr BDAddressAndType const & getAddressAndType() const noexcept
Returns the unique device EUI48 address and BDAddressType type.
Definition: BTDevice.hpp:278
direct_bt::HCIHandler
A thread safe singleton handler of the HCI control channel to one controller (BT adapter)
Definition: HCIHandler.hpp:171
jau::java_exception_check_and_throw
void java_exception_check_and_throw(JNIEnv *env, const char *file, int line)
Throws a C++ exception if a java exception occurred, otherwise do nothing.
jau::to_string
PRAGMA_DISABLE_WARNING_POP constexpr_cxx20 std::string to_string(const endian &v) noexcept
Return std::string representation of the given jau::endian.
Definition: byte_util.hpp:198
_deviceDisconnectedMethodArgs
static const std::string _deviceDisconnectedMethodArgs("(Lorg/direct_bt/BTDevice;Lorg/direct_bt/HCIStatusCode;SJ)V")
JNIAdapterStatusListener::deviceDisconnected
void deviceDisconnected(std::shared_ptr< BTDevice > device, const HCIStatusCode reason, const uint16_t handle, const uint64_t timestamp) override
BTDevice got disconnected.
Definition: DBTAdapter.cxx:471
_scanTypeClassName
static const std::string _scanTypeClassName("org/direct_bt/ScanType")
direct_bt::BTAdapter::isPowered
bool isPowered() const noexcept
Returns whether the adapter is valid, plugged in and powered.
Definition: BTAdapter.hpp:437
Java_jau_direct_1bt_DBTAdapter_isPoweredImpl
jboolean Java_jau_direct_1bt_DBTAdapter_isPoweredImpl(JNIEnv *env, jobject obj)
Definition: DBTAdapter.cxx:735
direct_bt::HCIStatusCode
HCIStatusCode
BT Core Spec v5.2: Vol 1, Part F Controller Error Codes: 1.3 List of Error Codes.
Definition: HCITypes.hpp:124
jni_env
thread_local JNIEnvContainer jni_env
direct_bt::BTAdapter::removeStatusListener
bool removeStatusListener(std::shared_ptr< AdapterStatusListener > l)
Remove the given listener from the list.
Definition: BTAdapter.cpp:585
direct_bt::BTAdapter::findSharedDevice
std::shared_ptr< BTDevice > findSharedDevice(const EUI48 &address, const BDAddressType addressType) noexcept
Returns shared BTDevice if found, otherwise nullptr.
Definition: BTAdapter.cpp:934
E_FILE_LINE
#define E_FILE_LINE
Definition: basic_types.hpp:64
JNIAdapterStatusListener::deviceConnected
void deviceConnected(std::shared_ptr< BTDevice > device, const uint16_t handle, const uint64_t timestamp) override
BTDevice got connected.
Definition: DBTAdapter.cxx:414
jau::darray
Implementation of a dynamic linear array storage, aka vector.
Definition: darray.hpp:102
jau::search_method
jmethodID search_method(JNIEnv *env, jclass clazz, const char *method_name, const char *prototype, bool is_static)
_eirDataTypeSetClazzCtorArgs
static const std::string _eirDataTypeSetClazzCtorArgs("(I)V")
Java_jau_direct_1bt_DBTAdapter_deleteImpl
void Java_jau_direct_1bt_DBTAdapter_deleteImpl(JNIEnv *env, jobject obj, jlong nativeInstance)
Definition: DBTAdapter.cxx:721
BTAdapter.hpp
_deviceReadyMethodArgs
static const std::string _deviceReadyMethodArgs("(Lorg/direct_bt/BTDevice;J)V")
le_scan_window
static const uint16_t le_scan_window
Definition: dbt_scanner10.cpp:634
direct_bt::BDAddressAndType::type
BDAddressType type
Definition: BTAddress.hpp:429
_pairingModeClassName
static const std::string _pairingModeClassName("org/direct_bt/PairingMode")
direct_bt::BTAdapter::toString
std::string toString() const noexcept override
Definition: BTAdapter.hpp:784
Java_jau_direct_1bt_DBTAdapter_removeAllStatusListener
jint Java_jau_direct_1bt_DBTAdapter_removeAllStatusListener(JNIEnv *env, jobject obj)
Definition: DBTAdapter.cxx:587
JNIAdapterStatusListener::deviceFound
bool deviceFound(std::shared_ptr< BTDevice > device, const uint64_t timestamp) override
A BTDevice has been newly discovered.
Definition: DBTAdapter.cxx:379
WARN_PRINT
#define WARN_PRINT(...)
Use for unconditional warning messages, prefix '[elapsed_time] Warning @ FILE:LINE: '.
Definition: debug.hpp:146
JNIGlobalRef::check
static void check(jobject object, const char *file, int line)
Definition: jni_mem.hpp:80
JNIAdapterStatusListener
Definition: DBTAdapter.cxx:62
jau::setInstance
void setInstance(JNIEnv *env, jobject obj, T *t)
Definition: helper_jni.hpp:286
direct_bt::number
constexpr uint8_t number(const BDAddressType rhs) noexcept
Definition: BTAddress.hpp:67
jau::JavaGlobalObj::check
static void check(const std::shared_ptr< JavaAnon > &shref, const char *file, int line)
Definition: helper_jni.hpp:142
direct_bt::BTAdapter::findDiscoveredDevice
std::shared_ptr< BTDevice > findDiscoveredDevice(const EUI48 &address, const BDAddressType addressType) noexcept
Returns shared BTDevice if found, otherwise nullptr.
Definition: BTAdapter.cpp:843
JNICriticalArray::get
T * get(U jarray_val, Mode mode_val=UPDATE_AND_RELEASE)
Acquired the primitive array.
Definition: jni_mem.hpp:177
direct_bt::PairingMode
PairingMode
Bluetooth secure pairing mode.
Definition: BTTypes0.hpp:261
jau::clearInstance
void clearInstance(JNIEnv *env, jobject obj)
Definition: helper_jni.hpp:295
jau::JavaGlobalObj::GetObject
static jobject GetObject(const std::shared_ptr< JavaAnon > &shref) noexcept
Definition: helper_jni.hpp:194
JNIAdapterStatusListener::deviceUpdated
void deviceUpdated(std::shared_ptr< BTDevice > device, const EIRDataType updateMask, const uint64_t timestamp) override
An already discovered BTDevice has been updated.
Definition: DBTAdapter.cxx:396
direct_bt::HCIStatusCode::INTERNAL_FAILURE
@ INTERNAL_FAILURE
direct_bt::BTAdapter::addStatusListener
bool addStatusListener(std::shared_ptr< AdapterStatusListener > l)
Add the given listener to the list if not already present.
Definition: BTAdapter.cpp:548
Java_jau_direct_1bt_DBTAdapter_getDiscoveredDevicesImpl
jobject Java_jau_direct_1bt_DBTAdapter_getDiscoveredDevicesImpl(JNIEnv *env, jobject obj)
Definition: DBTAdapter.cxx:792
Java_jau_direct_1bt_DBTAdapter_startDiscoveryImpl
jbyte Java_jau_direct_1bt_DBTAdapter_startDiscoveryImpl(JNIEnv *env, jobject obj, jboolean keepAlive, jboolean le_scan_active, jshort le_scan_interval, jshort le_scan_window, jbyte filter_policy)
Definition: DBTAdapter.cxx:768
le_scan_active
static bool le_scan_active
Definition: dbt_scanner10.cpp:632
Java_jau_direct_1bt_DBTAdapter_connectDeviceImpl
jobject Java_jau_direct_1bt_DBTAdapter_connectDeviceImpl(JNIEnv *env, jobject obj, jbyteArray jaddress, jbyte jaddressType)
Definition: DBTAdapter.cxx:903
JNICriticalArray
Definition: jni_mem.hpp:126
debug.hpp
Java_jau_direct_1bt_DBTAdapter_removeDeviceFromWhitelistImpl
jboolean Java_jau_direct_1bt_DBTAdapter_removeDeviceFromWhitelistImpl(JNIEnv *env, jobject obj, jbyteArray jaddress, jbyte jaddressType)
Definition: DBTAdapter.cxx:683
direct_bt::HCIHandler::isOpen
bool isOpen() const noexcept
Returns true if this mgmt instance is open, connected and hence valid, otherwise false.
Definition: HCIHandler.hpp:374
direct_bt::BTDevice::java_class
static std::string java_class() noexcept
Definition: BTDevice.hpp:238
_deviceUpdatedMethodArgs
static const std::string _deviceUpdatedMethodArgs("(Lorg/direct_bt/BTDevice;Lorg/direct_bt/EIRDataTypeSet;J)V")
rethrow_and_raise_java_exception
#define rethrow_and_raise_java_exception(E)
Re-throw current exception and raise respective java exception using any matching function above.
Definition: helper_base.hpp:55
direct_bt::BTAdapter::setLocalName
std::shared_ptr< NameAndShortName > setLocalName(const std::string &name, const std::string &short_name) noexcept
Sets the local friendly name.
Definition: BTAdapter.cpp:348
jau::JavaGlobalObj::getObject
jobject getObject() const noexcept
Definition: helper_jni.hpp:185
jau::JavaGlobalObj
Implementation for JavaAnon, by simply wrapping a JNIGlobalRef instance.
Definition: helper_jni.hpp:136
direct_bt::BTAdapter
BTAdapter represents one Bluetooth Controller.
Definition: BTAdapter.hpp:250
direct_bt::AdapterStatusListener::toString
virtual std::string toString() const =0
jau::IllegalStateException
Definition: basic_types.hpp:117
Java_jau_direct_1bt_DBTAdapter_isValidImpl
jboolean Java_jau_direct_1bt_DBTAdapter_isValidImpl(JNIEnv *env, jobject obj)
Definition: DBTAdapter.cxx:757
direct_bt::BDAddressType
BDAddressType
BT Core Spec v5.2: Vol 3, Part C Generic Access Profile (GAP): 15.1.1.1 Public Bluetooth address.
Definition: BTAddress.hpp:51
direct_bt::EUI48
A packed 48 bit EUI-48 identifier, formerly known as MAC-48 or simply network device MAC address (Med...
Definition: BTAddress.hpp:388
direct_bt::BDAddressAndType::address
EUI48 address
Definition: BTAddress.hpp:428
Java_jau_direct_1bt_DBTAdapter_addDeviceToWhitelistImpl1
jboolean Java_jau_direct_1bt_DBTAdapter_addDeviceToWhitelistImpl1(JNIEnv *env, jobject obj, jbyteArray jaddress, jbyte jaddressType, int jctype, jshort min_interval, jshort max_interval, jshort latency, jshort timeout)
Definition: DBTAdapter.cxx:625
jau::to_hexstring
std::string to_hexstring(value_type const &v) noexcept
Produce a lower-case hexadecimal string representation of the given pointer.
Definition: string_util.hpp:104
Java_jau_direct_1bt_DBTAdapter_toStringImpl
jstring Java_jau_direct_1bt_DBTAdapter_toStringImpl(JNIEnv *env, jobject obj)
Definition: DBTAdapter.cxx:710
JNIAdapterStatusListener::matchDevice
bool matchDevice(const BTDevice &device) override
Custom filter for all 'device*' notification methods, which will not be called if this method returns...
Definition: DBTAdapter.cxx:304
direct_bt::BTAdapter::isValid
bool isValid() const noexcept
Returns whether the adapter is valid, i.e.
Definition: BTAdapter.hpp:480
ERR_PRINT
#define ERR_PRINT(...)
Use for unconditional error messages, prefix '[elapsed_time] Error @ FILE:LINE: '.
Definition: debug.hpp:132
direct_bt::EUI48::b
uint8_t b[6]
Definition: BTAddress.hpp:388
direct_bt::BTAdapter::setDiscoverable
bool setDiscoverable(bool value) noexcept
Set the discoverable state of the adapter.
Definition: BTAdapter.cpp:352
Java_jau_direct_1bt_DBTAdapter_setDiscoverable
jboolean Java_jau_direct_1bt_DBTAdapter_setDiscoverable(JNIEnv *env, jobject obj, jboolean value)
Definition: DBTAdapter.cxx:892
Java_jau_direct_1bt_DBTAdapter_isDeviceWhitelisted
jboolean Java_jau_direct_1bt_DBTAdapter_isDeviceWhitelisted(JNIEnv *env, jobject obj, jbyteArray jaddress, jbyte jaddressType)
Definition: DBTAdapter.cxx:599
_pairingStateClassName
static const std::string _pairingStateClassName("org/direct_bt/SMPPairingState")
_deviceClazzCtorArgs
static const std::string _deviceClazzCtorArgs("(JLjau/direct_bt/DBTAdapter;[BBJLjava/lang/String;)V")
direct_bt::BTAdapter::addDeviceToWhitelist
bool addDeviceToWhitelist(const BDAddressAndType &addressAndType, const HCIWhitelistConnectType ctype, const uint16_t conn_interval_min=12, const uint16_t conn_interval_max=12, const uint16_t conn_latency=0, const uint16_t supervision_timeout=getHCIConnSupervisorTimeout(0, 15))
Add the given device to the adapter's autoconnect whitelist.
Definition: BTAdapter.cpp:522
JNIAdapterStatusListener::adapterSettingsChanged
void adapterSettingsChanged(BTAdapter &a, const AdapterSetting oldmask, const AdapterSetting newmask, const AdapterSetting changedmask, const uint64_t timestamp) override
BTAdapter setting(s) changed.
Definition: DBTAdapter.cxx:311
_scanTypeClazzGetArgs
static const std::string _scanTypeClazzGetArgs("(B)Lorg/direct_bt/ScanType;")
Java_jau_direct_1bt_DBTAdapter_removeDiscoveredDevicesImpl1
jint Java_jau_direct_1bt_DBTAdapter_removeDiscoveredDevicesImpl1(JNIEnv *env, jobject obj)
Definition: DBTAdapter.cxx:804
direct_bt::BTDevice::getName
std::string const getName() const noexcept
Definition: BTDevice.cpp:124
JNIAdapterStatusListener::deviceReady
void deviceReady(std::shared_ptr< BTDevice > device, const uint64_t timestamp) override
BTDevice is ready for user (GATT) processing, i.e.
Definition: DBTAdapter.cxx:457
_eirDataTypeSetClassName
static const std::string _eirDataTypeSetClassName("org/direct_bt/EIRDataTypeSet")
Java_jau_direct_1bt_DBTAdapter_addDeviceToWhitelistImpl2
jboolean Java_jau_direct_1bt_DBTAdapter_addDeviceToWhitelistImpl2(JNIEnv *env, jobject obj, jbyteArray jaddress, jbyte jaddressType, int jctype)
Definition: DBTAdapter.cxx:655
filter_policy
static const uint8_t filter_policy
Definition: dbt_scanner10.cpp:635
_hciStatusCodeClassName
static const std::string _hciStatusCodeClassName("org/direct_bt/HCIStatusCode")
JNIAdapterStatusListener::discoveringChanged
void discoveringChanged(BTAdapter &a, const ScanType currentMeta, const ScanType changedType, const bool changedEnabled, const bool keepAlive, const uint64_t timestamp) override
BTAdapter's discovery state has changed, i.e.
Definition: DBTAdapter.cxx:335
direct_bt::BTAdapter::startDiscovery
HCIStatusCode startDiscovery(const bool keepAlive=true, const bool le_scan_active=false, const uint16_t le_scan_interval=24, const uint16_t le_scan_window=24, const uint8_t filter_policy=0x00)
Starts a new discovery session.
Definition: BTAdapter.cpp:679
direct_bt::SMPPairingState
SMPPairingState
SMP Pairing Process state definition.
Definition: SMPTypes.hpp:101
JNIGlobalRef::getClass
jclass getClass() const noexcept
Definition: jni_mem.hpp:110
direct_bt::NameAndShortName::getName
std::string getName() const noexcept
Definition: BTTypes1.hpp:122
_pairingModeClazzGetArgs
static const std::string _pairingModeClazzGetArgs("(B)Lorg/direct_bt/PairingMode;")
direct_bt::BDAddressAndType
Unique Bluetooth EUI48 address and BDAddressType tuple.
Definition: BTAddress.hpp:417
_hciStatusCodeClazzGetArgs
static const std::string _hciStatusCodeClazzGetArgs("(B)Lorg/direct_bt/HCIStatusCode;")
direct_bt::BTDevice
Definition: BTDevice.hpp:57
Java_jau_direct_1bt_DBTAdapter_isSuspendedImpl
jboolean Java_jau_direct_1bt_DBTAdapter_isSuspendedImpl(JNIEnv *env, jobject obj)
Definition: DBTAdapter.cxx:746
Java_jau_direct_1bt_DBTAdapter_setPowered
jboolean Java_jau_direct_1bt_DBTAdapter_setPowered(JNIEnv *env, jobject obj, jboolean value)
Definition: DBTAdapter.cxx:847
_adapterSettingsClazzCtorArgs
static const std::string _adapterSettingsClazzCtorArgs("(I)V")
_devicePairingStateMethodArgs
static const std::string _devicePairingStateMethodArgs("(Lorg/direct_bt/BTDevice;Lorg/direct_bt/SMPPairingState;Lorg/direct_bt/PairingMode;J)V")
direct_bt::BTAdapter::removeDeviceFromWhitelist
bool removeDeviceFromWhitelist(const BDAddressAndType &addressAndType)
Remove the given device from the adapter's autoconnect whitelist.
Definition: BTAdapter.cpp:541
DBG_PRINT
#define DBG_PRINT(...)
Use for environment-variable environment::DEBUG conditional debug messages, prefix '[elapsed_time] De...
Definition: debug.hpp:78
Java_jau_direct_1bt_DBTAdapter_stopDiscoveryImpl
jbyte Java_jau_direct_1bt_DBTAdapter_stopDiscoveryImpl(JNIEnv *env, jobject obj)
Definition: DBTAdapter.cxx:781
direct_bt::SMPLongTermKeyInfo
SMP Long Term Key Info, used for platform agnostic persistence.
Definition: SMPTypes.hpp:522