aboutsummaryrefslogtreecommitdiffstats
path: root/java/jni
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2022-01-04 20:18:06 +0100
committerSven Gothel <[email protected]>2022-01-04 20:18:06 +0100
commit11eeb747a8de64a908c6ff25fb0be47e10403c36 (patch)
treecb6f40eca0d22205d54058b864fb5b35f4b0ee6b /java/jni
parent3705f5c4b5fc9c138497eefd31f6866603ad8afe (diff)
BTAdapter: Add startAdvertising(..) overload with user given EInfoReport and EIRDataType[Set] AD masks ..
.. allowing user to detail actual EIR AD (extended information advertising) instead of using the default. This is required to programmatically setup specific advertising information of the created server.
Diffstat (limited to 'java/jni')
-rw-r--r--java/jni/direct_bt/DBTAdapter.cxx39
1 files changed, 35 insertions, 4 deletions
diff --git a/java/jni/direct_bt/DBTAdapter.cxx b/java/jni/direct_bt/DBTAdapter.cxx
index d675b4b4..2e0f3a2e 100644
--- a/java/jni/direct_bt/DBTAdapter.cxx
+++ b/java/jni/direct_bt/DBTAdapter.cxx
@@ -994,10 +994,41 @@ void Java_jau_direct_1bt_DBTAdapter_printDeviceListsImpl(JNIEnv *env, jobject ob
}
}
-jbyte Java_jau_direct_1bt_DBTAdapter_startAdvertisingImpl(JNIEnv *env, jobject obj,
- jobject jgattServerData,
- jshort adv_interval_min, jshort adv_interval_max, jbyte jadv_type, jbyte adv_chan_map,
- jbyte filter_policy) {
+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) {
+ try {
+ DBGattServerRef gattServerRef; // nullptr
+ if( nullptr != jgattServerData ) {
+ std::shared_ptr<DBGattServer> * ref_ptr = jau::getInstance<std::shared_ptr<DBGattServer>>(env, jgattServerData);
+ gattServerRef = *ref_ptr;
+ }
+ if( nullptr == jeir ) {
+ throw jau::IllegalArgumentException("eir null", E_FILE_LINE);
+ }
+ EInfoReport * eir_ptr = jau::getInstance<EInfoReport>(env, jeir);
+ BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
+ jau::JavaGlobalObj::check(adapter->getJavaObject(), E_FILE_LINE);
+
+ const EIRDataType adv_mask = static_cast<EIRDataType>(jadv_mask);
+ const EIRDataType scanrsp_mask = static_cast<EIRDataType>(jscanrsp_mask);
+ const AD_PDU_Type adv_type = static_cast<AD_PDU_Type>(jadv_type);
+ HCIStatusCode res = adapter->startAdvertising(gattServerRef, *eir_ptr, adv_mask, scanrsp_mask, adv_interval_min, adv_interval_max, adv_type, adv_chan_map, filter_policy);
+ return (jbyte) number(res);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
+ }
+ return (jbyte) number(HCIStatusCode::INTERNAL_FAILURE);
+}
+
+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) {
try {
DBGattServerRef gattServerRef; // nullptr
if( nullptr != jgattServerData ) {