1 /******************************************************************
3 * Copyright 2014 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************/
23 * @brief This file contains the APIs for BT LE communications.
25 #ifndef __CA_LECORE_H_
26 #define __CA_LECORE_H_
29 #include "uthreadpool.h"
37 typedef void (*CAPacketReceiveCallback)(const char* address, const char* data);
39 void CALEInitialize(u_thread_pool_t handle);
43 int32_t CALESendUnicastMessage(const char* address, const char* data, uint32_t dataLen);
45 int32_t CALESendMulticastMessage(const char* data, uint32_t dataLen);
47 int32_t CALEStartUnicastServer(const char* address);
49 int32_t CALEStartMulticastServer();
51 int32_t CALEStopUnicastServer(int32_t serverID);
53 int32_t CALEStopMulticastServer(int32_t serverID);
55 void CALESetCallback(CAPacketReceiveCallback callback);
57 void CALEGetInterfaceInfo(CALocalConnectivity_t **info, uint32_t* size);
59 void CAGetLocalAddress(char* address);
61 int32_t CALESendUnicastMessageImpl(const char* address, const char* data, uint32_t dataLen);
63 int32_t CALESendMulticastMessageImpl(JNIEnv *env, const char* data, uint32_t dataLen);
66 * BT Common Method : JNI
68 jstring CANativeGetLocalDeviceAddress(JNIEnv *env);
70 jobjectArray CANativeGetBondedDevices(JNIEnv *env);
72 jint CANativeGetBTStateOnInfo(JNIEnv *env);
74 jboolean CANativeIsEnableBTAdapter(JNIEnv *env);
76 jstring CANativeGetAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice);
78 jstring CANativeGetAddressFromGattObj(JNIEnv *env, jobject gatt);
80 jstring CANativeGetRemoteAddress(JNIEnv *env, jobject bluetoothSocketObj);
85 void CANativeGattClose(JNIEnv *env, jobject bluetoothGatt);
87 void CANativeLEStartScan();
89 void CANativeLEStartScanImpl(JNIEnv *env, jobject callback);
91 void CANativeLEStartScanWithUUIDImpl(JNIEnv *env, jobjectArray uuids, jobject callback);
93 jobject CANativeGetUUIDObject(JNIEnv *env, const char* uuid);
95 void CANativeLEStopScan();
97 void CANativeLEStopScanImpl(JNIEnv *env, jobject callback);
99 void CANativeLEConnect(JNIEnv *env, jobject bluetoothDevice, jobject context, jboolean autoconnect,
102 void CANativeLEDisconnect(JNIEnv *env, jobject bluetoothGatt);
104 void CANativeLEDiscoverServices(JNIEnv *env, jobject bluetoothGatt);
106 void CANativeLESendData(JNIEnv *env, jobject bluetoothGatt, jobject gattCharacteristic);
108 jboolean CANativeSetCharacteristicNoti(JNIEnv *env, jobject bluetoothGatt);
110 jobject CANativeCreateGattCharacteristic(JNIEnv *env, jobject bluetoothGatt, jstring data);
112 jobject CANativeGetGattService(JNIEnv *env, jobject bluetoothGatt, jstring characterUUID);
114 jbyteArray CANativeGetValueFromCharacteristic(JNIEnv *env, jobject characteristic);
117 * BluetoothDevice List
119 void CANativeCreateScanDeviceList(JNIEnv *env);
121 void CANativeAddScanDeviceToList(JNIEnv *env, jobject device);
123 jboolean CANativeIsDeviceInList(JNIEnv *env, const char* remoteAddress);
125 void CANativeRemoveAllDevices(JNIEnv *env);
127 void CANativeRemoveDevice(JNIEnv *env, jstring remoteAddress);
129 void CAReorderingDeviceList(uint32_t index);
134 void CANativeCreateGattObjList(JNIEnv *env);
136 void CANativeAddGattobjToList(JNIEnv *env, jobject gatt);
138 jboolean CANativeIsGattObjInList(JNIEnv *env, const char* remoteAddress);
140 void CANativeRemoveAllGattObjsList(JNIEnv *env);
142 void CANativeLEDisconnectAll(JNIEnv *env);
144 void CANativeRemoveGattObj(JNIEnv *env, jstring address);
146 void CAReorderingGattList(uint32_t index);