replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / resource / csdk / connectivity / src / bt_le_adapter / android / caleclient.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
23  * This file contains the APIs for BT LE communications.
24  */
25 #ifndef CA_LECLIENT_H_
26 #define CA_LECLIENT_H_
27
28 #include "calestate.h"
29 #include "cacommon.h"
30 #include "cathreadpool.h"
31 #include "uarraylist.h"
32 #include "jni.h"
33
34 #ifdef __cplusplus
35 extern "C"
36 {
37 #endif
38
39 /**
40  * BLE Scanning State.
41  */
42 typedef enum
43 {
44     BLE_SCAN_ENABLE = 0, /**< BLE scan is working */
45     BLE_SCAN_DISABLE,    /**< BLE scan is not working */
46     BLE_SCAN_NONE        /**< Initialize State */
47 } CALEScanState_t;
48
49 /**
50  * Callback to be notified on reception of any data from remote devices.
51  * @param[in]  address                MAC address of remote device.
52  * @param[in]  data                   Data received from remote device.
53  * @pre  Callback must be registered using CALESetCallback(CAPacketReceiveCallback callback)
54  */
55 typedef void (*CAPacketReceiveCallback)(const char *address, const uint8_t *data);
56
57 /**
58  * initialize JNI object.
59  */
60 void CALEClientJniInit();
61
62 /**
63  * set context of application.
64  */
65 void CALEClientJNISetContext();
66
67 /**
68  * create interface object and initialize the object.
69  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
70  */
71 CAResult_t CALEClientCreateJniInterfaceObject();
72
73 /**
74  * initialize client for BLE.
75  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
76  */
77 CAResult_t CALEClientInitialize();
78
79 /**
80  * terminate client for BLE.
81  */
82 void CALEClientTerminate();
83
84 /**
85  * destroy interface object and terminate the interface.
86  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
87  */
88 CAResult_t CALEClientDestroyJniInterface();
89
90 /**
91  * for destroy sending routine.
92  * @param[in]   env                   JNI interface pointer.
93  * @param[in]   gatt                  Gatt profile object.
94  */
95 void CALEClientSendFinish(JNIEnv *env, jobject gatt);
96
97 /**
98  * send negotiation message after gatt connection is done.
99  * @param[in]   address               remote address.
100  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
101  */
102 CAResult_t CALEClientSendNegotiationMessage(const char* address);
103
104 /**
105  * send data for unicast (interface).
106  * @param[in]   address               remote address.
107  * @param[in]   data                  data for transmission.
108  * @param[in]   dataLen               data length.
109  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
110  */
111 CAResult_t CALEClientSendUnicastMessage(const char *address, const uint8_t *data,
112                                         const uint32_t dataLen);
113
114 /**
115  * send data for multicast (interface).
116  * @param[in]   data                  data for transmission.
117  * @param[in]   dataLen               data length.
118  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
119  */
120 CAResult_t CALEClientSendMulticastMessage(const uint8_t *data, const uint32_t dataLen);
121
122 /**
123  * start unicast server.
124  * @param[in]   address               remote address.
125  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
126  */
127 CAResult_t CALEClientStartUnicastServer(const char *address);
128
129 /**
130  * start multicast server (start discovery).
131  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
132  */
133 CAResult_t CALEClientStartMulticastServer();
134
135 /**
136  * stop unicast server.
137  */
138 void CALEClientStopUnicastServer();
139
140 /**
141  * stop multicast server (stop discovery).
142  */
143 void CALEClientStopMulticastServer();
144
145 /**
146  * set this callback for receiving data packets from peer devices.
147  * @param[in]   callback              callback to be notified on reception of
148  *                                    unicast/multicast data packets.
149  */
150 void CALEClientSetCallback(CAPacketReceiveCallback callback);
151
152 /**
153  * waiting to get scanned device from BT Platform.
154  * if there is no scanned device in the list.
155  * @param[in]   env                   JNI interface pointer.
156  * @param[in]   address               LE address.
157  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
158  */
159 CAResult_t CALEClientIsThereScannedDevices(JNIEnv *env, const char* address);
160
161 /**
162  * send data for unicast (implement).
163  * @param[in]   address               remote address.
164  * @param[in]   data                  data for transmission.
165  * @param[in]   dataLen               data length.
166  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
167  */
168 CAResult_t CALEClientSendUnicastMessageImpl(const char *address, const uint8_t *data,
169                                             const uint32_t dataLen);
170
171 /**
172  * send data for multicast (implement).
173  * @param[in]   env                   JNI interface pointer.
174  * @param[in]   data                  data for transmission.
175  * @param[in]   dataLen               data length.
176  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
177  */
178 CAResult_t CALEClientSendMulticastMessageImpl(JNIEnv *env, const uint8_t *data,
179                                               const uint32_t dataLen);
180
181 /**
182  * send data to remote device.
183  * if it isn't connected yet. connect LE before try to send data.
184  * @param[in]   env                   JNI interface pointer.
185  * @param[in]   device                bluetooth device object.
186  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
187  */
188 CAResult_t CALEClientSendData(JNIEnv *env, jobject device);
189
190 /**
191  * get address from bluetooth gatt object.
192  * @param[in]   env                   JNI interface pointer.
193  * @param[in]   gatt                  Gatt profile object.
194  * @return  bluetooth address.
195  */
196 jstring CALEClientGetAddressFromGattObj(JNIEnv *env, jobject gatt);
197
198 /**
199  * get remote address from bluetooth socket object.
200  * @param[in]   env                   JNI interface pointer.
201  * @param[in]   bluetoothSocketObj    bluetooth socket.
202  * @return  bluetooth address.
203  */
204 jstring CALEClientGetRemoteAddress(JNIEnv *env, jobject bluetoothSocketObj);
205
206 /**
207  * close gatt.
208  * @param[in]   env                   JNI interface pointer.
209  * @param[in]   bluetoothGatt         gatt profile object.
210  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
211  */
212 CAResult_t CALEClientGattClose(JNIEnv *env, jobject bluetoothGatt);
213
214 /**
215  * start to scan whole bluetooth devices (interface).
216  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
217  */
218 CAResult_t CALEClientStartScan();
219
220 /**
221  * start to scan whole bluetooth devices (implement).
222  * @param[in]   env                   JNI interface pointer.
223  * @param[in]   callback              callback to receive device object by scanning.
224  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
225  */
226 CAResult_t CALEClientStartScanImpl(JNIEnv *env, jobject callback);
227
228 /**
229  * start to scan whole bluetooth devices for android API level 21 (implement).
230  * @param[in]   env                   JNI interface pointer.
231  * @param[in]   callback              callback to receive device object by scanning.
232  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
233  */
234 CAResult_t CALEClientStartScanImplForV21(JNIEnv *env, jobject callback);
235
236 /**
237  * start to scan target bluetooth devices for service uuid (implement).
238  * @param[in]   env                   JNI interface pointer.
239  * @param[in]   uuids                 target UUID.
240  * @param[in]   callback              callback to receive device object by scanning.
241  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
242  */
243 CAResult_t CALEClientStartScanWithUUIDImpl(JNIEnv *env, jobjectArray uuids,
244                                            jobject callback);
245
246 /**
247  * start to scan target bluetooth devices for service uuid for android API level 21 (implement).
248  * @param[in]   env                   JNI interface pointer.
249  * @param[in]   uuids                 target UUID.
250  * @param[in]   callback              callback to receive device object by scanning.
251  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
252  */
253 CAResult_t CALEClientStartScanWithUUIDImplForV21(JNIEnv *env, jobjectArray uuids,
254                                                  jobject callback);
255
256 /**
257  * get uuid object.
258  * @param[in]   env                   JNI interface pointer.
259  * @param[in]   uuid                  uuid.
260  * @return  uuid object.
261  */
262 jobject CALEClientGetUUIDObject(JNIEnv *env, const char *uuid);
263
264 /**
265  * stop scan (interface).
266  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
267  */
268 CAResult_t CALEClientStopScan();
269
270 /**
271  * stop scan (implement).
272  * @param[in]   env                   JNI interface pointer.
273  * @param[in]   callback              callback to receive device object by scanning.
274  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
275  */
276 CAResult_t CALEClientStopScanImpl(JNIEnv *env, jobject callback);
277
278 /**
279  * stop scan for android API level 21(implement).
280  * @param[in]   env                   JNI interface pointer.
281  * @param[in]   callback              callback to receive device object by scanning.
282  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
283  */
284 CAResult_t CALEClientStopScanImplForV21(JNIEnv *env, jobject callback);
285
286 /**
287  * connect to gatt server hosted.
288  * @param[in]   env                   JNI interface pointer.
289  * @param[in]   bluetoothDevice       bluetooth Device object.
290  * @param[in]   autoconnect           whether to directly connect to the remote device(false) or
291  *                                     to automatically connect as soon as the remote device
292  *                                     becomes available.
293  * @return  gatt object
294  */
295 jobject CALEClientConnect(JNIEnv *env, jobject bluetoothDevice, jboolean autoconnect);
296
297 /**
298  * disconnect to gatt server by a target device.
299  * @param[in]   env                   JNI interface pointer.
300  * @param[in]   bluetoothGatt         Gatt profile object.
301  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
302  */
303 CAResult_t CALEClientDisconnect(JNIEnv *env, jobject bluetoothGatt);
304
305 /**
306  * disconnect to gatt server by whole devices.
307  * @param[in]   env                   JNI interface pointer.
308  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
309  */
310 CAResult_t CALEClientDisconnectAll(JNIEnv *env);
311
312 /**
313  * disconnect to gatt server by selected address.
314  * @param[in]   env                   JNI interface pointer.
315  * @param[in]   remoteAddress         remote address.
316  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
317  */
318 CAResult_t CALEClientDisconnectforAddress(JNIEnv *env, jstring remoteAddress);
319
320 /**
321  * request MTU size negotiation to server.
322  * @param[in]   env                   JNI interface pointer.
323  * @param[in]   bluetoothGatt         gatt object.
324  * @param[in]   size                  MTU size.
325  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
326  */
327 CAResult_t CALEClientRequestMTU(JNIEnv *env, jobject bluetoothGatt, jint size);
328 /**
329  * start discovery server.
330  * @param[in]   env                   JNI interface pointer.
331  * @param[in]   bluetoothGatt         Gatt profile object.
332  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
333  */
334 CAResult_t CALEClientDiscoverServices(JNIEnv *env, jobject bluetoothGatt);
335
336 /**
337  * call CALESetValueAndWriteCharacteristic when connection is successful.
338  * @param[in]   env                   JNI interface pointer.
339  * @param[in]   gatt                  Gatt profile object.
340  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
341  */
342 CAResult_t CALEClientWriteCharacteristic(JNIEnv *env, jobject gatt);
343
344 /**
345  * create GattCharacteristic and call CALEClientWriteCharacteristicImpl
346  * for request to write gatt characteristic.
347  * @param[in]   env                   JNI interface pointer.
348  * @param[in]   gatt                  Gatt profile object.
349  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
350  */
351 CAResult_t CALESetValueAndWriteCharacteristic(JNIEnv *env, jobject gatt);
352
353 /**
354  * request to write gatt characteristic.
355  * @param[in]   env                   JNI interface pointer.
356  * @param[in]   bluetoothGatt         Gatt profile object.
357  * @param[in]   gattCharacteristic    characteristic object that contain data to send.
358  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
359  */
360 CAResult_t CALEClientWriteCharacteristicImpl(JNIEnv *env, jobject bluetoothGatt,
361                                              jobject gattCharacteristic);
362
363 /**
364  * request to read gatt characteristic.
365  * @param[in]   env                   JNI interface pointer.
366  * @param[in]   bluetoothGatt         Gatt profile object.
367  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
368  */
369 CAResult_t CALEClientReadCharacteristic(JNIEnv *env, jobject bluetoothGatt);
370
371 /**
372  * enable notification for a target device.
373  * @param[in]   env                   JNI interface pointer.
374  * @param[in]   bluetoothGatt         Gatt profile object.
375  * @param[in]   characteristic        Characteristic object.
376  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
377  */
378 CAResult_t CALEClientSetCharacteristicNotification(JNIEnv *env, jobject bluetoothGatt,
379                                                   jobject characteristic);
380
381 /**
382  * create gatt characteristic object.
383  * @param[in]   env                   JNI interface pointer.
384  * @param[in]   bluetoothGatt         Gatt profile object.
385  * @param[in]   data                  for make Characteristic with data.
386  * @return  Gatt Characteristic object.
387  */
388 jobject CALEClientCreateGattCharacteristic(JNIEnv *env, jobject bluetoothGatt, jbyteArray data);
389
390 /**
391  * get gatt service.
392  * @param[in]   env                   JNI interface pointer.
393  * @param[in]   bluetoothGatt         Gatt profile object.
394  * @param[in]   characterUUID         for make BluetoothGattCharacteristic object.
395  * @return  Gatt Service.
396  */
397 jobject CALEClientGetGattService(JNIEnv *env, jobject bluetoothGatt, jstring characterUUID);
398
399 /**
400  * get value from characteristic.
401  * @param[in]   env                   JNI interface pointer.
402  * @param[in]   characteristic        Characteristic object.
403  * @return  value in characteristic.
404  */
405 jbyteArray CALEClientGetValueFromCharacteristic(JNIEnv *env, jobject characteristic);
406
407 /**
408  * create UUID List.
409  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
410  */
411 CAResult_t CALEClientCreateUUIDList();
412
413 /**
414  * set UUID to descriptor.
415  * @param[in]   env                   JNI interface pointer.
416  * @param[in]   bluetoothGatt         Gatt profile object.
417  * @param[in]   characteristic        Characteristic object.
418  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
419  */
420 CAResult_t CALEClientSetUUIDToDescriptor(JNIEnv *env, jobject bluetoothGatt,
421                                          jobject characteristic);
422
423 /**
424  * add device object to scan device list.
425  * @param[in]   env                   JNI interface pointer.
426  * @param[in]   device                bluetooth device object.
427  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
428  */
429 CAResult_t CALEClientAddScanDeviceToList(JNIEnv *env, jobject device);
430
431 /**
432  * check whether the device exist in list or not.
433  * @param[in]   env                   JNI interface pointer.
434  * @param[in]   remoteAddress         remote address.
435  * @return  true or false.
436  */
437 bool CALEClientIsDeviceInScanDeviceList(JNIEnv *env, const char *remoteAddress);
438
439 /**
440  * remove all devices in scan device list.
441  * @param[in]   env                   JNI interface pointer.
442  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
443  */
444 CAResult_t CALEClientRemoveAllScanDevices(JNIEnv *env);
445
446 /**
447  * remove target device in scan device list.
448  * @param[in]   env                   JNI interface pointer.
449  * @param[in]   remoteAddress         remote address.
450  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
451  */
452 CAResult_t CALEClientRemoveDeviceInScanDeviceList(JNIEnv *env, jstring remoteAddress);
453
454 /**
455  * add gatt object to gatt object list.
456  * @param[in]   env                   JNI interface pointer.
457  * @param[in]   gatt                  Gatt profile object.
458  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
459  */
460 CAResult_t CALEClientAddGattobjToList(JNIEnv *env, jobject gatt);
461
462 /**
463  * check whether the gatt object exist in list or not.
464  * @param[in]   env                   JNI interface pointer.
465  * @param[in]   remoteAddress         remote address.
466  * @return  true or false.
467  */
468 bool CALEClientIsGattObjInList(JNIEnv *env, const char *remoteAddress);
469
470 /**
471  * get the gatt object.
472  * @param[in]   env                   JNI interface pointer.
473  * @param[in]   remoteAddress         remote address.
474  * @return  gatt object.
475  */
476 jobject CALEClientGetGattObjInList(JNIEnv *env, const char* remoteAddress);
477
478 /**
479  * remove all gatt objects in gatt object list.
480  * @param[in]   env                   JNI interface pointer.
481  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
482  */
483 CAResult_t CALEClientRemoveAllGattObjs(JNIEnv *env);
484
485 /**
486  * remove target device in gatt object list.
487  * @param[in]   env                   JNI interface pointer.
488  * @param[in]   gatt                  Gatt profile object.
489  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
490  */
491 CAResult_t CALEClientRemoveGattObj(JNIEnv *env, jobject gatt);
492
493 /**
494  * remove gatt object of target device for address in gatt object list.
495  * @param[in]   env                   JNI interface pointer.
496  * @param[in]   gatt                  Gatt profile object.
497  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
498  */
499 CAResult_t CALEClientRemoveGattObjForAddr(JNIEnv *env, jstring addr);
500
501 /**
502  * get ble address from Bluetooth device.
503  * @param[in]   env                   JNI interface pointer.
504  * @param[in]   bluetoothDevice       Bluetooth device.
505  * @return  ble address.
506  */
507 jstring CALEClientGetLEAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice);
508
509 /**
510  * update new state information by Bluetooth device object.
511  * @param[in]   env                   JNI interface pointer.
512  * @param[in]   device                Bluetooth device.
513  * @param[in]   state_type            state type.
514  * @param[in]   target_state          state index to update.
515  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
516  */
517 CAResult_t CALEClientUpdateDeviceStateWithBtDevice(JNIEnv *env,
518                                                    jobject device,
519                                                    uint16_t state_type,
520                                                    uint16_t target_state);
521
522 /**
523  * set flag into State List.
524  * @param[in]   env                   JNI interface pointer.
525  * @param[in]   jni_address           remote address.
526  * @param[in]   state_idx             state index.
527  * @param[in]   flag                  auto connect flag.
528  */
529 CAResult_t CALEClientSetFlagToState(JNIEnv *env, jstring jni_address,
530                                     jint state_idx, jboolean flag);
531
532 /**
533  * get flag from State List.
534  * @param[in]   env                   JNI interface pointer.
535  * @param[in]   jni_address           remote address.
536  * @param[in]   state_idx             state index.
537  * @return  current flag;
538  */
539 jboolean CALEClientGetFlagFromState(JNIEnv *env, jstring jni_address, jint state_idx);
540
541 /**
542  * get MTU size.
543  * @param[in] address      the address of the remote device.
544  * @return  mtu size negotiated from remote device.
545  */
546 uint16_t CALEClientGetMtuSize(const char* address);
547
548 /**
549  * Reset values of device state for all of devices.
550  * this method has to be invoked when BT adapter is disabled.
551  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
552  */
553 CAResult_t CALEClientResetDeviceStateForAll();
554
555 /**
556  * create scan device list.
557  */
558 void CALEClientCreateDeviceList();
559
560 /**
561  * update the counter which data is sent to remote device.
562  * @param[in]   env                   JNI interface pointer.
563  */
564 void CALEClientUpdateSendCnt(JNIEnv *env);
565
566 /**
567  * initialize mutex.
568  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
569  */
570 CAResult_t CALEClientInitGattMutexVaraibles();
571
572 /**
573  * terminate mutex.
574  */
575 void CALEClientTerminateGattMutexVariables();
576
577 /**
578  * set send finish flag.
579  * @param[in]   flag        finish flag.
580  */
581 void CALEClientSetSendFinishFlag(bool flag);
582
583 /**
584  * close the connection of the profile proxy to the Service.
585  * @param[in]   env                   JNI interface pointer.
586  * @param[in]   gatt                  gatt profile object.
587  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
588  */
589 CAResult_t CALEClientCloseProfileProxy(JNIEnv *env, jobject gatt);
590
591 /**
592  * connect to GATT Server hosted by this device.
593  * @param[in]   env                   JNI interface pointer.
594  * @param[in]   bluetoothDevice       bluetooth device object.
595  * @param[in]   autoconnect           connect as soon as the device becomes avaiable(true).
596  * @return  gatt profile object
597  */
598 jobject CALEClientGattConnect(JNIEnv *env, jobject bluetoothDevice, jboolean autoconnect);
599
600 /**
601  * connect to GATT Server hosted by this device directly.
602  * @param[in]   env                   JNI interface pointer.
603  * @param[in]   bluetoothDevice       bluetooth device object.
604  * @param[in]   autoconnect           connect as soon as the device becomes avaiable(true).
605  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
606  */
607 CAResult_t CALEClientDirectConnect(JNIEnv *env, jobject bluetoothDevice, jboolean autoconnect);
608
609 /**
610  * check connection status.
611  * @param[in] address      the address of the remote device.
612  * @return  true or false.
613  */
614 bool CALEClientIsConnected(const char* address);
615
616 /**
617  * set new interval time and working count.
618  * @param[in]  intervalTime             interval time(Seconds).
619  * @param[in]  workingCount             working count for selected interval time.
620  * @param[in]  nextScanningStep         set next scanning state.
621  */
622 void CALEClientSetScanInterval(int32_t intervalTime, int32_t workingCount,
623                                CALEScanState_t nextScanningStep);
624
625 /**
626  * restart scanning with new interval time and working count.
627  * @param[in]  intervalTime             interval time(Seconds).
628  * @param[in]  workingCount             working count for selected interval time.
629  * @param[in]  nextScanningStep         set next scanning state.
630  */
631 void CALERestartScanWithInterval(int32_t intervalTime, int32_t workingCount,
632                                  CALEScanState_t nextScanningStep);
633
634 /**
635  * start LE scanning logic with interval time and working count.
636  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
637  */
638 CAResult_t CALEClientStartScanWithInterval();
639
640 /**
641  * stop LE scanning logic with interval time and cycle.
642  */
643 void CALEClientStopScanWithInterval();
644
645 #ifdef __cplusplus
646 } /* extern "C" */
647 #endif
648
649 #endif /* CA_LECLIENT_H_ */