26#include "jau_direct_bt_DBTDevice.h"
27#include "org_direct_bt_BTGattCharListener.h"
62 jmethodID mNotificationReceived =
nullptr;
63 jmethodID mIndicationReceived =
nullptr;
68 : listenerObj(listener)
72 if(
nullptr == listenerClazz ) {
84 const jau::TROOctets& charValue,
const uint64_t timestamp)
override {
85 JavaAnonRef jCharDeclRef = charDecl->getJavaObject();
86 if( !JavaGlobalObj::isValid(jCharDeclRef) ) {
90 jobject jCharDecl = JavaGlobalObj::GetObject(jCharDeclRef);
92 const size_t value_size = charValue.
size();
93 jbyteArray jval = env->NewByteArray((jsize)value_size);
94 env->SetByteArrayRegion(jval, 0, (jsize)value_size, (
const jbyte *)charValue.
get_ptr());
97 env->CallVoidMethod(listenerObj.
getObject(), mNotificationReceived,
98 jCharDecl, jval, (jlong)timestamp);
100 env->DeleteLocalRef(jval);
105 const bool confirmationSent)
override {
106 JavaAnonRef jCharDeclRef = charDecl->getJavaObject();
107 if( !JavaGlobalObj::isValid(jCharDeclRef) ) {
111 jobject jCharDecl = JavaGlobalObj::GetObject(jCharDeclRef);
113 const size_t value_size = charValue.
size();
114 jbyteArray jval = env->NewByteArray((jsize)value_size);
115 env->SetByteArrayRegion(jval, 0, (jsize)value_size, (
const jbyte *)charValue.
get_ptr());
118 env->CallVoidMethod(listenerObj.
getObject(), mIndicationReceived,
119 jCharDecl, jval, (jlong)timestamp, (jboolean)confirmationSent);
121 env->DeleteLocalRef(jval);
139 return (jlong) (intptr_t)
nullptr;
152 if(
nullptr != sref.
pointer() ) {
153 std::shared_ptr<JNIGattCharListener>* sref_ptr = castInstance<JNIGattCharListener>(nativeInstance);
166 if(
nullptr != sref.
pointer() ) {
168 DBG_PRINT(
"Java_jau_direct_1bt_DBTDevice_deleteImpl (w/ remove) %s", sref->
toString().c_str());
171 DBG_PRINT(
"Java_jau_direct_1bt_DBTDevice_deleteImpl null reference");
173 std::shared_ptr<BTDevice>* sref_ptr = castInstance<BTDevice>(nativeInstance);
176 DBG_PRINT(
"Java_jau_direct_1bt_DBTDevice_deleteImpl null reference store");
223 const EUI48 & addr = device->getAddressAndType().address;
224 jbyteArray jaddr = env->NewByteArray(
sizeof(addr));
225 env->SetByteArrayRegion(jaddr, 0,
sizeof(addr), (
const jbyte*)(addr.
b));
238 return static_cast<jbyte
>(
number( device->getAddressAndType().type ) );
261 if( !charMatchRef.
is_null() ) {
262 JavaGlobalObj::check(charMatchRef->getJavaObject(),
E_FILE_LINE);
265 std::shared_ptr<BTGattHandler> gatt = device->getGattHandler();
266 if(
nullptr == gatt ) {
267 ERR_PRINT(
"BTGattChar's device GATTHandle not connected: %s", device->
toString().c_str());
272 if( !charMatchRef.
is_null() ) {
275 addRes = gatt->addCharListener( gcl.
shared_ptr() );
301 std::shared_ptr<BTGattHandler> gatt = device->getGattHandler();
302 if(
nullptr == gatt ) {
304 DBG_PRINT(
"BTGattChar's device GATTHandle not connected: %s", device->
toString().c_str());
308 if( ! gatt->removeCharListener(gcl.
shared_ptr()) ) {
330 JavaAnonRef device_gattchar = associatedCharacteristicRef->getJavaObject();
331 JavaGlobalObj::check(device_gattchar,
E_FILE_LINE);
333 std::shared_ptr<BTGattHandler> gatt = device->getGattHandler();
334 if(
nullptr == gatt ) {
336 DBG_PRINT(
"BTGattChar's device GATTHandle not connected: %s", device->
toString().c_str());
340 return (jint) gatt->removeAllAssociatedCharListener(associatedCharacteristicRef.
shared_ptr());
357 std::shared_ptr<BTGattHandler> gatt = device->getGattHandler();
358 if(
nullptr == gatt ) {
360 DBG_PRINT(
"BTGattChar's device GATTHandle not connected: %s", device->
toString().c_str());
363 return (jint) gatt->removeAllCharListener();
376 return (jbyte)
number( device->getRole() );
380 return (jbyte)
number( BTRole::None );
384 jbyteArray jresTx, jbyteArray jresRx) {
390 if(
nullptr == jresTx ) {
393 if(
nullptr == jresRx ) {
397 const size_t resTx_size = env->GetArrayLength(jresTx);
398 if( 1 > resTx_size ) {
401 const size_t resRx_size = env->GetArrayLength(jresRx);
402 if( 1 > resRx_size ) {
407 uint8_t * resTx_ptr = criticalArrayTx.
get(jresTx, criticalArrayTx.Mode::UPDATE_AND_RELEASE);
408 if(
nullptr == resTx_ptr ) {
412 uint8_t * resRx_ptr = criticalArrayRx.
get(jresRx, criticalArrayTx.Mode::UPDATE_AND_RELEASE);
413 if(
nullptr == resRx_ptr ) {
420 return (jbyte)
number( device->getConnectedLE_PHY(resTx, resRx) );
424 return (jbyte)
number(HCIStatusCode::INTERNAL_FAILURE);
428 jbyte jTx, jbyte jRx) {
437 return (jbyte)
number ( device->setConnectedLE_PHY(Tx, Rx) );
441 return (jbyte)
number(HCIStatusCode::INTERNAL_FAILURE);
450 return (jbyte)
number( device->getTxPhys() );
454 return (jbyte)
number(HCIStatusCode::INTERNAL_FAILURE);
463 return (jbyte)
number( device->getRxPhys() );
467 return (jbyte)
number(HCIStatusCode::INTERNAL_FAILURE);
476 return (jbyte)
number( device->disconnect() );
480 return (jbyte)
number(HCIStatusCode::INTERNAL_FAILURE);
489 return device->isPrePaired() ? JNI_TRUE : JNI_FALSE;
502 return static_cast<jint
>( device->getResponderSMPPassKey() );
528 return (jbyte)
number( device->connectDefault() );
532 return (jbyte)
number(HCIStatusCode::INTERNAL_FAILURE);
542 return (jbyte)
number(res);
546 return (jbyte)
number(HCIStatusCode::INTERNAL_FAILURE);
550 jshort interval, jshort window,
551 jshort min_interval, jshort max_interval,
552 jshort latency, jshort timeout)
558 HCIStatusCode res = device->connectLE(interval, window, min_interval, max_interval, latency, timeout);
559 return (jbyte)
number(res);
563 return (jbyte)
number(HCIStatusCode::INTERNAL_FAILURE);
572 return (jbyte)
number( device->getAvailableSMPKeys(JNI_TRUE == responder) );
585 return (jbyte)
number( device->uploadKeys() );
598 if(
nullptr == jsink ) {
601 const size_t sink_size = env->GetArrayLength(jsink);
606 uint8_t * sink_ptr = criticalArray.
get(jsink, criticalArray.Mode::UPDATE_AND_RELEASE);
607 if(
nullptr == sink_ptr ) {
611 ltk_sink = device->getLongTermKey(JNI_TRUE == responder);
623 if(
nullptr == jsource ) {
626 const size_t source_size = env->GetArrayLength(jsource);
631 uint8_t * source_ptr = criticalArray.
get(jsource, criticalArray.Mode::NO_UPDATE_AND_RELEASE);
632 if(
nullptr == source_ptr ) {
637 device->setLongTermKey(ltk);
649 if(
nullptr == jsink ) {
652 const size_t sink_size = env->GetArrayLength(jsink);
657 uint8_t * sink_ptr = criticalArray.
get(jsink, criticalArray.Mode::UPDATE_AND_RELEASE);
658 if(
nullptr == sink_ptr ) {
662 irk_sink = device->getIdentityResolvingKey(JNI_TRUE == responder);
674 if(
nullptr == jsource ) {
677 const size_t source_size = env->GetArrayLength(jsource);
682 uint8_t * source_ptr = criticalArray.
get(jsource, criticalArray.Mode::NO_UPDATE_AND_RELEASE);
683 if(
nullptr == source_ptr ) {
688 device->setIdentityResolvingKey(irk);
700 if(
nullptr == jsink ) {
703 const size_t sink_size = env->GetArrayLength(jsink);
708 uint8_t * sink_ptr = criticalArray.
get(jsink, criticalArray.Mode::UPDATE_AND_RELEASE);
709 if(
nullptr == sink_ptr ) {
713 irk_sink = device->getSignatureResolvingKey(JNI_TRUE == responder);
725 if(
nullptr == jsource ) {
728 const size_t source_size = env->GetArrayLength(jsource);
733 uint8_t * source_ptr = criticalArray.
get(jsource, criticalArray.Mode::NO_UPDATE_AND_RELEASE);
734 if(
nullptr == source_ptr ) {
739 device->setSignatureResolvingKey(irk);
751 if(
nullptr == jsink ) {
754 const size_t sink_size = env->GetArrayLength(jsink);
759 uint8_t * sink_ptr = criticalArray.
get(jsink, criticalArray.Mode::UPDATE_AND_RELEASE);
760 if(
nullptr == sink_ptr ) {
764 lk_sink = device->getLinkKey(JNI_TRUE == responder);
776 if(
nullptr == jsource ) {
779 const size_t source_size = env->GetArrayLength(jsource);
784 uint8_t * source_ptr = criticalArray.
get(jsource, criticalArray.Mode::NO_UPDATE_AND_RELEASE);
785 if(
nullptr == source_ptr ) {
790 device->setLinkKey(lk);
802 return (jbyte)
number(res);
806 return (jbyte)
number(HCIStatusCode::INTERNAL_FAILURE);
815 return (jbyte)
number( device->getConnSecurityLevel() );
819 return number( BTSecurityLevel::UNSET );
828 return (jbyte)
number( device->getConnIOCapability() );
832 return (jbyte)
number( SMPIOCapability::UNSET );
841 return device->setConnSecurity(
to_BTSecurityLevel(
static_cast<uint8_t
>(jsec_level) ),
855 return device->setConnSecurityAuto(
to_SMPIOCapability(
static_cast<uint8_t
>(jio_cap) ) );
868 return device->isConnSecurityAutoEnabled();
881 return (jbyte)
number( device->getPairingMode() );
885 return number( PairingMode::NONE );
894 return (jbyte)
static_cast<uint8_t
>( device->getPairingState() );
898 return static_cast<uint8_t
>( SMPPairingState::NONE );
907 return (jbyte)
number( device->setPairingPasskey(
static_cast<uint32_t
>(jpasskey) ) );
911 return (jbyte)
static_cast<uint8_t
>( HCIStatusCode::INTERNAL_FAILURE );
920 return (jbyte)
number( device->setPairingPasskeyNegative() );
924 return (jbyte)
static_cast<uint8_t
>( HCIStatusCode::INTERNAL_FAILURE );
933 return (jbyte)
number( device->setPairingNumericComparison( JNI_TRUE == jequal ?
true :
false ) );
937 return (jbyte)
static_cast<uint8_t
>( HCIStatusCode::INTERNAL_FAILURE );
953 if( services.
size() == 0 ) {
961 [](JNIEnv *env_, jclass clazz, jmethodID clazz_ctor,
const BTGattServiceRef& service)->jobject {
963 std::shared_ptr<BTDevice> _device = service->getDeviceUnchecked();
964 if(
nullptr == _device ) {
967 JavaAnonRef _device_java = _device->getJavaObject();
969 jobject jdevice = JavaGlobalObj::GetObject(_device_java);
971 const jboolean isPrimary = service->primary;
976 jobject jservice = env_->NewObject(clazz, clazz_ctor, service_sref.
release_to_jlong(), jdevice, isPrimary,
977 juuid, service->handle, service->end_handle);
980 JavaAnonRef jServiceRef = service->getJavaObject();
982 env_->DeleteLocalRef(juuid);
983 env_->DeleteLocalRef(jservice);
984 return JavaGlobalObj::GetObject(jServiceRef);
986 return convert_vector_sharedptr_to_jarraylist<jau::darray<BTGattServiceRef>,
BTGattService>(
1000 if(
nullptr == jval ) {
1003 const size_t value_size = env->GetArrayLength(jval);
1004 if( 0 >= value_size ) {
1008 uint8_t * value_ptr = criticalArray.
get(jval, criticalArray.Mode::NO_UPDATE_AND_RELEASE);
1009 if(
nullptr == value_ptr ) {
1013 return device->sendNotification(char_value_handle, value) ? JNI_TRUE : JNI_FALSE;
1023 JavaAnonRef device_java = device->getJavaObject();
1026 if(
nullptr == jval ) {
1029 const size_t value_size = env->GetArrayLength(jval);
1030 if( 0 >= value_size ) {
1034 uint8_t * value_ptr = criticalArray.
get(jval, criticalArray.Mode::NO_UPDATE_AND_RELEASE);
1035 if(
nullptr == value_ptr ) {
1039 return device->sendIndication(char_value_handle, value) ? JNI_TRUE : JNI_FALSE;
1050 JavaAnonRef device_java = device->getJavaObject();
1053 return device->pingGATT() ? JNI_TRUE : JNI_FALSE;
1064 JavaAnonRef device_java = device->getJavaObject();
1066 return (jshort) device->getRSSI();
1076 JavaAnonRef device_java = device->getJavaObject();
1082 eir_sink = device->getEIR();
1092 JavaAnonRef device_java = device->getJavaObject();
1098 eir_sink = device->getEIRInd();
1108 JavaAnonRef device_java = device->getJavaObject();
1114 eir_sink = device->getEIRScanRsp();
1125 JavaAnonRef device_java = device->getJavaObject();
1127 return (jshort) device->getTxPower();
1142struct BooleanDeviceCBContext {
1147 jmethodID boolean_ctor;
1149 BooleanDeviceCBContext(
1154 jmethodID boolean_ctor_)
1155 : addressAndType(addressAndType_), javaCallback_ref(javaCallback_ref_),
1156 mRun(mRun_), boolean_cls_ref(boolean_cls_ref_), boolean_ctor(boolean_ctor_)
1160 bool operator==(
const BooleanDeviceCBContext& rhs)
const
1162 if( &rhs ==
this ) {
1165 return rhs.addressAndType == addressAndType &&
1166 rhs.javaCallback_ref == javaCallback_ref;
1169 bool operator!=(
const BooleanDeviceCBContext& rhs)
const
1170 {
return !( *
this == rhs ); }
1173typedef std::shared_ptr<BooleanDeviceCBContext> BooleanDeviceCBContextRef;
1179static void disablePairedNotifications(JNIEnv *env, jobject obj,
BTManager &mgmt)
1181 InvocationFunc<bool, const MgmtEvent&> * funcptr =
1182 getObjectRef<InvocationFunc<bool, const MgmtEvent&>>(env, obj,
"pairedNotificationRef");
1183 if(
nullptr != funcptr ) {
1184 FunctionDef<bool, const MgmtEvent&> funcDef( funcptr );
1186 setObjectRef(env, obj, funcptr,
"pairedNotificationRef");
1193void Java_jau_direct_1bt_DBTDevice_disablePairedNotificationsImpl(JNIEnv *env, jobject obj)
1196 BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
1200 disablePairedNotifications(env, obj, mgmt);
1205void Java_jau_direct_1bt_DBTDevice_enablePairedNotificationsImpl(JNIEnv *env, jobject obj, jobject javaCallback)
1208 BTDevice *device= getJavaUplinkObject<BTDevice>(env, obj);
1213 disablePairedNotifications(env, obj, mgmt);
1215 bool(*nativeCallback)(BooleanDeviceCBContextRef&,
const MgmtEvent&) =
1216 [](BooleanDeviceCBContextRef& ctx_ref,
const MgmtEvent& e)->bool {
1218 if( event.getAddress() != ctx_ref->addressAndType.address ||
event.getAddressType() != ctx_ref->addressAndType.type ) {
1221 jobject result =
jni_env->NewObject(ctx_ref->boolean_cls_ref.getClass(), ctx_ref->boolean_ctor, JNI_FALSE);
1222 jni_env->CallVoidMethod(*(ctx_ref->javaCallback_ref), ctx_ref->mRun, result);
1223 jni_env->DeleteLocalRef(result);
1229 jni_env->DeleteLocalRef(notification);
1235 BooleanDeviceCBContext * ctx =
new BooleanDeviceCBContext{
1237 jni_env->DeleteLocalRef(boolean_cls);
1240 FunctionDef<bool, const MgmtEvent&> funcDef = bindCaptureFunc(BooleanDeviceCBContextRef(ctx), nativeCallback);
1241 setObjectRef(env, obj, funcDef.cloneFunction(),
"pairedNotificationRef");
jint Java_jau_direct_1bt_DBTDevice_getResponderSMPPassKey(JNIEnv *env, jobject obj)
jboolean Java_jau_direct_1bt_DBTDevice_addCharListenerImpl(JNIEnv *env, jobject obj, jobject jlistener, jobject jAssociatedCharacteristic)
void Java_jau_direct_1bt_DBTDevice_deleteImpl(JNIEnv *env, jobject obj, jlong nativeInstance)
jbyte Java_jau_direct_1bt_DBTDevice_getTxPhysImpl(JNIEnv *env, jobject obj)
jbyte Java_jau_direct_1bt_DBTDevice_unpairImpl(JNIEnv *env, jobject obj)
jboolean Java_jau_direct_1bt_DBTDevice_sendIndication(JNIEnv *env, jobject obj, jshort char_value_handle, jbyteArray jval)
jlong Java_org_direct_1bt_BTGattCharListener_ctorImpl(JNIEnv *env, jobject obj)
jboolean Java_jau_direct_1bt_DBTDevice_removeCharListener(JNIEnv *env, jobject obj, jobject jlistener)
jbyte Java_jau_direct_1bt_DBTDevice_getRoleImpl(JNIEnv *env, jobject obj)
jbyte Java_jau_direct_1bt_DBTDevice_setPairingPasskeyNegativeImpl(JNIEnv *env, jobject obj)
void Java_jau_direct_1bt_DBTDevice_getEIRIndImpl(JNIEnv *env, jobject obj, jobject jeir_sink)
void Java_jau_direct_1bt_DBTDevice_setIdentityResolvingKeyImpl(JNIEnv *env, jobject obj, jbyteArray jsource)
static const std::string _indicationReceivedMethodArgs("(Lorg/direct_bt/BTGattChar;[BJZ)V")
jbyte Java_jau_direct_1bt_DBTDevice_getAddressTypeImpl(JNIEnv *env, jobject obj)
jbyte Java_jau_direct_1bt_DBTDevice_getAvailableSMPKeysImpl(JNIEnv *env, jobject obj, jboolean responder)
jbyte Java_jau_direct_1bt_DBTDevice_connectLEImpl1(JNIEnv *env, jobject obj, jshort interval, jshort window, jshort min_interval, jshort max_interval, jshort latency, jshort timeout)
jboolean Java_jau_direct_1bt_DBTDevice_setConnSecurityImpl(JNIEnv *env, jobject obj, jbyte jsec_level, jbyte jio_cap)
void Java_jau_direct_1bt_DBTDevice_initImpl(JNIEnv *env, jobject obj)
jobject Java_jau_direct_1bt_DBTDevice_getGattServicesImpl(JNIEnv *env, jobject obj)
jboolean Java_jau_direct_1bt_DBTDevice_pingGATTImpl(JNIEnv *env, jobject obj)
void Java_jau_direct_1bt_DBTDevice_setSignatureResolvingKeyImpl(JNIEnv *env, jobject obj, jbyteArray jsource)
jbyte Java_jau_direct_1bt_DBTDevice_uploadKeysImpl(JNIEnv *env, jobject obj)
jstring Java_jau_direct_1bt_DBTDevice_getNameImpl(JNIEnv *env, jobject obj)
void Java_org_direct_1bt_BTGattCharListener_deleteImpl(JNIEnv *env, jobject obj, jlong nativeInstance)
static const std::string _serviceClazzCtorArgs("(JLjau/direct_bt/DBTDevice;ZLjava/lang/String;SS)V")
jbyte Java_jau_direct_1bt_DBTDevice_connectDefaultImpl(JNIEnv *env, jobject obj)
jbyte Java_jau_direct_1bt_DBTDevice_getRxPhysImpl(JNIEnv *env, jobject obj)
void Java_jau_direct_1bt_DBTDevice_getEIRScanRspImpl(JNIEnv *env, jobject obj, jobject jeir_sink)
void Java_jau_direct_1bt_DBTDevice_getEIRImpl(JNIEnv *env, jobject obj, jobject jeir_sink)
jboolean Java_jau_direct_1bt_DBTDevice_removeImpl(JNIEnv *env, jobject obj)
jint Java_jau_direct_1bt_DBTDevice_removeAllAssociatedCharListener(JNIEnv *env, jobject obj, jobject jAssociatedCharacteristic)
jboolean Java_jau_direct_1bt_DBTDevice_setConnSecurityAutoImpl(JNIEnv *env, jobject obj, jbyte jio_cap)
jbyte Java_jau_direct_1bt_DBTDevice_getConnIOCapabilityImpl(JNIEnv *env, jobject obj)
jshort Java_jau_direct_1bt_DBTDevice_getRSSI(JNIEnv *env, jobject obj)
void Java_jau_direct_1bt_DBTDevice_setLongTermKeyImpl(JNIEnv *env, jobject obj, jbyteArray jsource)
void Java_jau_direct_1bt_DBTDevice_getSignatureResolvingKeyImpl(JNIEnv *env, jobject obj, jboolean responder, jbyteArray jsink)
static const std::string _notificationReceivedMethodArgs("(Lorg/direct_bt/BTGattChar;[BJ)V")
jstring Java_jau_direct_1bt_DBTDevice_toStringImpl(JNIEnv *env, jobject obj)
jbyteArray Java_jau_direct_1bt_DBTDevice_getAddressImpl(JNIEnv *env, jobject obj)
jint Java_jau_direct_1bt_DBTDevice_removeAllCharListener(JNIEnv *env, jobject obj)
jboolean Java_jau_direct_1bt_DBTDevice_isConnSecurityAutoEnabled(JNIEnv *env, jobject obj)
void Java_jau_direct_1bt_DBTDevice_getLinkKeyImpl(JNIEnv *env, jobject obj, jboolean responder, jbyteArray jsink)
void Java_jau_direct_1bt_DBTDevice_getIdentityResolvingKeyImpl(JNIEnv *env, jobject obj, jboolean responder, jbyteArray jsink)
jbyte Java_jau_direct_1bt_DBTDevice_getPairingModeImpl(JNIEnv *env, jobject obj)
jbyte Java_jau_direct_1bt_DBTDevice_disconnectImpl(JNIEnv *env, jobject obj)
jbyte Java_jau_direct_1bt_DBTDevice_getPairingStateImpl(JNIEnv *env, jobject obj)
jboolean Java_jau_direct_1bt_DBTDevice_sendNotification(JNIEnv *env, jobject obj, jshort char_value_handle, jbyteArray jval)
jbyte Java_jau_direct_1bt_DBTDevice_setPairingNumericComparisonImpl(JNIEnv *env, jobject obj, jboolean jequal)
void Java_jau_direct_1bt_DBTDevice_getLongTermKeyImpl(JNIEnv *env, jobject obj, jboolean responder, jbyteArray jsink)
jshort Java_jau_direct_1bt_DBTDevice_getTxPower(JNIEnv *env, jobject obj)
jbyte Java_jau_direct_1bt_DBTDevice_connectLEImpl0(JNIEnv *env, jobject obj)
jbyte Java_jau_direct_1bt_DBTDevice_getConnSecurityLevelImpl(JNIEnv *env, jobject obj)
jbyte Java_jau_direct_1bt_DBTDevice_getConnectedLE_1PHYImpl(JNIEnv *env, jobject obj, jbyteArray jresTx, jbyteArray jresRx)
jbyte Java_jau_direct_1bt_DBTDevice_setPairingPasskeyImpl(JNIEnv *env, jobject obj, jint jpasskey)
void Java_jau_direct_1bt_DBTDevice_setLinkKeyImpl(JNIEnv *env, jobject obj, jbyteArray jsource)
jbyte Java_jau_direct_1bt_DBTDevice_setConnectedLE_1PHYImpl(JNIEnv *env, jobject obj, jbyte jTx, jbyte jRx)
jboolean Java_jau_direct_1bt_DBTDevice_isPrePaired(JNIEnv *env, jobject obj)
JNIGattCharListener(JNIEnv *env, jobject listener)
void notificationReceived(BTGattCharRef charDecl, const jau::TROOctets &charValue, const uint64_t timestamp) override
Called from native BLE stack, initiated by a received notification associated with the given BTGattCh...
void indicationReceived(BTGattCharRef charDecl, const jau::TROOctets &charValue, const uint64_t timestamp, const bool confirmationSent) override
Called from native BLE stack, initiated by a received indication associated with the given BTGattChar...
Unique Bluetooth EUI48 address and BDAddressType tuple.
BTAdapter represents one local Bluetooth Controller.
const uint16_t dev_id
Adapter's internal temporary device id.
const BTManagerRef & getManager() const noexcept
Returns a reference to the used singleton BTManager instance, used to create this adapter.
BTDevice represents one remote Bluetooth device.
constexpr BDAddressAndType const & getAddressAndType() const noexcept
Returns the devices' unique EUI48 address and type tuple, might be its initially reported (resolvable...
BTAdapter & getAdapter() const
Returns the managing adapter.
BTGattChar event listener for notification and indication events.
Representing a Gatt Service object from the GATTRole::Client perspective.
A thread safe singleton handler of the BTAdapter manager, e.g.
size_type removeMgmtEventCallback(const MgmtEvent::Opcode opc, const MgmtEventCallback &cb) noexcept
Returns count of removed given MgmtEventCallback from the named MgmtEvent::Opcode list.
bool addMgmtEventCallback(const int dev_id, const MgmtEvent::Opcode opc, const MgmtEventCallback &cb) noexcept
MgmtEventCallback handling
uint16_t opcode, uint16_t dev-id, uint16_t param_size
mgmt_addr_info { EUI48, uint8_t type },
Transient read only and endian aware octet data, i.e.
constexpr nsize_t size() const noexcept
Returns the used memory size for read and write operations, may be zero.
constexpr uint8_t const * get_ptr() const noexcept
Implementation of a dynamic linear array storage, aka vector.
constexpr size_type size() const noexcept
Like std::vector::size().
Class template jau::function is a general-purpose static-polymorphic function wrapper.
T * get(U jarray_val, Mode mode_val=UPDATE_AND_RELEASE)
Acquired the primitive array.
jobject getObject() 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...
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.
void release_into_object(JNIEnv *env, jobject obj)
Deletes the std::shared_ptr<T> storage of the target java object if exists first and writes this inst...
#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: '.
@ little
Identifier for little endian, equivalent to endian::little.
bool operator!=(const alphabet &lhs, const alphabet &rhs) noexcept
std::string to_string(const alphabet &v) noexcept
bool operator==(const alphabet &lhs, const alphabet &rhs) noexcept
constexpr SMPIOCapability to_SMPIOCapability(const uint8_t v) noexcept
constexpr BTSecurityLevel to_BTSecurityLevel(const uint8_t v) noexcept
LE_PHYs
LE Transport PHY bit values.
HCIStatusCode
BT Core Spec v5.2: Vol 1, Part F Controller Error Codes: 1.3 List of Error Codes.
std::shared_ptr< BTGattChar > BTGattCharRef
std::shared_ptr< BTGattService > BTGattServiceRef
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)
void setObjectRef(JNIEnv *env, jobject obj, T *t, const char *field_name)
jmethodID search_method(JNIEnv *env, jclass clazz, const char *method_name, const char *prototype, bool is_static)
std::shared_ptr< JavaAnon > JavaAnonRef
jclass search_class(JNIEnv *env, const char *clazz_name)
#define rethrow_and_raise_java_exception(E)
Re-throw current exception and raise respective java exception using any matching function above.
SMP Identity Resolving Key, used for platform agnostic persistence.
Local SMP Link Key, used for platform agnostic persistence, mapping to platform specific MgmtLoadLink...
SMP Long Term Key, used for platform agnostic persistence.
SMP Signature Resolving Key, used for platform agnostic persistence.
A packed 48 bit EUI-48 identifier, formerly known as MAC-48 or simply network device MAC address (Med...