Direct-BT  2.3.1
Direct-BT - Direct Bluetooth Programming.
helper_dbt.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 <jni.h>
27 #include <memory>
28 #include <stdexcept>
29 #include <vector>
30 
31 #include "helper_dbt.hpp"
32 
33 using namespace direct_bt;
34 
36 
37 static std::string jStringEmpty("");
38 static std::string jAddressTypePublic("public");
39 static std::string jAddressTypeRandom("random");
40 
41 BDAddressType direct_bt::fromJavaAdressTypeToBDAddressType(JNIEnv *env, jstring jAddressType) {
42  if( nullptr != jAddressType ) {
43  std::string saddressType = jau::from_jstring_to_string(env, jAddressType);
44  if( jAddressTypePublic == saddressType ) {
46  }
47  if( jAddressTypeRandom == saddressType ) {
49  }
50  }
52 }
53 jstring direct_bt::fromBDAddressTypeToJavaAddressType(JNIEnv *env, BDAddressType bdAddressType) {
54  switch( bdAddressType ) {
60  // fall through intended
61  default:
63  }
64 }
65 
jau::from_jstring_to_string
std::string from_jstring_to_string(JNIEnv *env, jstring str)
direct_bt::DirectBTJNISettings
Definition: helper_dbt.hpp:35
jau::from_string_to_jstring
jstring from_string_to_jstring(JNIEnv *env, const std::string &str)
helper_dbt.hpp
direct_bt
Definition: ATTPDUTypes.hpp:171
direct_bt::fromBDAddressTypeToJavaAddressType
jstring fromBDAddressTypeToJavaAddressType(JNIEnv *env, BDAddressType bdAddressType)
Definition: helper_dbt.cxx:53
direct_bt::directBTJNISettings
DirectBTJNISettings directBTJNISettings
Definition: helper_dbt.cxx:35
jAddressTypeRandom
static std::string jAddressTypeRandom("random")
jStringEmpty
static std::string jStringEmpty("")
direct_bt::fromJavaAdressTypeToBDAddressType
BDAddressType fromJavaAdressTypeToBDAddressType(JNIEnv *env, jstring jAddressType)
Definition: helper_dbt.cxx:41
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::BDAddressType::BDADDR_LE_RANDOM
@ BDADDR_LE_RANDOM
Bluetooth LE random address, see BLERandomAddressType.
jAddressTypePublic
static std::string jAddressTypePublic("public")
direct_bt::BDAddressType::BDADDR_LE_PUBLIC
@ BDADDR_LE_PUBLIC
Bluetooth LE public address.
direct_bt::BDAddressType::BDADDR_BREDR
@ BDADDR_BREDR
Bluetooth BREDR address.