26#include "org_direct_bt_AdapterStatusListener.h"
27#include "jau_direct_bt_DBTAdapter.h"
57static const std::string
_adapterSettingsChangedMethodArgs(
"(Lorg/direct_bt/BTAdapter;Lorg/direct_bt/AdapterSettings;Lorg/direct_bt/AdapterSettings;Lorg/direct_bt/AdapterSettings;J)V");
58static const std::string
_discoveringChangedMethodArgs(
"(Lorg/direct_bt/BTAdapter;Lorg/direct_bt/ScanType;Lorg/direct_bt/ScanType;ZLorg/direct_bt/DiscoveryPolicy;J)V");
84 static std::atomic<int> iname_next;
88 jmethodID adapterSettingsClazzCtor;
90 jmethodID eirDataTypeSetClazzCtor;
92 jmethodID hciStatusCodeClazzGet;
94 jmethodID scanTypeClazzGet;
96 jmethodID discoveryPolicyClazzGet;
98 jmethodID pairingModeClazzGet;
100 jmethodID pairingStateClazzGet;
103 jmethodID deviceClazzCtor;
104 jfieldID deviceClazzTSLastDiscoveryField;
105 jfieldID deviceClazzTSLastUpdateField;
106 jfieldID deviceClazzConnectionHandleField;
107 jmethodID mAdapterSettingsChanged =
nullptr;
108 jmethodID mDiscoveringChanged =
nullptr;
109 jmethodID mDeviceFound =
nullptr;
110 jmethodID mDeviceUpdated =
nullptr;
111 jmethodID mDeviceConnected=
nullptr;
112 jmethodID mDevicePairingState=
nullptr;
113 jmethodID mDeviceReady =
nullptr;
114 jmethodID mDeviceDisconnected =
nullptr;
126 : iname(iname_next.fetch_add(1))
128 jclass listenerClazz =
search_class(env, statusListenerObj);
133 adapterSettingsClazzRef =
JNIGlobalRef(adapterSettingsClazz);
134 env->DeleteLocalRef(adapterSettingsClazz);
141 eirDataTypeSetClazzRef =
JNIGlobalRef(eirDataTypeSetClazz);
142 env->DeleteLocalRef(eirDataTypeSetClazz);
149 hciStatusCodeClazzRef =
JNIGlobalRef(hciErrorCodeClazz);
150 env->DeleteLocalRef(hciErrorCodeClazz);
158 env->DeleteLocalRef(scanTypeClazz);
165 discoveryPolicyClazzRef =
JNIGlobalRef(discoveryPolicyClazz);
166 env->DeleteLocalRef(discoveryPolicyClazz);
174 env->DeleteLocalRef(pairingModeClazz);
182 env->DeleteLocalRef(pairingStateClazz);
188 jclass deviceClazz =
search_class(env, BTDevice::java_class().c_str());
190 env->DeleteLocalRef(deviceClazz);
194 deviceClazzTSLastDiscoveryField =
search_field(env, deviceClazzRef.
getClass(),
"ts_last_discovery",
"J",
false);
195 deviceClazzTSLastUpdateField =
search_field(env, deviceClazzRef.
getClass(),
"ts_last_update",
"J",
false);
196 deviceClazzConnectionHandleField =
search_field(env, deviceClazzRef.
getClass(),
"hciConnHandle",
"S",
false);
209 const AdapterSetting changedmask,
const uint64_t timestamp)
override {
218 jobject adapterSettingOld = env->NewObject(adapterSettingsClazzRef.
getClass(), adapterSettingsClazzCtor, (jint)oldmask);
220 JNIGlobalRef::check(adapterSettingOld,
E_FILE_LINE);
222 jobject adapterSettingNew = env->NewObject(adapterSettingsClazzRef.
getClass(), adapterSettingsClazzCtor, (jint)newmask);
224 JNIGlobalRef::check(adapterSettingNew,
E_FILE_LINE);
226 jobject adapterSettingChanged = env->NewObject(adapterSettingsClazzRef.
getClass(), adapterSettingsClazzCtor, (jint)changedmask);
228 JNIGlobalRef::check(adapterSettingChanged,
E_FILE_LINE);
230 env->CallVoidMethod(JavaGlobalObj::GetObject(asl_java), mAdapterSettingsChanged,
231 JavaGlobalObj::GetObject(adapter_java), adapterSettingOld, adapterSettingNew, adapterSettingChanged, (jlong)timestamp);
233 env->DeleteLocalRef(adapterSettingOld);
234 env->DeleteLocalRef(adapterSettingNew);
235 env->DeleteLocalRef(adapterSettingChanged);
247 jobject jcurrentMeta = env->CallStaticObjectMethod(scanTypeClazzRef.
getClass(), scanTypeClazzGet, (jbyte)
number(currentMeta));
251 jobject jchangedType = env->CallStaticObjectMethod(scanTypeClazzRef.
getClass(), scanTypeClazzGet, (jbyte)
number(changedType));
255 jobject jdiscoveryPolicy = env->CallStaticObjectMethod(discoveryPolicyClazzRef.
getClass(), discoveryPolicyClazzGet, (jbyte)
number(policy));
257 JNIGlobalRef::check(jdiscoveryPolicy,
E_FILE_LINE);
259 env->CallVoidMethod(JavaGlobalObj::GetObject(asl_java), mDiscoveringChanged,
260 JavaGlobalObj::GetObject(adapter_java),
261 jcurrentMeta, jchangedType, (jboolean)changedEnabled, jdiscoveryPolicy, (jlong)timestamp);
267 jobject newJavaBTDevice(JNIEnv *env,
const BTDeviceRef& device,
const uint64_t timestamp) {
270 JavaAnonRef adapter_java = device->getAdapter().getJavaObject();
273 const EUI48 & addr = device->getAddressAndType().address;
274 jbyteArray jaddr = env->NewByteArray(
sizeof(addr));
275 env->SetByteArrayRegion(jaddr, 0,
sizeof(addr), (
const jbyte*)(addr.
b));
280 jobject tmp_jdevice = env->NewObject(deviceClazzRef.
getClass(), deviceClazzCtor,
281 device_sref.release_to_jlong(), JavaGlobalObj::GetObject(adapter_java),
282 jaddr, device->getAddressAndType().type, (jlong)timestamp, name);
287 jobject jdevice = JavaGlobalObj::GetObject(jDeviceRef1);
288 env->DeleteLocalRef(jaddr);
289 env->DeleteLocalRef(name);
290 env->DeleteLocalRef(tmp_jdevice);
303 if( JavaGlobalObj::isValid(device_java) ) {
305 jdevice = JavaGlobalObj::GetObject(device_java);
307 jdevice = newJavaBTDevice(env, device, timestamp);
309 env->SetLongField(jdevice, deviceClazzTSLastDiscoveryField, (jlong)device->getLastDiscoveryTimestamp());
311 jboolean res = env->CallBooleanMethod(JavaGlobalObj::GetObject(asl_java), mDeviceFound, jdevice, (jlong)timestamp);
313 return JNI_TRUE == res;
322 if( !JavaGlobalObj::isValid(device_java) ) {
325 env->SetLongField(JavaGlobalObj::GetObject(device_java), deviceClazzTSLastUpdateField, (jlong)timestamp);
328 jobject eirDataTypeSet = env->NewObject(eirDataTypeSetClazzRef.
getClass(), eirDataTypeSetClazzCtor, (jint)updateMask);
332 env->CallVoidMethod(JavaGlobalObj::GetObject(asl_java), mDeviceUpdated, JavaGlobalObj::GetObject(device_java), eirDataTypeSet, (jlong)timestamp);
334 env->DeleteLocalRef(eirDataTypeSet);
344 if( JavaGlobalObj::isValid(device_java) ) {
346 jdevice = JavaGlobalObj::GetObject(device_java);
348 jdevice = newJavaBTDevice(env, device, timestamp);
350 env->SetShortField(jdevice, deviceClazzConnectionHandleField, (jshort)device->getConnectionHandle());
352 env->SetLongField(jdevice, deviceClazzTSLastDiscoveryField, (jlong)device->getLastDiscoveryTimestamp());
354 env->SetLongField(jdevice, deviceClazzTSLastUpdateField, (jlong)timestamp);
357 env->CallVoidMethod(JavaGlobalObj::GetObject(asl_java), mDeviceConnected, jdevice, (jboolean)discovered, (jlong)timestamp);
366 if( !JavaGlobalObj::isValid(device_java) ) {
370 jobject jdevice = JavaGlobalObj::GetObject(device_java);
371 env->SetLongField(jdevice, deviceClazzTSLastUpdateField, (jlong)timestamp);
374 jobject jstate = env->CallStaticObjectMethod(pairingStateClazzRef.
getClass(), pairingStateClazzGet,
static_cast<uint8_t
>(state));
378 jobject jmode = env->CallStaticObjectMethod(pairingModeClazzRef.
getClass(), pairingModeClazzGet,
static_cast<uint8_t
>(mode));
382 env->CallVoidMethod(JavaGlobalObj::GetObject(asl_java), mDevicePairingState, jdevice, jstate, jmode, (jlong)timestamp);
391 if( !JavaGlobalObj::isValid(device_java) ) {
395 jobject jdevice = JavaGlobalObj::GetObject(device_java);
396 env->SetLongField(jdevice, deviceClazzTSLastUpdateField, (jlong)timestamp);
399 env->CallVoidMethod(JavaGlobalObj::GetObject(asl_java), mDeviceReady, jdevice, (jlong)timestamp);
408 if( !JavaGlobalObj::isValid(device_java) ) {
412 jobject jdevice = JavaGlobalObj::GetObject(device_java);
413 env->SetLongField(jdevice, deviceClazzTSLastUpdateField, (jlong)timestamp);
416 jobject hciErrorCode = env->CallStaticObjectMethod(hciStatusCodeClazzRef.
getClass(), hciStatusCodeClazzGet, (jbyte)
static_cast<uint8_t
>(reason));
420 env->SetShortField(jdevice, deviceClazzConnectionHandleField, (jshort)0);
423 env->CallVoidMethod(JavaGlobalObj::GetObject(asl_java), mDeviceDisconnected, jdevice, hciErrorCode, (jshort)handle, (jlong)timestamp);
427std::atomic<int> JNIAdapterStatusListener::iname_next(0);
443 return (jlong) (intptr_t)
nullptr;
456 if(
nullptr != sref.
pointer() ) {
457 std::shared_ptr<JNIAdapterStatusListener>* sref_ptr = castInstance<JNIAdapterStatusListener>(nativeInstance);
470 if(
nullptr != adapter.
pointer() ) {
472 DBG_PRINT(
"Java_jau_direct_1bt_DBTAdapter_deleteImpl (w/ close) %s", adapter->
toString().c_str());
475 DBG_PRINT(
"Java_jau_direct_1bt_DBTAdapter_deleteImpl null reference");
477 std::shared_ptr<BTAdapter>* ref_ptr = castInstance<BTAdapter>(nativeInstance);
480 DBG_PRINT(
"Java_jau_direct_1bt_DBTAdapter_deleteImpl null reference store");
491 JavaAnonRef adapter_java = adapter->getJavaObject();
499 if( !deviceOwnerAndMatchRef.
is_null() ) {
500 JavaGlobalObj::check(deviceOwnerAndMatchRef->getJavaObject(),
E_FILE_LINE);
504 if( !deviceOwnerAndMatchRef.
is_null() ) {
507 addRes = adapter->addStatusListener( asl.
shared_ptr() );
523 JavaAnonRef adapter_java = adapter->getJavaObject();
530 if( ! adapter->removeStatusListener( asl.
shared_ptr() ) ) {
544 JavaAnonRef adapter_java = adapter->getJavaObject();
546 return (jint)adapter->removeAllStatusListener();
556 JavaAnonRef adapter_java = adapter->getJavaObject();
559 if(
nullptr == jaddress ) {
562 const size_t address_size = env->GetArrayLength(jaddress);
563 if(
sizeof(
EUI48) > address_size ) {
567 uint8_t * address_ptr = criticalArray.
get(jaddress, criticalArray.Mode::NO_UPDATE_AND_RELEASE);
568 if(
nullptr == address_ptr ) {
571 const EUI48& address = *
reinterpret_cast<EUI48 *
>(address_ptr);
574 return adapter->isDeviceWhitelisted(addressAndType);
581 jbyteArray jaddress, jbyte jaddressType,
int jctype,
582 jshort min_interval, jshort max_interval,
583 jshort latency, jshort timeout) {
586 JavaAnonRef adapter_java = adapter->getJavaObject();
589 if(
nullptr == jaddress ) {
592 const size_t address_size = env->GetArrayLength(jaddress);
593 if(
sizeof(
EUI48) > address_size ) {
597 uint8_t * address_ptr = criticalArray.
get(jaddress, criticalArray.Mode::NO_UPDATE_AND_RELEASE);
598 if(
nullptr == address_ptr ) {
601 const EUI48& address = *
reinterpret_cast<EUI48 *
>(address_ptr);
605 return adapter->addDeviceToWhitelist(addressAndType, ctype, (uint16_t)min_interval, (uint16_t)max_interval, (uint16_t)latency, (uint16_t)timeout);
612 jbyteArray jaddress, jbyte jaddressType,
int jctype) {
615 JavaAnonRef adapter_java = adapter->getJavaObject();
618 if(
nullptr == jaddress ) {
621 const size_t address_size = env->GetArrayLength(jaddress);
622 if(
sizeof(
EUI48) > address_size ) {
626 uint8_t * address_ptr = criticalArray.
get(jaddress, criticalArray.Mode::NO_UPDATE_AND_RELEASE);
627 if(
nullptr == address_ptr ) {
630 const EUI48& address = *
reinterpret_cast<EUI48 *
>(address_ptr);
634 return adapter->addDeviceToWhitelist(addressAndType, ctype);
643 JavaAnonRef adapter_java = adapter->getJavaObject();
646 if(
nullptr == jaddress ) {
649 const size_t address_size = env->GetArrayLength(jaddress);
650 if(
sizeof(
EUI48) > address_size ) {
654 uint8_t * address_ptr = criticalArray.
get(jaddress, criticalArray.Mode::NO_UPDATE_AND_RELEASE);
655 if(
nullptr == address_ptr ) {
658 const EUI48& address = *
reinterpret_cast<EUI48 *
>(address_ptr);
661 return adapter->removeDeviceFromWhitelist(addressAndType);
671 JavaAnonRef adapter_java = adapter->getJavaObject();
685 JavaAnonRef adapter_java = adapter->getJavaObject();
688 return (jint) adapter->getBTMajorVersion();
699 JavaAnonRef adapter_java = adapter->getJavaObject();
702 return adapter->isPowered();
713 JavaAnonRef adapter_java = adapter->getJavaObject();
716 return adapter->isSuspended();
727 JavaAnonRef adapter_java = adapter->getJavaObject();
730 return adapter->isValid();
741 JavaAnonRef adapter_java = adapter->getJavaObject();
744 return (jlong)
number( adapter->getLEFeatures() );
759 JavaAnonRef adapter_java = adapter->getJavaObject();
765 return (jbyte)
number( adapter->startDiscovery(gatt_server_ref.
shared_ptr(),
771 return (jbyte)
number(HCIStatusCode::INTERNAL_FAILURE);
778 JavaAnonRef adapter_java = adapter->getJavaObject();
781 return (jbyte)
number( adapter->stopDiscovery() );
785 return (jbyte)
number(HCIStatusCode::INTERNAL_FAILURE);
792 JavaAnonRef adapter_java = adapter->getJavaObject();
795 current = adapter->getCurrentDiscoveryPolicy();
799 return (jbyte)
number(current);
805 JavaAnonRef adapter_java = adapter->getJavaObject();
812 return adapter->removeDevicePausingDiscovery(*device) ? JNI_TRUE : JNI_FALSE;
823 JavaAnonRef adapter_java = adapter->getJavaObject();
826 return (jbyte)
number( adapter->getRole() );
830 return (jbyte)
number( BTRole::None );
837 JavaAnonRef adapter_java = adapter->getJavaObject();
840 return (jbyte)
number( adapter->getBTMode() );
844 return (jbyte)
number( BTMode::NONE );
851 JavaAnonRef adapter_java = adapter->getJavaObject();
866 JavaAnonRef adapter_java = adapter->getJavaObject();
869 return (jint) adapter->removeDiscoveredDevices();
880 JavaAnonRef adapter_java = adapter->getJavaObject();
883 if(
nullptr == jaddress ) {
886 const size_t address_size = env->GetArrayLength(jaddress);
887 if(
sizeof(
EUI48) > address_size ) {
891 uint8_t * address_ptr = criticalArray.
get(jaddress, criticalArray.Mode::NO_UPDATE_AND_RELEASE);
892 if(
nullptr == address_ptr ) {
895 const EUI48& address = *
reinterpret_cast<EUI48 *
>(address_ptr);
898 return adapter->removeDiscoveredDevice(addressAndType);
912 JavaAnonRef adapter_java = adapter->getJavaObject();
915 return adapter->setPowered(JNI_TRUE == power_on ?
true :
false) ? JNI_TRUE : JNI_FALSE;
925 JavaAnonRef adapter_java = adapter->getJavaObject();
928 HCIStatusCode res = adapter->setPrivacy(JNI_TRUE == enable ?
true :
false);
929 return (jbyte)
number(res);
933 return (jbyte)
number(HCIStatusCode::INTERNAL_FAILURE);
939 JavaAnonRef adapter_java = adapter->getJavaObject();
942 return adapter->getSecureConnectionsEnabled() ? JNI_TRUE : JNI_FALSE;
952 JavaAnonRef adapter_java = adapter->getJavaObject();
955 HCIStatusCode res = adapter->setSecureConnections(JNI_TRUE == enable ?
true :
false);
956 return (jbyte)
number(res);
960 return (jbyte)
number(HCIStatusCode::INTERNAL_FAILURE);
964 jshort conn_interval_min, jshort conn_interval_max,
965 jshort conn_latency, jshort supervision_timeout) {
968 JavaAnonRef adapter_java = adapter->getJavaObject();
971 HCIStatusCode res = adapter->setDefaultConnParam(
static_cast<uint16_t
>(conn_interval_min),
972 static_cast<uint16_t
>(conn_interval_max),
973 static_cast<uint16_t
>(conn_latency),
974 static_cast<uint16_t
>(supervision_timeout));
975 return (jbyte)
number(res);
979 return (jbyte)
number(HCIStatusCode::INTERNAL_FAILURE);
985 JavaAnonRef adapter_java = adapter->getJavaObject();
988 adapter->setServerConnSecurity(
to_BTSecurityLevel(
static_cast<uint8_t
>(jsec_level) ),
998 JavaAnonRef adapter_java = adapter->getJavaObject();
1002 adapter->setSMPKeyPath(path);
1011 JavaAnonRef adapter_java = adapter->getJavaObject();
1016 return (jbyte)
number(res);
1020 return (jbyte)
number(HCIStatusCode::INTERNAL_FAILURE);
1026 JavaAnonRef adapter_java = adapter->getJavaObject();
1029 return adapter->isInitialized();
1039 JavaAnonRef adapter_java = adapter->getJavaObject();
1043 return (jbyte)
number(res);
1047 return (jbyte)
number(HCIStatusCode::INTERNAL_FAILURE);
1051 jbyte jTx, jbyte jRx) {
1054 JavaAnonRef adapter_java = adapter->getJavaObject();
1060 return (jbyte)
number ( adapter->setDefaultLE_PHY(Tx, Rx) );
1064 return (jbyte)
number(HCIStatusCode::INTERNAL_FAILURE);
1070 JavaAnonRef adapter_java = adapter->getJavaObject();
1083 JavaAnonRef adapter_java = adapter->getJavaObject();
1096 JavaAnonRef adapter_java = adapter->getJavaObject();
1101 return (jbyte)
number( adapter->setName(name, short_name) );
1105 return (jbyte)
number(HCIStatusCode::INTERNAL_FAILURE);
1111 JavaAnonRef adapter_java = adapter->getJavaObject();
1114 if(
nullptr == jaddress ) {
1117 const size_t address_size = env->GetArrayLength(jaddress);
1118 if(
sizeof(
EUI48) > address_size ) {
1122 uint8_t * address_ptr = criticalArray.
get(jaddress, criticalArray.Mode::NO_UPDATE_AND_RELEASE);
1123 if(
nullptr == address_ptr ) {
1126 const EUI48& address = *
reinterpret_cast<EUI48 *
>(address_ptr);
1129 BTDeviceRef device = adapter->findSharedDevice(address, addressType);
1130 if(
nullptr == device ) {
1131 device = adapter->findDiscoveredDevice(address, addressType);
1133 if(
nullptr != device ) {
1141 device->connectDefault();
1142 return JavaGlobalObj::GetObject(jDeviceRef);
1153 JavaAnonRef adapter_java = adapter->getJavaObject();
1156 adapter->printDeviceLists();
1163 jobject jgattServerData,
1171 JavaAnonRef adapter_java = adapter->getJavaObject();
1182 return (jbyte)
number(res);
1186 return (jbyte)
number(HCIStatusCode::INTERNAL_FAILURE);
1190 jobject jgattServerData,
1195 JavaAnonRef adapter_java = adapter->getJavaObject();
1203 return (jbyte)
number(res);
1207 return (jbyte)
number(HCIStatusCode::INTERNAL_FAILURE);
1213 JavaAnonRef adapter_java = adapter->getJavaObject();
1217 return (jbyte)
number(res);
1221 return (jbyte)
number(HCIStatusCode::INTERNAL_FAILURE);
1227 JavaAnonRef adapter_java = adapter->getJavaObject();
1230 return adapter->isAdvertising() ? JNI_TRUE : JNI_FALSE;
jobject Java_jau_direct_1bt_DBTAdapter_connectDeviceImpl(JNIEnv *env, jobject obj, jbyteArray jaddress, jbyte jaddressType)
jbyte Java_jau_direct_1bt_DBTAdapter_resetImpl(JNIEnv *env, jobject obj)
jbyte Java_jau_direct_1bt_DBTAdapter_startDiscoveryImpl(JNIEnv *env, jobject obj, jobject jgattServerData, jbyte policy, jboolean le_scan_active, jshort le_scan_interval, jshort le_scan_window, jbyte filter_policy, jboolean filter_dup)
static const std::string _adapterSettingsChangedMethodArgs("(Lorg/direct_bt/BTAdapter;Lorg/direct_bt/AdapterSettings;Lorg/direct_bt/AdapterSettings;Lorg/direct_bt/AdapterSettings;J)V")
static const std::string _adapterSettingsClazzCtorArgs("(I)V")
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)
static const std::string _deviceDisconnectedMethodArgs("(Lorg/direct_bt/BTDevice;Lorg/direct_bt/HCIStatusCode;SJ)V")
static const std::string _adapterSettingsClassName("org/direct_bt/AdapterSettings")
jbyte Java_jau_direct_1bt_DBTAdapter_getBTModeImpl(JNIEnv *env, jobject obj)
static const std::string _discoveryPolicyClazzGetArgs("(B)Lorg/direct_bt/DiscoveryPolicy;")
static const std::string _hciStatusCodeClassName("org/direct_bt/HCIStatusCode")
jlong Java_org_direct_1bt_AdapterStatusListener_ctorImpl(JNIEnv *env, jobject obj)
jbyte Java_jau_direct_1bt_DBTAdapter_stopDiscoveryImpl(JNIEnv *env, jobject obj)
static const std::string _deviceFoundMethodArgs("(Lorg/direct_bt/BTDevice;J)Z")
jboolean Java_jau_direct_1bt_DBTAdapter_getSecureConnectionsEnabled(JNIEnv *env, jobject obj)
void Java_jau_direct_1bt_DBTAdapter_printDeviceListsImpl(JNIEnv *env, jobject obj)
jbyte Java_jau_direct_1bt_DBTAdapter_startAdvertising1Impl(JNIEnv *env, jobject obj, jobject jgattServerData, jobject jeir, jint jadv_mask, jint jscanrsp_mask, jshort adv_interval_min, jshort adv_interval_max, jbyte jadv_type, jbyte adv_chan_map, jbyte filter_policy)
jobject Java_jau_direct_1bt_DBTAdapter_getDiscoveredDevicesImpl(JNIEnv *env, jobject obj)
jboolean Java_jau_direct_1bt_DBTAdapter_isPoweredImpl(JNIEnv *env, jobject obj)
jbyte Java_jau_direct_1bt_DBTAdapter_setSecureConnectionsImpl(JNIEnv *env, jobject obj, jboolean enable)
jint Java_jau_direct_1bt_DBTAdapter_getBTMajorVersion(JNIEnv *env, jobject obj)
jboolean Java_jau_direct_1bt_DBTAdapter_isDeviceWhitelisted(JNIEnv *env, jobject obj, jbyteArray jaddress, jbyte jaddressType)
void Java_jau_direct_1bt_DBTAdapter_setServerConnSecurityImpl(JNIEnv *env, jobject obj, jbyte jsec_level, jbyte jio_cap)
void Java_org_direct_1bt_AdapterStatusListener_deleteImpl(JNIEnv *env, jobject obj, jlong nativeInstance)
static const std::string _deviceReadyMethodArgs("(Lorg/direct_bt/BTDevice;J)V")
static const std::string _hciStatusCodeClazzGetArgs("(B)Lorg/direct_bt/HCIStatusCode;")
static const std::string _deviceClazzCtorArgs("(JLjau/direct_bt/DBTAdapter;[BBJLjava/lang/String;)V")
jbyte Java_jau_direct_1bt_DBTAdapter_setNameImpl(JNIEnv *env, jobject obj, jstring jname, jstring jshort_name)
static const std::string _eirDataTypeSetClassName("org/direct_bt/EIRDataTypeSet")
jbyte Java_jau_direct_1bt_DBTAdapter_setDefaultConnParamImpl(JNIEnv *env, jobject obj, jshort conn_interval_min, jshort conn_interval_max, jshort conn_latency, jshort supervision_timeout)
jboolean Java_jau_direct_1bt_DBTAdapter_removeDeviceFromWhitelistImpl(JNIEnv *env, jobject obj, jbyteArray jaddress, jbyte jaddressType)
jboolean Java_jau_direct_1bt_DBTAdapter_isAdvertising(JNIEnv *env, jobject obj)
jboolean Java_jau_direct_1bt_DBTAdapter_isSuspendedImpl(JNIEnv *env, jobject obj)
jbyte Java_jau_direct_1bt_DBTAdapter_initializeImpl(JNIEnv *env, jobject obj, jbyte jbtMode, jboolean powerOn)
static const std::string _pairingStateClazzGetArgs("(B)Lorg/direct_bt/SMPPairingState;")
jboolean Java_jau_direct_1bt_DBTAdapter_removeDiscoveredDeviceImpl1(JNIEnv *env, jobject obj, jbyteArray jaddress, jbyte jaddressType)
jlong Java_jau_direct_1bt_DBTAdapter_getLEFeaturesImpl(JNIEnv *env, jobject obj)
jint Java_jau_direct_1bt_DBTAdapter_removeDiscoveredDevicesImpl1(JNIEnv *env, jobject obj)
static const std::string _pairingModeClazzGetArgs("(B)Lorg/direct_bt/PairingMode;")
jboolean Java_jau_direct_1bt_DBTAdapter_removeStatusListenerImpl(JNIEnv *env, jobject obj, jobject jstatusListener)
jboolean Java_jau_direct_1bt_DBTAdapter_addStatusListenerImpl(JNIEnv *env, jobject obj, jobject jdeviceOwnerAndMatch, jobject jstatusListener)
static const std::string _scanTypeClassName("org/direct_bt/ScanType")
static const std::string _discoveryPolicyClassName("org/direct_bt/DiscoveryPolicy")
jboolean Java_jau_direct_1bt_DBTAdapter_removeDevicePausingDiscovery(JNIEnv *env, jobject obj, jobject jdevice)
jboolean Java_jau_direct_1bt_DBTAdapter_isValidImpl(JNIEnv *env, jobject obj)
static const std::string _eirDataTypeSetClazzCtorArgs("(I)V")
jboolean Java_jau_direct_1bt_DBTAdapter_setPowered(JNIEnv *env, jobject obj, jboolean power_on)
static const std::string _scanTypeClazzGetArgs("(B)Lorg/direct_bt/ScanType;")
jboolean Java_jau_direct_1bt_DBTAdapter_isInitialized(JNIEnv *env, jobject obj)
jbyte Java_jau_direct_1bt_DBTAdapter_startAdvertising2Impl(JNIEnv *env, jobject obj, jobject jgattServerData, jshort adv_interval_min, jshort adv_interval_max, jbyte jadv_type, jbyte adv_chan_map, jbyte filter_policy)
jstring Java_jau_direct_1bt_DBTAdapter_getNameImpl(JNIEnv *env, jobject obj)
void Java_jau_direct_1bt_DBTAdapter_deleteImpl(JNIEnv *env, jobject obj, jlong nativeInstance)
jbyte Java_jau_direct_1bt_DBTAdapter_setDefaultLE_1PHYImpl(JNIEnv *env, jobject obj, jbyte jTx, jbyte jRx)
jstring Java_jau_direct_1bt_DBTAdapter_getShortNameImpl(JNIEnv *env, jobject obj)
jboolean Java_jau_direct_1bt_DBTAdapter_addDeviceToWhitelistImpl2(JNIEnv *env, jobject obj, jbyteArray jaddress, jbyte jaddressType, int jctype)
jint Java_jau_direct_1bt_DBTAdapter_removeAllStatusListenerImpl(JNIEnv *env, jobject obj)
static const std::string _pairingStateClassName("org/direct_bt/SMPPairingState")
jstring Java_jau_direct_1bt_DBTAdapter_toStringImpl(JNIEnv *env, jobject obj)
jbyte Java_jau_direct_1bt_DBTAdapter_setPrivacyImpl(JNIEnv *env, jobject obj, jboolean enable)
static const std::string _deviceUpdatedMethodArgs("(Lorg/direct_bt/BTDevice;Lorg/direct_bt/EIRDataTypeSet;J)V")
jbyte Java_jau_direct_1bt_DBTAdapter_getCurrentDiscoveryPolicyImpl(JNIEnv *env, jobject obj)
jbyte Java_jau_direct_1bt_DBTAdapter_getRoleImpl(JNIEnv *env, jobject obj)
static const std::string _pairingModeClassName("org/direct_bt/PairingMode")
static const std::string _discoveringChangedMethodArgs("(Lorg/direct_bt/BTAdapter;Lorg/direct_bt/ScanType;Lorg/direct_bt/ScanType;ZLorg/direct_bt/DiscoveryPolicy;J)V")
static const std::string _devicePairingStateMethodArgs("(Lorg/direct_bt/BTDevice;Lorg/direct_bt/SMPPairingState;Lorg/direct_bt/PairingMode;J)V")
static const std::string _deviceConnectedMethodArgs("(Lorg/direct_bt/BTDevice;ZJ)V")
jbyte Java_jau_direct_1bt_DBTAdapter_stopAdvertisingImpl(JNIEnv *env, jobject obj)
void Java_jau_direct_1bt_DBTAdapter_setSMPKeyPath(JNIEnv *env, jobject obj, jstring jpath)
JNIAdapterStatusListener(JNIEnv *env, jobject statusListenerObj)
void deviceConnected(const BTDeviceRef &device, const bool discovered, const uint64_t timestamp) override
Remote BTDevice got connected.
void deviceReady(const BTDeviceRef &device, const uint64_t timestamp) override
Remote BTDevice is ready for user (GATT) processing, i.e.
~JNIAdapterStatusListener() override=default
void deviceUpdated(const BTDeviceRef &device, const EIRDataType updateMask, const uint64_t timestamp) override
An already discovered remote BTDevice has been updated.
void deviceDisconnected(const BTDeviceRef &device, const HCIStatusCode reason, const uint16_t handle, const uint64_t timestamp) override
Remote BTDevice got disconnected.
void adapterSettingsChanged(BTAdapter &a, const AdapterSetting oldmask, const AdapterSetting newmask, const AdapterSetting changedmask, const uint64_t timestamp) override
BTAdapter setting(s) changed.
bool deviceFound(const BTDeviceRef &device, const uint64_t timestamp) override
A remote BTDevice has been newly discovered.
void devicePairingState(const BTDeviceRef &device, const SMPPairingState state, const PairingMode mode, const uint64_t timestamp) override
An already connected remote BTDevice's ::SMPPairingState has changed.
void discoveringChanged(BTAdapter &a, const ScanType currentMeta, const ScanType changedType, const bool changedEnabled, const DiscoveryPolicy policy, const uint64_t timestamp) override
BTAdapter's discovery state has changed, i.e.
std::string toString() const noexcept override
BTAdapter status listener for remote BTDevice discovery events: Added, updated and removed; as well a...
Unique Bluetooth EUI48 address and BDAddressType tuple.
BTAdapter represents one local Bluetooth Controller.
A thread safe singleton handler of the HCI control channel to one controller (BT adapter)
bool isOpen() const noexcept
Returns true if this mgmt instance is open, connected and hence valid, otherwise false.
Implementation of a dynamic linear array storage, aka vector.
T * get(U jarray_val, Mode mode_val=UPDATE_AND_RELEASE)
Acquired the primitive array.
jclass getClass() const noexcept
const JavaAnonRef & getJavaObject() noexcept
A std::shared_ptr<T> storage instance to be copied from and released into a java object's long native...
void null_check1() const
Throws an exception if this instances shared_ptr<T> storage is nullptr.
bool is_null() const noexcept
Returns true if either this instances shared_ptr<T> storage or the managed object reference is nullpt...
const std::shared_ptr< T > & shared_ptr() const
Provides access to const reference of shared_ptr<T>, r-value.
std::shared_ptr< T > * pointer() noexcept
Provides access to the shared_ptr<T> pointer, l-value of storage.
std::string toString() const noexcept
jlong release_to_jlong() noexcept
Release ownership and return the jlong representation of the shared_ptr<T> storage.
static const uint8_t filter_policy
static const uint16_t le_scan_interval
static const uint16_t le_scan_window
static const bool filter_dup
static bool le_scan_active
static const uint16_t adv_interval_max
static const uint8_t adv_chan_map
static const uint16_t adv_interval_min
static const AD_PDU_Type adv_type
#define ERR_PRINT(...)
Use for unconditional error messages, prefix '[elapsed_time] Error @ FILE:LINE FUNC: '.
#define DBG_PRINT(...)
Use for environment-variable environment::DEBUG conditional debug messages, prefix '[elapsed_time] De...
#define WARN_PRINT(...)
Use for unconditional warning messages, prefix '[elapsed_time] Warning @ FILE:LINE FUNC: '.
std::string to_string(const alphabet &v) noexcept
SMPPairingState
SMP Pairing Process state definition.
constexpr SMPIOCapability to_SMPIOCapability(const uint8_t v) noexcept
constexpr BTSecurityLevel to_BTSecurityLevel(const uint8_t v) noexcept
BTMode
Bluetooth adapter operating mode.
HCIWhitelistConnectType
HCI Whitelist connection type.
DiscoveryPolicy
Discovery policy defines the BTAdapter discovery mode after connecting a remote BTDevice:
std::shared_ptr< BTDevice > BTDeviceRef
LE_PHYs
LE Transport PHY bit values.
ScanType
Meta ScanType as derived from BTMode, with defined value mask consisting of BDAddressType bits.
AdapterSetting
Adapter Setting Bits.
BDAddressType
BT Core Spec v5.2: Vol 3, Part C Generic Access Profile (GAP): 15.1.1.1 Public Bluetooth address.
AD_PDU_Type
LE Advertising (AD) Protocol Data Unit (PDU) Types.
PairingMode
Bluetooth secure pairing mode.
HCIStatusCode
BT Core Spec v5.2: Vol 1, Part F Controller Error Codes: 1.3 List of Error Codes.
EIRDataType
Bit mask of 'Extended Inquiry Response' (EIR) data fields, indicating a set of related data.
constexpr uint32_t number(const iostate rhs) noexcept
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.
thread_local JNIEnvContainer jni_env
jstring from_string_to_jstring(JNIEnv *env, const std::string &str)
jobject convert_vector_sharedptr_to_jarraylist(JNIEnv *env, T &array)
jfieldID search_field(JNIEnv *env, jclass clazz, const char *field_name, const char *type, bool is_static)
jmethodID search_method(JNIEnv *env, jclass clazz, const char *method_name, const char *prototype, bool is_static)
std::shared_ptr< JavaAnon > JavaAnonRef
std::string from_jstring_to_string(JNIEnv *env, jstring str)
jclass search_class(JNIEnv *env, const char *clazz_name)
std::string to_hexstring(value_type const &v) noexcept
Produce a lower-case hexadecimal string representation of the given pointer.
#define rethrow_and_raise_java_exception(E)
Re-throw current exception and raise respective java exception using any matching function above.
A packed 48 bit EUI-48 identifier, formerly known as MAC-48 or simply network device MAC address (Med...