Merge "Implementation of connectivity abstraction feature Release v0.5" into connecti...
[platform/upstream/iotivity.git] / resource / csdk / connectivity / inc / calecore.h
1 /******************************************************************
2  *
3  * Copyright 2014 Samsung Electronics All Rights Reserved.
4  *
5  *
6  *
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  ******************************************************************/
20
21 /**
22  * @file calecore.h
23  * @brief This file contains the APIs for BT LE communications.
24  */
25 #ifndef __CA_LECORE_H_
26 #define __CA_LECORE_H_
27
28 #include "cacommon.h"
29 #include "uthreadpool.h"
30 #include "jni.h"
31
32 #ifdef __cplusplus
33 extern "C"
34 {
35 #endif
36
37 typedef void (*CAPacketReceiveCallback)(const char* address, const char* data);
38
39 void CALEInitialize(u_thread_pool_t handle);
40
41 void CALETerminate();
42
43 int32_t CALESendUnicastMessage(const char* address, const char* data, uint32_t dataLen);
44
45 int32_t CALESendMulticastMessage(const char* data, uint32_t dataLen);
46
47 int32_t CALEStartUnicastServer(const char* address);
48
49 int32_t CALEStartMulticastServer();
50
51 int32_t CALEStopUnicastServer(int32_t serverID);
52
53 int32_t CALEStopMulticastServer(int32_t serverID);
54
55 void CALESetCallback(CAPacketReceiveCallback callback);
56
57 void CALEGetInterfaceInfo(CALocalConnectivity_t **info, uint32_t* size);
58
59 void CAGetLocalAddress(char* address);
60
61 int32_t CALESendUnicastMessageImpl(const char* address, const char* data, uint32_t dataLen);
62
63 int32_t CALESendMulticastMessageImpl(JNIEnv *env, const char* data, uint32_t dataLen);
64
65 /**
66  * BT Common Method : JNI
67  */
68 jstring CANativeGetLocalDeviceAddress(JNIEnv *env);
69
70 jobjectArray CANativeGetBondedDevices(JNIEnv *env);
71
72 jint CANativeGetBTStateOnInfo(JNIEnv *env);
73
74 jboolean CANativeIsEnableBTAdapter(JNIEnv *env);
75
76 jstring CANativeGetAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice);
77
78 jstring CANativeGetAddressFromGattObj(JNIEnv *env, jobject gatt);
79
80 jstring CANativeGetRemoteAddress(JNIEnv *env, jobject bluetoothSocketObj);
81
82 /**
83  * BLE Method : JNI
84  */
85 void CANativeGattClose(JNIEnv *env, jobject bluetoothGatt);
86
87 void CANativeLEStartScan();
88
89 void CANativeLEStartScanImpl(JNIEnv *env, jobject callback);
90
91 void CANativeLEStartScanWithUUIDImpl(JNIEnv *env, jobjectArray uuids, jobject callback);
92
93 jobject CANativeGetUUIDObject(JNIEnv *env, const char* uuid);
94
95 void CANativeLEStopScan();
96
97 void CANativeLEStopScanImpl(JNIEnv *env, jobject callback);
98
99 void CANativeLEConnect(JNIEnv *env, jobject bluetoothDevice, jobject context, jboolean autoconnect,
100     jobject callback);
101
102 void CANativeLEDisconnect(JNIEnv *env, jobject bluetoothGatt);
103
104 void CANativeLEDiscoverServices(JNIEnv *env, jobject bluetoothGatt);
105
106 void CANativeLESendData(JNIEnv *env, jobject bluetoothGatt, jobject gattCharacteristic);
107
108 jboolean CANativeSetCharacteristicNoti(JNIEnv *env, jobject bluetoothGatt);
109
110 jobject CANativeCreateGattCharacteristic(JNIEnv *env, jobject bluetoothGatt, jstring data);
111
112 jobject CANativeGetGattService(JNIEnv *env, jobject bluetoothGatt, jstring characterUUID);
113
114 jbyteArray CANativeGetValueFromCharacteristic(JNIEnv *env, jobject characteristic);
115
116 /**
117  * BluetoothDevice List
118  */
119 void CANativeCreateScanDeviceList(JNIEnv *env);
120
121 void CANativeAddScanDeviceToList(JNIEnv *env, jobject device);
122
123 jboolean CANativeIsDeviceInList(JNIEnv *env, const char* remoteAddress);
124
125 void CANativeRemoveAllDevices(JNIEnv *env);
126
127 void CANativeRemoveDevice(JNIEnv *env, jstring remoteAddress);
128
129 void CAReorderingDeviceList(uint32_t index);
130
131 /**
132  * BluetoothGatt List
133  */
134 void CANativeCreateGattObjList(JNIEnv *env);
135
136 void CANativeAddGattobjToList(JNIEnv *env, jobject gatt);
137
138 jboolean CANativeIsGattObjInList(JNIEnv *env, const char* remoteAddress);
139
140 void CANativeRemoveAllGattObjsList(JNIEnv *env);
141
142 void CANativeLEDisconnectAll(JNIEnv *env);
143
144 void CANativeRemoveGattObj(JNIEnv *env, jstring address);
145
146 void CAReorderingGattList(uint32_t index);
147
148 #ifdef __cplusplus
149 } /* extern "C" */
150 #endif
151
152 #endif