26#include "jau_direct_bt_DBTGattService.h"
45 if(
nullptr != sref.
pointer() ) {
46 std::shared_ptr<BTGattService>* sref_ptr = castInstance<BTGattService>(nativeInstance);
57 JavaAnonRef service_java = service->getJavaObject();
67static const std::string
_characteristicClazzCtorArgs(
"(JLjau/direct_bt/DBTGattService;SLorg/direct_bt/GattCharPropertySet;Ljava/lang/String;SII)V");
74 JavaAnonRef service_java = service->getJavaObject();
79 jclass gattCharPropSetClazz;
80 jmethodID gattCharPropSetClazzCtor;
85 if(
nullptr == gattCharPropSetClazz ) {
91 if(
nullptr == gattCharPropSetClazzCtor ) {
103 [&gattCharPropSetClazz, &gattCharPropSetClazzCtor](JNIEnv *env_, jclass clazz, jmethodID clazz_ctor,
const BTGattCharRef& characteristic)->jobject {
105 std::shared_ptr<BTGattService> _service = characteristic->getServiceUnchecked();
106 if(
nullptr == _service ) {
109 JavaAnonRef _service_java = _service->getJavaObject();
112 jobject jservice = JavaGlobalObj::GetObject(_service_java);
114 jobject jGattCharPropSet = env_->NewObject(gattCharPropSetClazz, gattCharPropSetClazzCtor, (jbyte)characteristic->properties);
116 JNIGlobalRef::check(jGattCharPropSet,
E_FILE_LINE);
123 jobject jcharVal = env_->NewObject(clazz, clazz_ctor, characteristic_sref.
release_to_jlong(), jservice,
124 characteristic->handle, jGattCharPropSet,
125 uuid, characteristic->value_handle,
126 characteristic->clientCharConfigIndex,
127 characteristic->userDescriptionIndex);
130 JavaAnonRef jCharRef = characteristic->getJavaObject();
132 env_->DeleteLocalRef(jGattCharPropSet);
133 env_->DeleteLocalRef(jcharVal);
134 return JavaGlobalObj::GetObject(jCharRef);
136 jobject jres = convert_vector_sharedptr_to_jarraylist<jau::darray<std::shared_ptr<BTGattChar>>,
BTGattChar>(
138 env->DeleteLocalRef(gattCharPropSetClazz);
void Java_jau_direct_1bt_DBTGattService_deleteImpl(JNIEnv *env, jobject obj, jlong nativeInstance)
jstring Java_jau_direct_1bt_DBTGattService_toStringImpl(JNIEnv *env, jobject obj)
static const std::string _gattCharPropSetClazzCtorArgs("(B)V")
static const std::string _gattCharPropSetClassName("org/direct_bt/GattCharPropertySet")
static const std::string _characteristicClazzCtorArgs("(JLjau/direct_bt/DBTGattService;SLorg/direct_bt/GattCharPropertySet;Ljava/lang/String;SII)V")
jobject Java_jau_direct_1bt_DBTGattService_getCharsImpl(JNIEnv *env, jobject obj)
Representing a Gatt Characteristic object from the GATTRole::Client perspective.
Implementation of a dynamic linear array storage, aka vector.
Class template jau::function is a general-purpose static-polymorphic function wrapper.
A std::shared_ptr<T> storage instance to be copied from and released into a java object's long native...
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.
std::shared_ptr< BTGattChar > BTGattCharRef
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.
jstring from_string_to_jstring(JNIEnv *env, const std::string &str)
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.