replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / resource / csdk / connectivity / src / bt_le_adapter / android / caleclient.h
index d42b6f2..e05a0d4 100644 (file)
@@ -25,6 +25,7 @@
 #ifndef CA_LECLIENT_H_
 #define CA_LECLIENT_H_
 
+#include "calestate.h"
 #include "cacommon.h"
 #include "cathreadpool.h"
 #include "uarraylist.h"
@@ -35,29 +36,14 @@ extern "C"
 {
 #endif
 
-static const uint16_t GATT_ERROR = 133;
-
-static const uint16_t STATE_SEND_NONE = 1;
-static const uint16_t STATE_SEND_SUCCESS = 2;
-static const uint16_t STATE_SEND_FAIL = 3;
-static const uint16_t STATE_SENDING = 4;
-
-typedef struct le_state_info
-{
-    char address[CA_MACADDR_SIZE];
-    uint16_t connectedState;
-    uint16_t sendState;
-    jboolean autoConnectFlag;
-    jboolean isDescriptorFound;
-} CALEState_t;
-
 /**
  * BLE Scanning State.
  */
 typedef enum
 {
     BLE_SCAN_ENABLE = 0, /**< BLE scan is working */
-    BLE_SCAN_DISABLE     /**< BLE scan is not working */
+    BLE_SCAN_DISABLE,    /**< BLE scan is not working */
+    BLE_SCAN_NONE        /**< Initialize State */
 } CALEScanState_t;
 
 /**
@@ -109,6 +95,13 @@ CAResult_t CALEClientDestroyJniInterface();
 void CALEClientSendFinish(JNIEnv *env, jobject gatt);
 
 /**
+ * send negotiation message after gatt connection is done.
+ * @param[in]   address               remote address.
+ * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+ */
+CAResult_t CALEClientSendNegotiationMessage(const char* address);
+
+/**
  * send data for unicast (interface).
  * @param[in]   address               remote address.
  * @param[in]   data                  data for transmission.
@@ -233,6 +226,14 @@ CAResult_t CALEClientStartScan();
 CAResult_t CALEClientStartScanImpl(JNIEnv *env, jobject callback);
 
 /**
+ * start to scan whole bluetooth devices for android API level 21 (implement).
+ * @param[in]   env                   JNI interface pointer.
+ * @param[in]   callback              callback to receive device object by scanning.
+ * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+ */
+CAResult_t CALEClientStartScanImplForV21(JNIEnv *env, jobject callback);
+
+/**
  * start to scan target bluetooth devices for service uuid (implement).
  * @param[in]   env                   JNI interface pointer.
  * @param[in]   uuids                 target UUID.
@@ -243,6 +244,16 @@ CAResult_t CALEClientStartScanWithUUIDImpl(JNIEnv *env, jobjectArray uuids,
                                            jobject callback);
 
 /**
+ * start to scan target bluetooth devices for service uuid for android API level 21 (implement).
+ * @param[in]   env                   JNI interface pointer.
+ * @param[in]   uuids                 target UUID.
+ * @param[in]   callback              callback to receive device object by scanning.
+ * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+ */
+CAResult_t CALEClientStartScanWithUUIDImplForV21(JNIEnv *env, jobjectArray uuids,
+                                                 jobject callback);
+
+/**
  * get uuid object.
  * @param[in]   env                   JNI interface pointer.
  * @param[in]   uuid                  uuid.
@@ -265,23 +276,12 @@ CAResult_t CALEClientStopScan();
 CAResult_t CALEClientStopScanImpl(JNIEnv *env, jobject callback);
 
 /**
- * set flag into State List.
- * @param[in]   env                   JNI interface pointer.
- * @param[in]   jni_address           remote address.
- * @param[in]   state_idx             state index.
- * @param[in]   flag                  auto connect flag.
- */
-CAResult_t CALEClientSetFlagToState(JNIEnv *env, jstring jni_address,
-                                    jint state_idx, jboolean flag);
-
-/**
- * get flag from State List.
+ * stop scan for android API level 21(implement).
  * @param[in]   env                   JNI interface pointer.
- * @param[in]   jni_address           remote address.
- * @param[in]   state_idx             state index.
- * @return  current flag;
+ * @param[in]   callback              callback to receive device object by scanning.
+ * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
  */
-jboolean CALEClientGetFlagFromState(JNIEnv *env, jstring jni_address, jint state_idx);
+CAResult_t CALEClientStopScanImplForV21(JNIEnv *env, jobject callback);
 
 /**
  * connect to gatt server hosted.
@@ -318,6 +318,14 @@ CAResult_t CALEClientDisconnectAll(JNIEnv *env);
 CAResult_t CALEClientDisconnectforAddress(JNIEnv *env, jstring remoteAddress);
 
 /**
+ * request MTU size negotiation to server.
+ * @param[in]   env                   JNI interface pointer.
+ * @param[in]   bluetoothGatt         gatt object.
+ * @param[in]   size                  MTU size.
+ * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+ */
+CAResult_t CALEClientRequestMTU(JNIEnv *env, jobject bluetoothGatt, jint size);
+/**
  * start discovery server.
  * @param[in]   env                   JNI interface pointer.
  * @param[in]   bluetoothGatt         Gatt profile object.
@@ -499,58 +507,50 @@ CAResult_t CALEClientRemoveGattObjForAddr(JNIEnv *env, jstring addr);
 jstring CALEClientGetLEAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice);
 
 /**
- * update new state information.
- * @param[in]   address               remote address.
+ * update new state information by Bluetooth device object.
+ * @param[in]   env                   JNI interface pointer.
+ * @param[in]   device                Bluetooth device.
  * @param[in]   state_type            state type.
  * @param[in]   target_state          state index to update.
  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
  */
-CAResult_t CALEClientUpdateDeviceState(const char* address, uint16_t state_type,
-                                       uint16_t target_state);
+CAResult_t CALEClientUpdateDeviceStateWithBtDevice(JNIEnv *env,
+                                                   jobject device,
+                                                   uint16_t state_type,
+                                                   uint16_t target_state);
 
 /**
- * check whether the remote address is existed or not.
- * @param[in]   address               remote address.
- * @return  true or false.
+ * set flag into State List.
+ * @param[in]   env                   JNI interface pointer.
+ * @param[in]   jni_address           remote address.
+ * @param[in]   state_idx             state index.
+ * @param[in]   flag                  auto connect flag.
  */
-bool CALEClientIsDeviceInList(const char *remoteAddress);
+CAResult_t CALEClientSetFlagToState(JNIEnv *env, jstring jni_address,
+                                    jint state_idx, jboolean flag);
 
 /**
- * remove all device states.
- * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+ * get flag from State List.
+ * @param[in]   env                   JNI interface pointer.
+ * @param[in]   jni_address           remote address.
+ * @param[in]   state_idx             state index.
+ * @return  current flag;
  */
-CAResult_t CALEClientRemoveAllDeviceState();
+jboolean CALEClientGetFlagFromState(JNIEnv *env, jstring jni_address, jint state_idx);
 
 /**
- * Reset values of device state for all of devices.
- * this method has to be invoked when BT adapter is disabled.
- * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+ * get MTU size.
+ * @param[in] address      the address of the remote device.
+ * @return  mtu size negotiated from remote device.
  */
-CAResult_t CALEClientResetDeviceStateForAll();
+uint16_t CALEClientGetMtuSize(const char* address);
 
 /**
- * remove the device state for a remote device.
- * @param[in]   remoteAddress         remote address.
+ * Reset values of device state for all of devices.
+ * this method has to be invoked when BT adapter is disabled.
  * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
  */
-CAResult_t CALEClientRemoveDeviceState(const char* remoteAddress);
-
-/**
- * get state information for a remote device.
- * @param[in]   remoteAddress         remote address.
- * @return  CALEState_t.
- */
-CALEState_t* CALEClientGetStateInfo(const char* remoteAddress);
-
-/**
- * check whether the remote address has same state with target state.
- * @param[in]   remoteAddress         remote address.
- * @param[in]   state_type            state_type.
- * @param[in]   target_state          state index to check.
- * @return  true or false.
- */
-bool CALEClientIsValidState(const char* remoteAddress, uint16_t state_type,
-                            uint16_t target_state);
+CAResult_t CALEClientResetDeviceStateForAll();
 
 /**
  * create scan device list.
@@ -607,6 +607,13 @@ jobject CALEClientGattConnect(JNIEnv *env, jobject bluetoothDevice, jboolean aut
 CAResult_t CALEClientDirectConnect(JNIEnv *env, jobject bluetoothDevice, jboolean autoconnect);
 
 /**
+ * check connection status.
+ * @param[in] address      the address of the remote device.
+ * @return  true or false.
+ */
+bool CALEClientIsConnected(const char* address);
+
+/**
  * set new interval time and working count.
  * @param[in]  intervalTime             interval time(Seconds).
  * @param[in]  workingCount             working count for selected interval time.