}
CASetAutoConnectionDeviceInfo(address);
+
+ (*env)->ReleaseStringUTFChars(env, jaddress, address);
}
JNIEXPORT void JNICALL
}
CAUnsetAutoConnectionDeviceInfo(address);
+
+ (*env)->ReleaseStringUTFChars(env, jaddress, address);
}
JNIEXPORT void JNICALL
CAResult_t CARegisterNetworkMonitorHandler(CAAdapterStateChangedCB adapterStateCB,
CAConnectionStateChangedCB connStateCB);
+/**
+ * Set device to handle for auto connection.
+ * @param[in] address LE address to set.
+ *
+ * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED.
+ */
CAResult_t CASetAutoConnectionDeviceInfo(const char* address);
+/**
+ * Unset device to handle for auto connection.
+ * @param[in] address LE address to unset.
+ *
+ * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED.
+ */
CAResult_t CAUnsetAutoConnectionDeviceInfo(const char* address);
#ifdef __ANDROID__
// connection request
jobject newGatt = CALEClientConnect(env, device,
- CALEClientGetAutoConnectFlag(env, jni_address));
+ JNI_FALSE);
if (NULL == newGatt)
{
OIC_LOG(ERROR, TAG, "CALEClientConnect has failed");
}
OIC_LOG(DEBUG, TAG, "start to connect LE");
- jobject gatt = CALEClientConnect(env, device, JNI_TRUE);
+ jobject gatt = CALEClientConnect(env, device,
+ CALEClientGetAutoConnectFlag(env, jni_address));
if (NULL == gatt)
{
OIC_LOG(ERROR, TAG, "CALEClientConnect has failed");
continue;
}
(*env)->DeleteGlobalRef(env, jarrayObj);
+ jarrayObj = NULL;
}
OICFree(g_deviceList);
{
OIC_LOG_V(DEBUG, TAG, "remove object : %s", remoteAddress);
(*env)->DeleteGlobalRef(env, jarrayObj);
+ jarrayObj = NULL;
(*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
(*env)->ReleaseStringUTFChars(env, address, remoteAddress);
continue;
}
(*env)->DeleteGlobalRef(env, jarrayObj);
+ jarrayObj = NULL;
}
OICFree(g_gattObjectList);
{
OIC_LOG_V(DEBUG, TAG, "remove object : %s", remoteAddress);
(*env)->DeleteGlobalRef(env, jarrayObj);
+ jarrayObj = NULL;
(*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
(*env)->ReleaseStringUTFChars(env, jni_remoteAddress, remoteAddress);
{
OIC_LOG_V(DEBUG, TAG, "remove object : %s", remoteAddress);
(*env)->DeleteGlobalRef(env, jarrayObj);
-
+ jarrayObj = NULL;
(*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
(*env)->ReleaseStringUTFChars(env, addr, remoteAddress);
if (NULL == u_arraylist_remove(g_gattObjectList, index))
goto error_exit;
}
- jobject newGatt = CALEClientConnect(env, btObject,
- CALEClientGetAutoConnectFlag(env, leAddress));
+ jobject newGatt = CALEClientConnect(env, btObject, JNI_TRUE);
if (!newGatt)
{
OIC_LOG(ERROR, TAG, "CALEClientConnect has failed");
goto error_exit;
}
+
return;
}
else
#ifndef SINGLE_THREAD
#include "caqueueingthread.h"
#endif
+#if defined(__TIZEN__) || defined(__ANDROID__)
+#include "caleserver.h"
+#include "caleclient.h"
+#endif
#include "oic_malloc.h"
#include "oic_string.h"
#include "caremotehandler.h"
/**
* Logging tag for module name.
*/
-#define CALEADAPTER_TAG "OIC_LE_ADAP"
+#define CALEADAPTER_TAG "OIC_CA_LE_ADAP"
/**
* The MTU supported for BLE adapter
*/
static void CALEDataDestroyer(void *data, uint32_t size);
+#ifndef SINGLE_THREAD
+/**
+ * remove request or response data of send queue.
+ *
+ * @param[in] queueHandle queue to process the outgoing packets.
+ * @param[in] mutex mutex related to sender for client / server.
+ * @param[in] address target address to remove data in queue.
+ */
+static void CALERemoveSendQueueData(CAQueueingThread_t *queueHandle,
+ ca_mutex mutex,
+ const char* address);
+#endif
+
static CAResult_t CAInitLEServerQueues()
{
OIC_LOG(DEBUG, CALEADAPTER_TAG, "IN");
}
}
- if(g_bleServerSenderInfo)
+ // remove data of send queue.
+ if (g_bleClientSendQueueHandle)
{
- CABLESenderInfo_t *senderInfo = NULL;
- uint32_t senderIndex = 0;
-
- if(CA_STATUS_OK == CALEGetSenderInfo(address, g_bleServerSenderInfo, &senderInfo,
- &senderIndex))
- {
- u_arraylist_remove(g_bleServerSenderInfo, senderIndex);
- OICFree(senderInfo->defragData);
- OICFree(senderInfo->remoteEndpoint);
- OICFree(senderInfo);
+ CALERemoveSendQueueData(g_bleClientSendQueueHandle,
+ g_bleClientSendDataMutex,
+ address);
+ }
- OIC_LOG(DEBUG, CALEADAPTER_TAG, "SenderInfo is removed for disconnection");
- }
- else
- {
- OIC_LOG(DEBUG, CALEADAPTER_TAG, "SenderInfo doesn't exist");
- }
+ if (g_bleServerSendQueueHandle)
+ {
+ CALERemoveSendQueueData(g_bleServerSendQueueHandle,
+ g_bleServerSendDataMutex,
+ address);
}
#endif
}
OIC_LOG(DEBUG, CALEADAPTER_TAG, "CALEErrorHandler OUT");
}
+
+#ifndef SINGLE_THREAD
+static void CALERemoveSendQueueData(CAQueueingThread_t *queueHandle, ca_mutex mutex,
+ const char* address)
+{
+ OIC_LOG(DEBUG, CALEADAPTER_TAG, "CALERemoveSendQueueData");
+
+ VERIFY_NON_NULL_VOID(queueHandle, CALEADAPTER_TAG, "queueHandle");
+ VERIFY_NON_NULL_VOID(address, CALEADAPTER_TAG, "address");
+
+ ca_mutex_lock(mutex);
+ while (u_queue_get_size(queueHandle->dataQueue) > 0)
+ {
+ OIC_LOG(DEBUG, CALEADAPTER_TAG, "get data from queue");
+ u_queue_message_t *message = u_queue_get_element(queueHandle->dataQueue);
+ if (NULL != message)
+ {
+ CALEData_t *bleData = (CALEData_t *) message->msg;
+ if (bleData && bleData->remoteEndpoint)
+ {
+ if (!strcmp(bleData->remoteEndpoint->addr, address))
+ {
+ OIC_LOG(DEBUG, CALEADAPTER_TAG, "found the message of disconnected device");
+ if (NULL != queueHandle->destroy)
+ {
+ queueHandle->destroy(message->msg, message->size);
+ }
+ else
+ {
+ OICFree(message->msg);
+ }
+
+ OICFree(message);
+ }
+ }
+ }
+ }
+ ca_mutex_unlock(mutex);
+}
+#endif