{
#endif
+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_SUCCESS = 1;
static const uint16_t STATE_SEND_FAILED = 2;
-static const jint STATE_CONNECTED = 2;
-static const jint STATE_DISCONNECTED = 0;
-
typedef struct le_state_info
{
char address[CA_MACADDR_SIZE];
jint connectedState;
uint16_t notificationState;
uint16_t sendState;
+ jboolean autoConnectFlag;
} CALEState_t;
/**
* @param[in] data Data received from remote device.
* @pre Callback must be registered using CALESetCallback(CAPacketReceiveCallback callback)
*/
-typedef void (*CAPacketReceiveCallback)(const char *address, const char *data);
+typedef void (*CAPacketReceiveCallback)(const char *address, const uint8_t *data);
/**
* initialize JNI object.
/**
* initialize client for BLE.
- * @param[in] handle thread pool handle object.
* @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
-CAResult_t CALEClientInitialize(ca_thread_pool_t handle);
+CAResult_t CALEClientInitialize();
/**
* terminate client for BLE.
void CALEClientTerminate();
/**
+ * destroy interface object and terminate the interface.
+ * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+ */
+CAResult_t CALEClientDestroyJniInterface();
+
+/**
* for destroy sending routine.
* @param[in] env JNI interface pointer.
* @param[in] gatt Gatt profile object.
* @param[in] dataLen data length.
* @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
-CAResult_t CALEClientSendUnicastMessage(const char *address, const char *data,
+CAResult_t CALEClientSendUnicastMessage(const char *address, const uint8_t *data,
const uint32_t dataLen);
/**
* @param[in] dataLen data length.
* @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
-CAResult_t CALEClientSendMulticastMessage(const char *data, const uint32_t dataLen);
+CAResult_t CALEClientSendMulticastMessage(const uint8_t *data, const uint32_t dataLen);
/**
* start unicast server.
void CALEClientSetCallback(CAPacketReceiveCallback callback);
/**
+ * waiting to get scanned device from BT Platform.
+ * if there is no scanned device in the list.
+ * @param[in] env JNI interface pointer.
+ * @param[in] address LE address.
+ * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+ */
+CAResult_t CALEClientIsThereScannedDevices(JNIEnv *env, const char* address);
+
+/**
* send data for unicast (implement).
* @param[in] address remote address.
* @param[in] data data for transmission.
* @param[in] dataLen data length.
* @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
-CAResult_t CALEClientSendUnicastMessageImpl(const char *address, const char *data,
+CAResult_t CALEClientSendUnicastMessageImpl(const char *address, const uint8_t *data,
const uint32_t dataLen);
/**
* @param[in] dataLen data length.
* @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
-CAResult_t CALEClientSendMulticastMessageImpl(JNIEnv *env, const char *data,
+CAResult_t CALEClientSendMulticastMessageImpl(JNIEnv *env, const uint8_t *data,
const uint32_t dataLen);
/**
CAResult_t CALEClientStopScan();
/**
+ * set ble scanning flag.
+ * @param[in] flag scan flag.
+ */
+void CALEClientSetScanFlag(bool flag);
+
+/**
* stop scan (implement).
* @param[in] env JNI interface pointer.
* @param[in] callback callback to receive device object by scanning.
CAResult_t CALEClientStopScanImpl(JNIEnv *env, jobject callback);
/**
+ * set auto connect flag for connectGatt API.
+ * @param[in] env JNI interface pointer.
+ * @param[in] jni_address remote address.
+ * @param[in] flag auto connect flag.
+ */
+CAResult_t CALEClientSetAutoConnectFlag(JNIEnv *env, jstring jni_address, jboolean flag);
+
+/**
+ * get auto connect flag.
+ * @param[in] env JNI interface pointer.
+ * @param[in] jni_address remote address.
+ * @return current auto connect flag;
+ */
+jboolean CALEClientGetAutoConnectFlag(JNIEnv *env, jstring jni_address);
+
+/**
* connect to gatt server hosted.
* @param[in] env JNI interface pointer.
* @param[in] bluetoothDevice bluetooth Device object.
* @param[in] autoconnect whether to directly connect to the remote device(false) or
* to automatically connect as soon as the remote device
* becomes available.
- * @param[in] callback callback for connection state change.
- * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+ * @return gatt object
*/
-CAResult_t CALEClientConnect(JNIEnv *env, jobject bluetoothDevice, jboolean autoconnect,
- jobject callback);
+jobject CALEClientConnect(JNIEnv *env, jobject bluetoothDevice, jboolean autoconnect);
/**
* disconnect to gatt server by a target device.
CAResult_t CALEClientDisconnectAll(JNIEnv *env);
/**
+ * disconnect to gatt server by selected address.
+ * @param[in] env JNI interface pointer.
+ * @param[in] remoteAddress remote address.
+ * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+ */
+CAResult_t CALEClientDisconnectforAddress(JNIEnv *env, jstring remoteAddress);
+
+/**
* start discovery server.
* @param[in] env JNI interface pointer.
* @param[in] bluetoothGatt Gatt profile object.
CAResult_t CALEClientDiscoverServices(JNIEnv *env, jobject bluetoothGatt);
/**
+ * call CALESetValueAndWriteCharacteristic when connection is successful.
+ * @param[in] env JNI interface pointer.
+ * @param[in] gatt Gatt profile object.
+ * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+ */
+CAResult_t CALEClientWriteCharacteristic(JNIEnv *env, jobject gatt);
+
+/**
* create GattCharacteristic and call CALEClientWriteCharacteristicImpl
* for request to write gatt characteristic.
* @param[in] env JNI interface pointer.
* @param[in] gatt Gatt profile object.
* @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
-CAResult_t CALEClientWriteCharacteristic(JNIEnv *env, jobject gatt);
+CAResult_t CALESetValueAndWriteCharacteristic(JNIEnv *env, jobject gatt);
/**
* request to write gatt characteristic.
CAResult_t CALEClientRemoveGattObjForAddr(JNIEnv *env, jstring addr);
/**
+ * get ble address from Bluetooth device.
+ * @param[in] env JNI interface pointer.
+ * @param[in] bluetoothDevice Bluetooth device.
+ * @return ble address.
+ */
+jstring CALEClientGetLEAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice);
+
+/**
* update new state information.
* @param[in] address remote address.
* @param[in] connectedState connection state.
CAResult_t CALEClientRemoveAllDeviceState();
/**
+ * 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 CALEClientResetDeviceStateForAll();
+
+/**
* remove the device state for a remote device.
* @param[in] remoteAddress remote address.
* @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
void CALEClientCreateDeviceList();
/**
- * Reordering for device state list.
- * @param[in] index index of device list that want to reordering.
- * @param[in] list the list to reorder.
- * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
- */
-CAResult_t CALEClientReorderingList(uint32_t index, u_arraylist_t *list);
-
-/**
* update the counter which data is sent to remote device.
* @param[in] env JNI interface pointer.
*/
*/
void CALEClientSetSendFinishFlag(bool flag);
+/**
+ * close the connection of the profile proxy to the Service.
+ * @param[in] env JNI interface pointer.
+ * @param[in] gatt gatt profile object.
+ * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+ */
+CAResult_t CALEClientCloseProfileProxy(JNIEnv *env, jobject gatt);
+
+/**
+ * connect to GATT Server hosted by this device.
+ * @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 gatt profile object
+ */
+jobject CALEClientGattConnect(JNIEnv *env, jobject bluetoothDevice, jboolean autoconnect);
+
#ifdef __cplusplus
} /* extern "C" */
#endif