Imported Upstream version 1.1.1
[platform/upstream/iotivity.git] / resource / csdk / connectivity / src / bt_le_adapter / android / caleclient.h
index 10066e1..3dc64f6 100644 (file)
@@ -37,19 +37,15 @@ extern "C"
 
 static const uint16_t GATT_ERROR = 133;
 
-static const uint16_t STATE_CHARACTER_SET = 2;
-static const uint16_t STATE_CHARACTER_UNSET = 1;
-static const uint16_t STATE_CHARACTER_NO_CHANGE = 0;
-
-static const uint16_t STATE_SEND_NONE = 0;
-static const uint16_t STATE_SEND_SUCCESS = 1;
-static const uint16_t STATE_SEND_FAILED = 2;
+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];
-    jint connectedState;
-    uint16_t notificationState;
+    uint16_t connectedState;
     uint16_t sendState;
     jboolean autoConnectFlag;
 } CALEState_t;
@@ -180,13 +176,6 @@ CAResult_t CALEClientSendMulticastMessageImpl(JNIEnv *env, const uint8_t *data,
                                               const uint32_t dataLen);
 
 /**
- * check whether it is connected or not with remote address.
- * @param[in]   address               remote address.
- * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
- */
-CAResult_t CALECheckSendState(const char* address);
-
-/**
  * send data to remote device.
  * if it isn't connected yet. connect LE before try to send data.
  * @param[in]   env                   JNI interface pointer.
@@ -272,20 +261,23 @@ void CALEClientSetScanFlag(bool flag);
 CAResult_t CALEClientStopScanImpl(JNIEnv *env, jobject callback);
 
 /**
- * set auto connect flag for connectGatt API.
+ * 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 CALEClientSetAutoConnectFlag(JNIEnv *env, jstring jni_address, jboolean flag);
+CAResult_t CALEClientSetFlagToState(JNIEnv *env, jstring jni_address,
+                                    jint state_idx, jboolean flag);
 
 /**
- * get auto connect flag.
+ * get flag from State List.
  * @param[in]   env                   JNI interface pointer.
  * @param[in]   jni_address           remote address.
- * @return  current auto connect flag;
+ * @param[in]   state_idx             state index.
+ * @return  current flag;
  */
-jboolean CALEClientGetAutoConnectFlag(JNIEnv *env, jstring jni_address);
+jboolean CALEClientGetFlagFromState(JNIEnv *env, jstring jni_address, jint state_idx);
 
 /**
  * connect to gatt server hosted.
@@ -505,20 +497,12 @@ jstring CALEClientGetLEAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice)
 /**
  * update new state information.
  * @param[in]   address               remote address.
- * @param[in]   connectedState        connection state.
- * @param[in]   notificationState     whether characteristic notification already set or not.
- * @param[in]   sendState             whether sending was success or not.
+ * @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, uint32_t connectedState,
-                                       uint16_t notificationState, uint16_t sendState);
-
-/**
- * add new state to state list.
- * @param[in]   state                 new state.
- * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
- */
-CAResult_t CALEClientAddDeviceStateToList(CALEState_t* state);
+CAResult_t CALEClientUpdateDeviceState(const char* address, uint16_t state_type,
+                                       uint16_t target_state);
 
 /**
  * check whether the remote address is existed or not.
@@ -555,18 +539,14 @@ CAResult_t CALEClientRemoveDeviceState(const char* remoteAddress);
 CALEState_t* CALEClientGetStateInfo(const char* remoteAddress);
 
 /**
- * check whether the remote address is connected or not.
- * @param[in]   remoteAddress         remote address.
- * @return  true or false.
- */
-bool CALEClientIsConnectedDevice(const char* remoteAddress);
-
-/**
- * check whether the remote address set CharacteristicNotification or not.
+ * 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 CALEClientIsSetCharacteristic(const char* remoteAddress);
+bool CALEClientIsValidState(const char* remoteAddress, uint16_t state_type,
+                            uint16_t target_state);
 
 /**
  * create scan device list.
@@ -613,6 +593,15 @@ CAResult_t CALEClientCloseProfileProxy(JNIEnv *env, jobject gatt);
  */
 jobject CALEClientGattConnect(JNIEnv *env, jobject bluetoothDevice, jboolean autoconnect);
 
+/**
+ * connect to GATT Server hosted by this device directly.
+ * @param[in]   env                   JNI interface pointer.
+ * @param[in]   bluetoothDevice       bluetooth device object.
+ * @param[in]   autoconnect           connect as soon as the device becomes avaiable(true).
+ * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+ */
+CAResult_t CALEClientDirectConnect(JNIEnv *env, jobject bluetoothDevice, jboolean autoconnect);
+
 #ifdef __cplusplus
 } /* extern "C" */
 #endif