{
#endif /* __cplusplus */
-typedef struct ca_mutex_internal *ca_mutex;
-typedef struct ca_cond_internal *ca_cond;
-typedef struct ca_thread_internal *ca_thread;
+typedef struct oc_mutex_internal *oc_mutex;
+typedef struct oc_cond_internal *oc_cond;
+typedef struct oc_thread_internal *oc_thread;
/**
- * Enums for ca_cond_wait_for return values.
+ * Enums for oc_cond_wait_for return values.
*/
typedef enum
{
- CA_WAIT_SUCCESS = 0, /**< Condition Signal. */
- CA_WAIT_INVAL = -1, /**< Invalid Condition. */
- CA_WAIT_TIMEDOUT = -2 /**< Condition Timed Out. */
-} CAWaitResult_t;
+ OC_WAIT_SUCCESS = 0, /**< Condition Signal. */
+ OC_WAIT_INVAL = -1, /**< Invalid Condition. */
+ OC_WAIT_TIMEDOUT = -2 /**< Condition Timed Out. */
+} OCWaitResult_t;
typedef enum
{
- CA_THREAD_SUCCESS = 0,
- CA_THREAD_ALLOCATION_FAILURE = 1,
- CA_THREAD_CREATE_FAILURE=2,
- CA_THREAD_INVALID=3,
- CA_THREAD_WAIT_FAILURE=4,
- CA_THREAD_INVALID_PARAMETER=5
-} CAThreadResult_t;
+ OC_THREAD_SUCCESS = 0,
+ OC_THREAD_ALLOCATION_FAILURE = 1,
+ OC_THREAD_CREATE_FAILURE=2,
+ OC_THREAD_INVALID=3,
+ OC_THREAD_WAIT_FAILURE=4,
+ OC_THREAD_INVALID_PARAMETER=5
+} OCThreadResult_t;
/**
* Allocates, and starts a new thread
* @param[out] t The thread that will refer to a newly allocated, and started thread
* @param[in] start_routine The function that will execute in a new thread
* @param[in] arg The information passed to the start_routine
- * @return CAThreadResult_t An enumeration of possible outcomes
- * @retval CA_THREAD_SUCCESS If a thread was successfully allocated and started.
- * @retval CA_THREAD_ALLOCATION_FAILURE If a thread was unable to be allocated
- * @retval CA_THREAD_CREATE_FAILURE If a thread was unable to be started
+ * @return OCThreadResult_t An enumeration of possible outcomes
+ * @retval OC_THREAD_SUCCESS If a thread was successfully allocated and started.
+ * @retval OC_THREAD_ALLOCATION_FAILURE If a thread was unable to be allocated
+ * @retval OC_THREAD_CREATE_FAILURE If a thread was unable to be started
*
*/
-CAThreadResult_t ca_thread_new(ca_thread *t, void *(*start_routine)(void *), void *arg);
+OCThreadResult_t oc_thread_new(oc_thread *t, void *(*start_routine)(void *), void *arg);
/**
- * Frees a thread previously allocated with ca_thread_new()
+ * Frees a thread previously allocated with oc_thread_new()
*
* @param[in] t The thread to be unallocated
- * @return CAThreadResult_t An enumeration of possible outcomes
- * @retval CA_THREAD_SUCCESS If a thread was successfully unallocated
- * @retval CA_THREAD_INVALID_PARAMETER If param t is NULL
+ * @return OCThreadResult_t An enumeration of possible outcomes
+ * @retval OC_THREAD_SUCCESS If a thread was successfully unallocated
+ * @retval OC_THREAD_INVALID_PARAMETER If param t is NULL
*
*/
-CAThreadResult_t ca_thread_free(ca_thread t);
+OCThreadResult_t oc_thread_free(oc_thread t);
/**
* Block until a thread's execution has been completed
*
* @param[in] t The thread to be waited on
- * @return CAThreadResult_t An enumeration of possible outcomes
- * @retval CA_THREAD_SUCCESS If the thread successfully completed execution
- * @retval CA_THREAD_WAIT_FAILURE If a problem occured while waiting for execution of the thread to complete
+ * @return OCThreadResult_t An enumeration of possible outcomes
+ * @retval OC_THREAD_SUCCESS If the thread successfully completed execution
+ * @retval OC_THREAD_WAIT_FAILURE If a problem occured while waiting for execution of the thread to complete
*
*/
-CAThreadResult_t ca_thread_wait(ca_thread t);
+OCThreadResult_t oc_thread_wait(oc_thread t);
/**
* Creates new mutex.
* @return Reference to newly created mutex, otherwise NULL.
*
*/
-ca_mutex ca_mutex_new(void);
+oc_mutex oc_mutex_new(void);
/**
* Lock the mutex.
* @param mutex The mutex to be locked.
*
*/
-void ca_mutex_lock(ca_mutex mutex);
+void oc_mutex_lock(oc_mutex mutex);
/**
* Unlock the mutex.
* @param mutex The mutex to be unlocked.
*
*/
-void ca_mutex_unlock(ca_mutex mutex);
+void oc_mutex_unlock(oc_mutex mutex);
/**
* Free the mutex.
* @retval false if mutex parameter is invalid
*
*/
-bool ca_mutex_free(ca_mutex mutex);
+bool oc_mutex_free(oc_mutex mutex);
/**
* Creates new condition.
*
- * @return Reference to newly created ca_cond, otherwise NULL.
+ * @return Reference to newly created oc_cond, otherwise NULL.
*
*/
-ca_cond ca_cond_new(void);
+oc_cond oc_cond_new(void);
/**
* One of threads is woken up if multiple threads are waiting for cond.
* @param cond The condtion to be signaled.
*
*/
-void ca_cond_signal(ca_cond cond);
+void oc_cond_signal(oc_cond cond);
/**
* All of threads are woken up if multiple threads are waiting for cond.
* @param cond The condtion to be signaled.
*
*/
-void ca_cond_broadcast(ca_cond cond);
+void oc_cond_broadcast(oc_cond cond);
/**
* Waits until this thread woken up on cond.
* @param mutex The mutex which is currently locked from calling thread.
*
*/
-void ca_cond_wait(ca_cond cond, ca_mutex mutex);
+void oc_cond_wait(oc_cond cond, oc_mutex mutex);
/**
* Waits until this thread woken up on cond,
* but not longer than the interval specified by microseconds.
* The mutex is unlocked before falling asleep and locked again before resuming.
- * If microseconds is 0, ca_cond_wait_for() acts like ca_cond_wait().
+ * If microseconds is 0, oc_cond_wait_for() acts like oc_cond_wait().
*
* @param cond The condtion to be wait for to signal.
* @param mutex The mutex which is currently locked from calling thread.
* @param microseconds relative time for waiting, microseconds.
*
- * @return ::CA_WAIT_SUCCESS if the condition was signaled,
- * ::CA_WAIT_TIMEDOUT if wait period exceeded,
- * ::CA_WAIT_INVAL for invalid parameters.
+ * @return OC_WAIT_SUCCESS if the condition was signaled,
+ * OC_WAIT_TIMEDOUT if wait period exceeded,
+ * OC_WAIT_INVAL for invalid parameters.
*
*/
-CAWaitResult_t ca_cond_wait_for(ca_cond cond, ca_mutex mutex, uint64_t microseconds);
+OCWaitResult_t oc_cond_wait_for(oc_cond cond, oc_mutex mutex, uint64_t microseconds);
/**
* Free the condition.
* @param cond The condition to be freed.
*
*/
-void ca_cond_free(ca_cond cond);
+void oc_cond_free(oc_cond cond);
#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */
-#endif /* CA_MUTEX_H_ */
+#endif /* OC_THREAD_H_ */
typedef struct _tagMutexInfo_t
{
-} ca_mutex_internal;
+} oc_mutex_internal;
typedef struct _tagEventInfo_t
{
-} ca_cond_internal;
+} oc_cond_internal;
typedef struct _tagThreadInfo_t
{
-} ca_thread_internal;
+} oc_thread_internal;
/**
* @var g_mutexInfo
- * @brief This is used to return a non NULL value for ca_mutex_new().
+ * @brief This is used to return a non NULL value for oc_mutex_new().
*/
-static ca_mutex_internal g_mutexInfo = { 0 };
+static oc_mutex_internal g_mutexInfo = { 0 };
/**
* @var g_condInfo
- * @brief This is used to return a non NULL value for ca_cond_new().
+ * @brief This is used to return a non NULL value for oc_cond_new().
*/
-static ca_cond_internal g_condInfo = { 0 };
+static oc_cond_internal g_condInfo = { 0 };
-CAThreadResult_t ca_thread_new(ca_thread *t, void *(*start_routine)(void *), void *arg)
+OCThreadResult_t oc_thread_new(oc_thread *t, void *(*start_routine)(void *), void *arg)
{
- return CA_THREAD_CREATE_FAILURE;
+ return OC_THREAD_CREATE_FAILURE;
}
-CAThreadResult_t ca_thread_free(ca_thread t)
+OCThreadResult_t oc_thread_free(oc_thread t)
{
- return CA_THREAD_INVALID;
+ return OC_THREAD_INVALID;
}
-CAThreadResult_t ca_thread_wait(ca_thread t)
+OCThreadResult_t oc_thread_wait(oc_thread t)
{
- return CA_THREAD_INVALID;
+ return OC_THREAD_INVALID;
}
-ca_mutex ca_mutex_new(void)
+oc_mutex oc_mutex_new(void)
{
- return (ca_mutex)&g_mutexInfo;
+ return (oc_mutex)&g_mutexInfo;
}
-bool ca_mutex_free(ca_mutex mutex)
+bool oc_mutex_free(oc_mutex mutex)
{
return true;
}
-void ca_mutex_lock(ca_mutex mutex)
+void oc_mutex_lock(oc_mutex mutex)
{
return;
}
-void ca_mutex_unlock(ca_mutex mutex)
+void oc_mutex_unlock(oc_mutex mutex)
{
return;
}
-ca_cond ca_cond_new(void)
+oc_cond oc_cond_new(void)
{
- return (ca_cond)&g_condInfo;
+ return (oc_cond)&g_condInfo;
}
-void ca_cond_free(ca_cond cond)
+void oc_cond_free(oc_cond cond)
{
return;
}
-void ca_cond_signal(ca_cond cond)
+void oc_cond_signal(oc_cond cond)
{
return;
}
-void ca_cond_broadcast(ca_cond cond)
+void oc_cond_broadcast(oc_cond cond)
{
return;
}
-void ca_cond_wait(ca_cond cond, ca_mutex mutex)
+void oc_cond_wait(oc_cond cond, oc_mutex mutex)
{
return;
}
-CAWaitResult_t ca_cond_wait_for(ca_cond cond, ca_mutex mutex, uint64_t microseconds)
+OCWaitResult_t oc_cond_wait_for(oc_cond cond, oc_mutex mutex, uint64_t microseconds)
{
- return CA_WAIT_SUCCESS;
+ return OC_WAIT_SUCCESS;
}
typedef struct _tagMutexInfo_t
{
pthread_mutex_t mutex;
-} ca_mutex_internal;
+} oc_mutex_internal;
typedef struct _tagEventInfo_t
{
pthread_cond_t cond;
pthread_condattr_t condattr;
-} ca_cond_internal;
+} oc_cond_internal;
typedef struct _tagThreadInfo_t
{
pthread_t thread;
pthread_attr_t threadattr;
-} ca_thread_internal;
+} oc_thread_internal;
-CAThreadResult_t ca_thread_new(ca_thread *t, void *(*start_routine)(void *), void *arg)
+OCThreadResult_t oc_thread_new(oc_thread *t, void *(*start_routine)(void *), void *arg)
{
- CAThreadResult_t res = CA_THREAD_SUCCESS;
- ca_thread_internal *threadInfo = (ca_thread_internal*)OICMalloc(sizeof(ca_thread_internal));
+ OCThreadResult_t res = OC_THREAD_SUCCESS;
+ oc_thread_internal *threadInfo = (oc_thread_internal*)OICMalloc(sizeof(oc_thread_internal));
if (NULL != threadInfo)
{
int result = pthread_create(&threadInfo->thread, NULL, start_routine, arg);
if (result != 0)
{
- res = CA_THREAD_CREATE_FAILURE;
+ res = OC_THREAD_CREATE_FAILURE;
*t = NULL;
OICFree(threadInfo);
OIC_LOG_V(ERROR, TAG, "%s: pthread_create failed", __func__);
}
else
{
- *t = (ca_thread)threadInfo;
+ *t = (oc_thread)threadInfo;
}
}
else
{
OIC_LOG_V(ERROR, TAG, "%s Failed to allocate thread!", __func__);
*t = NULL;
- res = CA_THREAD_ALLOCATION_FAILURE;
+ res = OC_THREAD_ALLOCATION_FAILURE;
}
return res;
}
-CAThreadResult_t ca_thread_free(ca_thread t)
+OCThreadResult_t oc_thread_free(oc_thread t)
{
- CAThreadResult_t res = CA_THREAD_SUCCESS;
- ca_thread_internal *threadInfo = (ca_thread_internal*) t;
+ OCThreadResult_t res = OC_THREAD_SUCCESS;
+ oc_thread_internal *threadInfo = (oc_thread_internal*) t;
if (threadInfo)
{
OICFree(threadInfo);
else
{
OIC_LOG_V(ERROR, TAG, "%s Invalid thread !", __func__);
- res = CA_THREAD_INVALID;
+ res = OC_THREAD_INVALID;
}
return res;
}
-CAThreadResult_t ca_thread_wait(ca_thread t)
+OCThreadResult_t oc_thread_wait(oc_thread t)
{
- CAThreadResult_t res = CA_THREAD_SUCCESS;
- ca_thread_internal *threadInfo = (ca_thread_internal*) t;
+ OCThreadResult_t res = OC_THREAD_SUCCESS;
+ oc_thread_internal *threadInfo = (oc_thread_internal*) t;
int joinres = pthread_join(threadInfo->thread, NULL);
if (0 != joinres)
{
OIC_LOG_V(ERROR, TAG, "Failed to join thread with error %d", joinres);
- res = CA_THREAD_WAIT_FAILURE;
+ res = OC_THREAD_WAIT_FAILURE;
}
return res;
}
-ca_mutex ca_mutex_new(void)
+oc_mutex oc_mutex_new(void)
{
- ca_mutex retVal = NULL;
- ca_mutex_internal *mutexInfo = (ca_mutex_internal*) OICMalloc(sizeof(ca_mutex_internal));
+ oc_mutex retVal = NULL;
+ oc_mutex_internal *mutexInfo = (oc_mutex_internal*) OICMalloc(sizeof(oc_mutex_internal));
if (NULL != mutexInfo)
{
// create the mutex with the attributes set
int ret=pthread_mutex_init(&(mutexInfo->mutex), PTHREAD_MUTEX_DEFAULT);
if (0 == ret)
{
- retVal = (ca_mutex) mutexInfo;
+ retVal = (oc_mutex) mutexInfo;
}
else
{
return retVal;
}
-bool ca_mutex_free(ca_mutex mutex)
+bool oc_mutex_free(oc_mutex mutex)
{
bool bRet=false;
- ca_mutex_internal *mutexInfo = (ca_mutex_internal*) mutex;
+ oc_mutex_internal *mutexInfo = (oc_mutex_internal*) mutex;
if (mutexInfo)
{
int ret = pthread_mutex_destroy(&mutexInfo->mutex);
return bRet;
}
-void ca_mutex_lock(ca_mutex mutex)
+void oc_mutex_lock(oc_mutex mutex)
{
- ca_mutex_internal *mutexInfo = (ca_mutex_internal*) mutex;
+ oc_mutex_internal *mutexInfo = (oc_mutex_internal*) mutex;
if (mutexInfo)
{
int ret = pthread_mutex_lock(&mutexInfo->mutex);
}
}
-void ca_mutex_unlock(ca_mutex mutex)
+void oc_mutex_unlock(oc_mutex mutex)
{
- ca_mutex_internal *mutexInfo = (ca_mutex_internal*) mutex;
+ oc_mutex_internal *mutexInfo = (oc_mutex_internal*) mutex;
if (mutexInfo)
{
int ret = pthread_mutex_unlock(&mutexInfo->mutex);
}
}
-ca_cond ca_cond_new(void)
+oc_cond oc_cond_new(void)
{
- ca_cond retVal = NULL;
- ca_cond_internal *eventInfo = (ca_cond_internal*) OICMalloc(sizeof(ca_cond_internal));
+ oc_cond retVal = NULL;
+ oc_cond_internal *eventInfo = (oc_cond_internal*) OICMalloc(sizeof(oc_cond_internal));
if (NULL != eventInfo)
{
int ret = pthread_condattr_init(&(eventInfo->condattr));
ret = pthread_cond_init(&(eventInfo->cond), &(eventInfo->condattr));
if (0 == ret)
{
- retVal = (ca_cond) eventInfo;
+ retVal = (oc_cond) eventInfo;
}
else
{
return retVal;
}
-void ca_cond_free(ca_cond cond)
+void oc_cond_free(oc_cond cond)
{
- ca_cond_internal *eventInfo = (ca_cond_internal*) cond;
+ oc_cond_internal *eventInfo = (oc_cond_internal*) cond;
if (eventInfo != NULL)
{
int ret = pthread_cond_destroy(&(eventInfo->cond));
}
}
-void ca_cond_signal(ca_cond cond)
+void oc_cond_signal(oc_cond cond)
{
- ca_cond_internal *eventInfo = (ca_cond_internal*) cond;
+ oc_cond_internal *eventInfo = (oc_cond_internal*) cond;
if (eventInfo != NULL)
{
int ret = pthread_cond_signal(&(eventInfo->cond));
}
}
-void ca_cond_broadcast(ca_cond cond)
+void oc_cond_broadcast(oc_cond cond)
{
- ca_cond_internal* eventInfo = (ca_cond_internal*) cond;
+ oc_cond_internal* eventInfo = (oc_cond_internal*) cond;
if (eventInfo != NULL)
{
int ret = pthread_cond_broadcast(&(eventInfo->cond));
}
}
-void ca_cond_wait(ca_cond cond, ca_mutex mutex)
+void oc_cond_wait(oc_cond cond, oc_mutex mutex)
{
- ca_cond_wait_for(cond, mutex, 0L);
+ oc_cond_wait_for(cond, mutex, 0L);
}
#ifndef TIMEVAL_TO_TIMESPEC
}
#endif
-struct timespec ca_get_current_time()
+struct timespec oc_get_current_time()
{
#if defined(__ANDROID__) || _POSIX_TIMERS > 0
struct timespec ts;
#endif
}
-void ca_add_microseconds_to_timespec(struct timespec* ts, uint64_t microseconds)
+void oc_add_microseconds_to_timespec(struct timespec* ts, uint64_t microseconds)
{
time_t secPart = microseconds/USECS_PER_SEC;
uint64_t nsecPart = (microseconds % USECS_PER_SEC) * NANOSECS_PER_USECS;
ts->tv_sec += secPart + secOfNs;
}
-CAWaitResult_t ca_cond_wait_for(ca_cond cond, ca_mutex mutex, uint64_t microseconds)
+OCWaitResult_t oc_cond_wait_for(oc_cond cond, oc_mutex mutex, uint64_t microseconds)
{
- CAWaitResult_t retVal = CA_WAIT_INVAL;
+ OCWaitResult_t retVal = OC_WAIT_INVAL;
- ca_cond_internal *eventInfo = (ca_cond_internal*) cond;
- ca_mutex_internal *mutexInfo = (ca_mutex_internal*) mutex;
+ oc_cond_internal *eventInfo = (oc_cond_internal*) cond;
+ oc_mutex_internal *mutexInfo = (oc_mutex_internal*) mutex;
if (NULL == mutexInfo)
{
OIC_LOG_V(ERROR, TAG, "%s: Invalid mutex", __func__);
- return CA_WAIT_INVAL;
+ return OC_WAIT_INVAL;
}
if (NULL == eventInfo)
{
OIC_LOG_V(ERROR, TAG, "%s: Invalid condition", __func__);
- return CA_WAIT_INVAL;
+ return OC_WAIT_INVAL;
}
if (microseconds > 0)
} else
#endif
{
- abstime = ca_get_current_time();
- ca_add_microseconds_to_timespec(&abstime, microseconds);
+ abstime = oc_get_current_time();
+ oc_add_microseconds_to_timespec(&abstime, microseconds);
//Wait for the given time
ret = pthread_cond_timedwait(&(eventInfo->cond), &(mutexInfo->mutex), &abstime);
{
case 0:
// Success
- retVal = CA_WAIT_SUCCESS;
+ retVal = OC_WAIT_SUCCESS;
break;
case ETIMEDOUT:
- retVal = CA_WAIT_TIMEDOUT;
+ retVal = OC_WAIT_TIMEDOUT;
break;
case EINVAL:
OIC_LOG_V(ERROR, TAG, "%s: condition, mutex, or abstime is Invalid", __func__);
- retVal = CA_WAIT_INVAL;
+ retVal = OC_WAIT_INVAL;
break;
default:
OIC_LOG_V(ERROR, TAG, "%s: pthread_cond_timedwait returned %d", __func__, retVal);
- retVal = CA_WAIT_INVAL;
+ retVal = OC_WAIT_INVAL;
break;
}
}
{
// Wait forever
int ret = pthread_cond_wait(&eventInfo->cond, &mutexInfo->mutex);
- retVal = ret == 0 ? CA_WAIT_SUCCESS : CA_WAIT_INVAL;
+ retVal = ret == 0 ? OC_WAIT_SUCCESS : OC_WAIT_INVAL;
}
return retVal;
}
/**
* @file
- * This file provides APIs related to mutex and semaphores.
+ * This file provides APIs related to mutex, semaphores, and threads.
*/
#include "iotivity_config.h"
#include "octhread.h"
typedef struct _tagMutexInfo_t
{
CRITICAL_SECTION mutex;
-} ca_mutex_internal;
+} oc_mutex_internal;
typedef struct _tagEventInfo_t
{
CONDITION_VARIABLE cond;
-} ca_cond_internal;
+} oc_cond_internal;
typedef struct _tagThreadInfo_t
{
HANDLE handle;
-} ca_thread_internal;
+} oc_thread_internal;
-CAThreadResult_t ca_thread_new(ca_thread *t, void *(*start_routine)(void *), void *arg)
+OCThreadResult_t oc_thread_new(oc_thread *t, void *(*start_routine)(void *), void *arg)
{
- CAThreadResult_t res = CA_THREAD_SUCCESS;
- ca_thread_internal *threadInfo = (ca_thread_internal*)OICMalloc(sizeof(ca_thread_internal));
+ OCThreadResult_t res = OC_THREAD_SUCCESS;
+ oc_thread_internal *threadInfo = (oc_thread_internal*)OICMalloc(sizeof(oc_thread_internal));
if (NULL != threadInfo)
{
threadInfo->handle = CreateThread(NULL, 0, (PTHREAD_START_ROUTINE)start_routine, arg, 0, NULL);
if (threadInfo->handle == NULL)
{
- res = CA_THREAD_CREATE_FAILURE;
+ res = OC_THREAD_CREATE_FAILURE;
*t = NULL;
OICFree(threadInfo);
OIC_LOG_V(ERROR, TAG, "%s: CreateThread failed: %i", __func__, GetLastError());
}
else
{
- *t = (ca_thread)threadInfo;
+ *t = (oc_thread)threadInfo;
}
}
else
{
OIC_LOG_V(ERROR, TAG, "%s Failed to allocate thread!", __func__);
*t = NULL;
- res = CA_THREAD_ALLOCATION_FAILURE;
+ res = OC_THREAD_ALLOCATION_FAILURE;
}
return res;
}
-CAThreadResult_t ca_thread_free(ca_thread t)
+OCThreadResult_t oc_thread_free(oc_thread t)
{
- CAThreadResult_t res = CA_THREAD_INVALID_PARAMETER;
- ca_thread_internal *threadInfo = (ca_thread_internal*) t;
+ OCThreadResult_t res = OC_THREAD_INVALID_PARAMETER;
+ oc_thread_internal *threadInfo = (oc_thread_internal*) t;
if (threadInfo)
{
CloseHandle(threadInfo->handle);
OICFree(threadInfo);
- res = CA_THREAD_SUCCESS;
+ res = OC_THREAD_SUCCESS;
}
else
{
return res;
}
-CAThreadResult_t ca_thread_wait(ca_thread t)
+OCThreadResult_t oc_thread_wait(oc_thread t)
{
- CAThreadResult_t res = CA_THREAD_SUCCESS;
- ca_thread_internal *threadInfo = (ca_thread_internal*) t;
+ OCThreadResult_t res = OC_THREAD_SUCCESS;
+ oc_thread_internal *threadInfo = (oc_thread_internal*) t;
DWORD joinres = WaitForSingleObject(threadInfo->handle, INFINITE);
if (WAIT_OBJECT_0 != joinres)
{
OIC_LOG(ERROR, TAG, "Failed to join thread");
- res = CA_THREAD_WAIT_FAILURE;
+ res = OC_THREAD_WAIT_FAILURE;
}
else
{
return res;
}
-ca_mutex ca_mutex_new(void)
+oc_mutex oc_mutex_new(void)
{
- ca_mutex retVal = NULL;
- ca_mutex_internal *mutexInfo = (ca_mutex_internal*) OICMalloc(sizeof(ca_mutex_internal));
+ oc_mutex retVal = NULL;
+ oc_mutex_internal *mutexInfo = (oc_mutex_internal*) OICMalloc(sizeof(oc_mutex_internal));
if (NULL != mutexInfo)
{
InitializeCriticalSection(&mutexInfo->mutex);
- retVal = (ca_mutex)mutexInfo;
+ retVal = (oc_mutex)mutexInfo;
}
else
{
return retVal;
}
-bool ca_mutex_free(ca_mutex mutex)
+bool oc_mutex_free(oc_mutex mutex)
{
bool bRet = false;
- ca_mutex_internal *mutexInfo = (ca_mutex_internal*) mutex;
+ oc_mutex_internal *mutexInfo = (oc_mutex_internal*) mutex;
if (mutexInfo)
{
DeleteCriticalSection(&mutexInfo->mutex);
return bRet;
}
-void ca_mutex_lock(ca_mutex mutex)
+void oc_mutex_lock(oc_mutex mutex)
{
- ca_mutex_internal *mutexInfo = (ca_mutex_internal*) mutex;
+ oc_mutex_internal *mutexInfo = (oc_mutex_internal*) mutex;
if (mutexInfo)
{
EnterCriticalSection(&mutexInfo->mutex);
}
}
-void ca_mutex_unlock(ca_mutex mutex)
+void oc_mutex_unlock(oc_mutex mutex)
{
- ca_mutex_internal *mutexInfo = (ca_mutex_internal*) mutex;
+ oc_mutex_internal *mutexInfo = (oc_mutex_internal*) mutex;
if (mutexInfo)
{
LeaveCriticalSection(&mutexInfo->mutex);
}
}
-ca_cond ca_cond_new(void)
+oc_cond oc_cond_new(void)
{
- ca_cond retVal = NULL;
- ca_cond_internal *eventInfo = (ca_cond_internal*) OICMalloc(sizeof(ca_cond_internal));
+ oc_cond retVal = NULL;
+ oc_cond_internal *eventInfo = (oc_cond_internal*) OICMalloc(sizeof(oc_cond_internal));
if (NULL != eventInfo)
{
InitializeConditionVariable(&eventInfo->cond);
- retVal = (ca_cond) eventInfo;
+ retVal = (oc_cond) eventInfo;
}
else
{
return retVal;
}
-void ca_cond_free(ca_cond cond)
+void oc_cond_free(oc_cond cond)
{
- ca_cond_internal *eventInfo = (ca_cond_internal*) cond;
+ oc_cond_internal *eventInfo = (oc_cond_internal*) cond;
if (eventInfo != NULL)
{
OICFree(cond);
}
}
-void ca_cond_signal(ca_cond cond)
+void oc_cond_signal(oc_cond cond)
{
- ca_cond_internal *eventInfo = (ca_cond_internal*) cond;
+ oc_cond_internal *eventInfo = (oc_cond_internal*) cond;
if (eventInfo != NULL)
{
WakeConditionVariable(&eventInfo->cond);
}
}
-void ca_cond_broadcast(ca_cond cond)
+void oc_cond_broadcast(oc_cond cond)
{
- ca_cond_internal* eventInfo = (ca_cond_internal*) cond;
+ oc_cond_internal* eventInfo = (oc_cond_internal*) cond;
if (eventInfo != NULL)
{
WakeAllConditionVariable(&eventInfo->cond);
}
}
-void ca_cond_wait(ca_cond cond, ca_mutex mutex)
+void oc_cond_wait(oc_cond cond, oc_mutex mutex)
{
- ca_cond_wait_for(cond, mutex, 0L);
+ oc_cond_wait_for(cond, mutex, 0L);
}
-CAWaitResult_t ca_cond_wait_for(ca_cond cond, ca_mutex mutex, uint64_t microseconds)
+OCWaitResult_t oc_cond_wait_for(oc_cond cond, oc_mutex mutex, uint64_t microseconds)
{
- CAWaitResult_t retVal = CA_WAIT_INVAL;
+ OCWaitResult_t retVal = OC_WAIT_INVAL;
- ca_cond_internal *eventInfo = (ca_cond_internal*) cond;
- ca_mutex_internal *mutexInfo = (ca_mutex_internal*) mutex;
+ oc_cond_internal *eventInfo = (oc_cond_internal*) cond;
+ oc_mutex_internal *mutexInfo = (oc_mutex_internal*) mutex;
if (NULL == mutexInfo)
{
OIC_LOG_V(ERROR, TAG, "%s: Invalid mutex", __func__);
- return CA_WAIT_INVAL;
+ return OC_WAIT_INVAL;
}
if (NULL == eventInfo)
{
OIC_LOG_V(ERROR, TAG, "%s: Invalid condition", __func__);
- return CA_WAIT_INVAL;
+ return OC_WAIT_INVAL;
}
DWORD milli = 0;
{
if (GetLastError() == ERROR_TIMEOUT)
{
- retVal = CA_WAIT_TIMEDOUT;
+ retVal = OC_WAIT_TIMEDOUT;
}
else
{
OIC_LOG_V(ERROR, TAG, "SleepConditionVariableCS() failed %i", GetLastError());
- retVal = CA_WAIT_INVAL;
+ retVal = OC_WAIT_INVAL;
}
}
else
{
- retVal = CA_WAIT_SUCCESS;
+ retVal = OC_WAIT_SUCCESS;
}
return retVal;
typedef struct ca_thread_pool_details_t
{
u_arraylist_t* threads_list;
- ca_mutex list_lock;
+ oc_mutex list_lock;
} ca_thread_pool_details_t;
/**
return CA_MEMORY_ALLOC_FAILED;
}
- (*thread_pool)->details->list_lock = ca_mutex_new();
+ (*thread_pool)->details->list_lock = oc_mutex_new();
if(!(*thread_pool)->details->list_lock)
{
if(!(*thread_pool)->details->threads_list)
{
OIC_LOG(ERROR, TAG, "Failed to create thread-pool list");
- if(!ca_mutex_free((*thread_pool)->details->list_lock))
+ if(!oc_mutex_free((*thread_pool)->details->list_lock))
{
OIC_LOG(ERROR, TAG, "Failed to free thread-pool mutex");
}
info->func = method;
info->data = data;
- ca_thread thread;
- int thrRet = ca_thread_new(&thread, ca_thread_pool_pthreads_delegate, info);
+ oc_thread thread;
+ int thrRet = oc_thread_new(&thread, ca_thread_pool_pthreads_delegate, info);
if (thrRet != 0)
{
OIC_LOG_V(ERROR, TAG, "Thread start failed with error %d", thrRet);
return CA_STATUS_FAILED;
}
- ca_mutex_lock(thread_pool->details->list_lock);
+ oc_mutex_lock(thread_pool->details->list_lock);
bool addResult = u_arraylist_add(thread_pool->details->threads_list, (void*)thread);
- ca_mutex_unlock(thread_pool->details->list_lock);
+ oc_mutex_unlock(thread_pool->details->list_lock);
if(!addResult)
{
OIC_LOG_V(ERROR, TAG, "Arraylist Add failed, may not be properly joined: %d", addResult);
- ca_thread_free(thread);
+ oc_thread_free(thread);
return CA_STATUS_FAILED;
}
return;
}
- ca_mutex_lock(thread_pool->details->list_lock);
+ oc_mutex_lock(thread_pool->details->list_lock);
for(uint32_t i = 0; i<u_arraylist_length(thread_pool->details->threads_list); ++i)
{
- ca_thread thr = (ca_thread)u_arraylist_get(thread_pool->details->threads_list, i);
- ca_thread_wait(thr);
- ca_thread_free(thr);
+ oc_thread thr = (oc_thread)u_arraylist_get(thread_pool->details->threads_list, i);
+ oc_thread_wait(thr);
+ oc_thread_free(thr);
}
u_arraylist_free(&(thread_pool->details->threads_list));
- ca_mutex_unlock(thread_pool->details->list_lock);
- ca_mutex_free(thread_pool->details->list_lock);
+ oc_mutex_unlock(thread_pool->details->list_lock);
+ oc_mutex_free(thread_pool->details->list_lock);
OICFree(thread_pool->details);
OICFree(thread_pool);
u_arraylist_t *dataList;
/** data list mutex for synchronization. **/
- ca_mutex blockDataListMutex;
+ oc_mutex blockDataListMutex;
/** sender mutex for synchronization. **/
- ca_mutex blockDataSenderMutex;
+ oc_mutex blockDataSenderMutex;
} CABlockWiseContext_t;
/**
/** Thread pool of the thread started. **/
ca_thread_pool_t threadPool;
/** mutex for synchronization. **/
- ca_mutex threadMutex;
+ oc_mutex threadMutex;
/** conditional mutex for synchronization. **/
- ca_cond threadCond;
+ oc_cond threadCond;
/** Thread function to be invoked. **/
CAThreadTask threadTask;
/** Data destroy function. **/
ca_thread_pool_t threadPool;
/** mutex for synchronization. **/
- ca_mutex threadMutex;
+ oc_mutex threadMutex;
/** conditional mutex for synchronization. **/
- ca_cond threadCond;
+ oc_cond threadCond;
/** send method for retransmission data. **/
CADataSendMethod_t dataSendMethod;
removePeerFromList(&peer->sep.endpoint); \
if (mutex) \
{ \
- ca_mutex_unlock(g_tlsContextMutex); \
+ oc_mutex_unlock(g_tlsContextMutex); \
} \
OIC_LOG_V(DEBUG, NET_TLS_TAG, "Out %s", __func__); \
return error; \
* @var g_dtlsContextMutex
* @brief Mutex to synchronize access to g_caTlsContext.
*/
-static ca_mutex g_tlsContextMutex = NULL;
+static oc_mutex g_tlsContextMutex = NULL;
/**
* @var g_tlsHandshakeCallback
OIC_LOG_V(DEBUG, NET_TLS_TAG, "In %s", __func__);
VERIFY_NON_NULL_RET(endpoint, NET_TLS_TAG, "Param endpoint is NULL" , CA_STATUS_INVALID_PARAM);
- ca_mutex_lock(g_tlsContextMutex);
+ oc_mutex_lock(g_tlsContextMutex);
if (NULL == g_caTlsContext)
{
OIC_LOG(ERROR, NET_TLS_TAG, "Context is NULL");
- ca_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
return CA_STATUS_FAILED;
}
TlsEndPoint_t * tep = getTlsPeer(endpoint);
if (NULL == tep)
{
OIC_LOG(ERROR, NET_TLS_TAG, "Session does not exist");
- ca_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
return CA_STATUS_FAILED;
}
/* No error checking, the connection might be closed already */
while (MBEDTLS_ERR_SSL_WANT_WRITE == ret);
removePeerFromList(&tep->sep.endpoint);
- ca_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
OIC_LOG_V(DEBUG, NET_TLS_TAG, "Out %s", __func__);
return CA_STATUS_OK;
VERIFY_NON_NULL_VOID(g_tlsContextMutex, NET_TLS_TAG, "context mutex is NULL");
//Lock tlsContext mutex
- ca_mutex_lock(g_tlsContextMutex);
+ oc_mutex_lock(g_tlsContextMutex);
// Clear all lists
deletePeerList();
g_caTlsContext = NULL;
// Unlock tlsContext mutex and de-initialize it
- ca_mutex_unlock(g_tlsContextMutex);
- ca_mutex_free(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_free(g_tlsContextMutex);
g_tlsContextMutex = NULL;
OIC_LOG_V(DEBUG, NET_TLS_TAG, "Out %s ", __func__);
// Initialize mutex for tlsContext
if (NULL == g_tlsContextMutex)
{
- g_tlsContextMutex = ca_mutex_new();
+ g_tlsContextMutex = oc_mutex_new();
VERIFY_NON_NULL_RET(g_tlsContextMutex, NET_TLS_TAG, "malloc failed",
CA_MEMORY_ALLOC_FAILED);
}
}
// Lock tlsContext mutex and create tlsContext
- ca_mutex_lock(g_tlsContextMutex);
+ oc_mutex_lock(g_tlsContextMutex);
g_caTlsContext = (TlsContext_t *)OICCalloc(1, sizeof(TlsContext_t));
if (NULL == g_caTlsContext)
{
OIC_LOG(ERROR, NET_TLS_TAG, "Context malloc failed");
- ca_mutex_unlock(g_tlsContextMutex);
- ca_mutex_free(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_free(g_tlsContextMutex);
g_tlsContextMutex = NULL;
return CA_MEMORY_ALLOC_FAILED;
}
OIC_LOG(ERROR, NET_TLS_TAG, "peerList initialization failed!");
OICFree(g_caTlsContext);
g_caTlsContext = NULL;
- ca_mutex_unlock(g_tlsContextMutex);
- ca_mutex_free(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_free(g_tlsContextMutex);
g_tlsContextMutex = NULL;
return CA_STATUS_FAILED;
}
if(urandomFd == -1)
{
OIC_LOG(ERROR, NET_TLS_TAG, "Fails open /dev/urandom!");
- ca_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
CAdeinitTlsAdapter();
return CA_STATUS_FAILED;
}
{
OIC_LOG(ERROR, NET_TLS_TAG, "Fails read from /dev/urandom!");
close(urandomFd);
- ca_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
CAdeinitTlsAdapter();
return CA_STATUS_FAILED;
}
&g_caTlsContext->entropy, seed, sizeof(SEED)))
{
OIC_LOG(ERROR, NET_TLS_TAG, "Seed initialization failed!");
- ca_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
CAdeinitTlsAdapter();
return CA_STATUS_FAILED;
}
MBEDTLS_SSL_TRANSPORT_STREAM, MBEDTLS_SSL_PRESET_DEFAULT) != 0)
{
OIC_LOG(ERROR, NET_TLS_TAG, "Client config initialization failed!");
- ca_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
CAdeinitTlsAdapter();
return CA_STATUS_FAILED;
}
MBEDTLS_SSL_TRANSPORT_STREAM, MBEDTLS_SSL_PRESET_DEFAULT) != 0)
{
OIC_LOG(ERROR, NET_TLS_TAG, "Server config initialization failed!");
- ca_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
CAdeinitTlsAdapter();
return CA_STATUS_FAILED;
}
mbedtls_pk_init(&g_caTlsContext->pkey);
mbedtls_x509_crl_init(&g_caTlsContext->crl);
- ca_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
OIC_LOG_V(DEBUG, NET_TLS_TAG, "Out %s", __func__);
return CA_STATUS_OK;
OIC_LOG_V(DEBUG, NET_TLS_TAG, "Data to be encrypted dataLen [%d]", dataLen);
- ca_mutex_lock(g_tlsContextMutex);
+ oc_mutex_lock(g_tlsContextMutex);
if(NULL == g_caTlsContext)
{
OIC_LOG(ERROR, NET_TLS_TAG, "Context is NULL");
- ca_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
return CA_STATUS_FAILED;
}
if (NULL == tep)
{
OIC_LOG(ERROR, NET_TLS_TAG, "TLS handshake failed");
- ca_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
return CA_STATUS_FAILED;
}
g_tlsHandshakeCallback(&tep->sep.endpoint, &errorInfo);
}
removePeerFromList(&tep->sep.endpoint);
- ca_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
return CA_STATUS_FAILED;
}
}
if (NULL == msg || !u_arraylist_add(tep->cacheList, (void *) msg))
{
OIC_LOG(ERROR, NET_TLS_TAG, "u_arraylist_add failed!");
- ca_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
return CA_STATUS_FAILED;
}
}
- ca_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
OIC_LOG_V(DEBUG, NET_TLS_TAG, "Out %s", __func__);
return CA_STATUS_OK;
VERIFY_NON_NULL_RET(sep, NET_TLS_TAG, "endpoint is NULL" , CA_STATUS_INVALID_PARAM);
VERIFY_NON_NULL_RET(data, NET_TLS_TAG, "Param data is NULL" , CA_STATUS_INVALID_PARAM);
- ca_mutex_lock(g_tlsContextMutex);
+ oc_mutex_lock(g_tlsContextMutex);
if (NULL == g_caTlsContext)
{
OIC_LOG(ERROR, NET_TLS_TAG, "Context is NULL");
- ca_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
return CA_STATUS_FAILED;
}
if (NULL == peer)
{
OIC_LOG(ERROR, NET_TLS_TAG, "Malloc failed!");
- ca_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
return CA_STATUS_FAILED;
}
//Load allowed SVR suites from SVR DB
{
OIC_LOG(ERROR, NET_TLS_TAG, "u_arraylist_add failed!");
OICFree(peer);
- ca_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
return CA_STATUS_FAILED;
}
}
}
}
}
- ca_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
OIC_LOG_V(DEBUG, NET_TLS_TAG, "Out %s", __func__);
return CA_STATUS_OK;
}
{
OIC_LOG(INFO, NET_TLS_TAG, "Connection was closed gracefully");
removePeerFromList(&peer->sep.endpoint);
- ca_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
return CA_STATUS_OK;
}
g_tlsHandshakeCallback(&peer->sep.endpoint, &errorInfo);
}
removePeerFromList(&peer->sep.endpoint);
- ca_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
return CA_STATUS_FAILED;
}
g_caTlsContext->adapterCallbacks[0].recvCallback(&peer->sep, decryptBuffer, ret);
}
- ca_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
OIC_LOG_V(DEBUG, NET_TLS_TAG, "Out %s", __func__);
return CA_STATUS_OK;
}
OIC_LOG_V(DEBUG, NET_TLS_TAG, "In %s", __func__);
VERIFY_NON_NULL_VOID(sendCallback, NET_TLS_TAG, "sendCallback is NULL");
VERIFY_NON_NULL_VOID(recvCallback, NET_TLS_TAG, "recvCallback is NULL");
- ca_mutex_lock(g_tlsContextMutex);
+ oc_mutex_lock(g_tlsContextMutex);
if (NULL == g_caTlsContext)
{
OIC_LOG(ERROR, NET_TLS_TAG, "Context is NULL");
- ca_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
return;
}
g_caTlsContext->adapterCallbacks[0].sendCallback = sendCallback;
}
- ca_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
OIC_LOG_V(DEBUG, NET_TLS_TAG, "Out %s", __func__);
}
CAResult_t res = CA_STATUS_OK;
OIC_LOG_V(DEBUG, NET_TLS_TAG, "In %s", __func__);
VERIFY_NON_NULL_RET(endpoint, NET_TLS_TAG, "Param endpoint is NULL" , CA_STATUS_INVALID_PARAM);
- ca_mutex_lock(g_tlsContextMutex);
+ oc_mutex_lock(g_tlsContextMutex);
if (NULL == initiateTlsHandshake(endpoint))
{
OIC_LOG(ERROR, NET_TLS_TAG, "TLS handshake failed");
res = CA_STATUS_FAILED;
}
- ca_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
OIC_LOG_V(DEBUG, NET_TLS_TAG, "Out %s", __func__);
return res;
}
VERIFY_NON_NULL_RET(ownerPSK, NET_TLS_TAG, "ownerPSK is NULL", CA_STATUS_INVALID_PARAM);
VERIFY_NON_NULL_RET(deviceID, NET_TLS_TAG, "rsrcID is NULL", CA_STATUS_INVALID_PARAM);
- ca_mutex_lock(g_tlsContextMutex);
+ oc_mutex_lock(g_tlsContextMutex);
if (NULL == g_caTlsContext)
{
OIC_LOG(ERROR, NET_TLS_TAG, "Context is NULL");
- ca_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
OIC_LOG_V(DEBUG, NET_TLS_TAG, "Out %s", __func__);
return CA_STATUS_FAILED;
}
if (NULL == tep)
{
OIC_LOG(ERROR, NET_TLS_TAG, "Session does not exist");
- ca_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
return CA_STATUS_FAILED;
}
MBEDTLS_MD_SHA1, MBEDTLS_PKCS12_DERIVE_KEY, 1))
{
OIC_LOG(ERROR, NET_TLS_TAG, "Failed to generate key");
- ca_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
OIC_LOG_V(DEBUG, NET_TLS_TAG, "Out %s", __func__);
return CA_STATUS_FAILED;
}
OIC_LOG_V(DEBUG, NET_TLS_TAG, "PSK: ");
OIC_LOG_BUFFER(DEBUG, NET_TLS_TAG, tep->master, sizeof(tep->master));
- ca_mutex_unlock(g_tlsContextMutex);
+ oc_mutex_unlock(g_tlsContextMutex);
OIC_LOG_V(DEBUG, NET_TLS_TAG, "Out %s", __func__);
return CA_STATUS_OK;
* @var g_dtlsContextMutex
* @brief Mutex to synchronize access to g_caDtlsContext.
*/
-static ca_mutex g_dtlsContextMutex = NULL;
+static oc_mutex g_dtlsContextMutex = NULL;
/**
* @var g_getCredentialsCallback
CATransportAdapter_t type)
{
OIC_LOG(DEBUG, NET_DTLS_TAG, "IN");
- ca_mutex_lock(g_dtlsContextMutex);
+ oc_mutex_lock(g_dtlsContextMutex);
if (NULL == g_caDtlsContext)
{
OIC_LOG(ERROR, NET_DTLS_TAG, "Context is NULL");
- ca_mutex_unlock(g_dtlsContextMutex);
+ oc_mutex_unlock(g_dtlsContextMutex);
return;
}
g_caDtlsContext->adapterCallbacks[0].sendCallback = sendCallback;
}
- ca_mutex_unlock(g_dtlsContextMutex);
+ oc_mutex_unlock(g_dtlsContextMutex);
OIC_LOG(DEBUG, NET_DTLS_TAG, "OUT");
}
{
OIC_LOG(DEBUG, NET_DTLS_TAG, "IN CADtlsSelectCipherSuite");
- ca_mutex_lock(g_dtlsContextMutex);
+ oc_mutex_lock(g_dtlsContextMutex);
if (NULL == g_caDtlsContext)
{
OIC_LOG(ERROR, NET_DTLS_TAG, "Context is NULL");
- ca_mutex_unlock(g_dtlsContextMutex);
+ oc_mutex_unlock(g_dtlsContextMutex);
return CA_STATUS_FAILED;
}
dtls_select_cipher(g_caDtlsContext->dtlsContext, cipher);
- ca_mutex_unlock(g_dtlsContextMutex);
+ oc_mutex_unlock(g_dtlsContextMutex);
OIC_LOG_V(DEBUG, NET_DTLS_TAG, "Selected cipher suite is 0x%02X%02X\n",
((uint8_t*)(&cipher))[1], ((uint8_t*)(&cipher))[0]);
{
OIC_LOG(DEBUG, NET_DTLS_TAG, "IN CADtlsEnablesAnonEcdh");
- ca_mutex_lock(g_dtlsContextMutex);
+ oc_mutex_lock(g_dtlsContextMutex);
if (NULL == g_caDtlsContext)
{
OIC_LOG(ERROR, NET_DTLS_TAG, "Context is NULL");
- ca_mutex_unlock(g_dtlsContextMutex);
+ oc_mutex_unlock(g_dtlsContextMutex);
return CA_STATUS_FAILED;
}
dtls_enables_anon_ecdh(g_caDtlsContext->dtlsContext,
enable == true ? DTLS_CIPHER_ENABLE : DTLS_CIPHER_DISABLE);
- ca_mutex_unlock(g_dtlsContextMutex);
+ oc_mutex_unlock(g_dtlsContextMutex);
OIC_LOG_V(DEBUG, NET_DTLS_TAG, "TLS_ECDH_anon_WITH_AES_128_CBC_SHA_256 is %s",
enable ? "enabled" : "disabled");
dst.ifIndex = 0;
dst.size = CASizeOfAddrInfo(&dst);
- ca_mutex_lock(g_dtlsContextMutex);
+ oc_mutex_lock(g_dtlsContextMutex);
if(NULL == g_caDtlsContext)
{
OIC_LOG(ERROR, NET_DTLS_TAG, "Context is NULL");
- ca_mutex_unlock(g_dtlsContextMutex);
+ oc_mutex_unlock(g_dtlsContextMutex);
return CA_STATUS_FAILED;
}
if(0 > dtls_connect(g_caDtlsContext->dtlsContext, (session_t*)(&dst)))
{
OIC_LOG(ERROR, NET_DTLS_TAG, "Failed to connect");
- ca_mutex_unlock(g_dtlsContextMutex);
+ oc_mutex_unlock(g_dtlsContextMutex);
return CA_STATUS_FAILED;
}
- ca_mutex_unlock(g_dtlsContextMutex);
+ oc_mutex_unlock(g_dtlsContextMutex);
OIC_LOG(DEBUG, NET_DTLS_TAG, "OUT CADtlsInitiateHandshake");
dst.ifIndex = 0;
dst.size = CASizeOfAddrInfo(&dst);
- ca_mutex_lock(g_dtlsContextMutex);
+ oc_mutex_lock(g_dtlsContextMutex);
if (NULL == g_caDtlsContext)
{
OIC_LOG(ERROR, NET_DTLS_TAG, "Context is NULL");
- ca_mutex_unlock(g_dtlsContextMutex);
+ oc_mutex_unlock(g_dtlsContextMutex);
return CA_STATUS_FAILED;
}
if (0 > dtls_close(g_caDtlsContext->dtlsContext, (session_t*)(&dst)))
{
OIC_LOG(ERROR, NET_DTLS_TAG, "Failed to close the session");
- ca_mutex_unlock(g_dtlsContextMutex);
+ oc_mutex_unlock(g_dtlsContextMutex);
return CA_STATUS_FAILED;
}
- ca_mutex_unlock(g_dtlsContextMutex);
+ oc_mutex_unlock(g_dtlsContextMutex);
OIC_LOG(DEBUG, NET_DTLS_TAG, "OUT CADtlsDisconnect");
dst.ifIndex = 0;
dst.size = CASizeOfAddrInfo(&dst);
- ca_mutex_lock(g_dtlsContextMutex);
+ oc_mutex_lock(g_dtlsContextMutex);
if (NULL == g_caDtlsContext)
{
OIC_LOG(ERROR, NET_DTLS_TAG, "Context is NULL");
- ca_mutex_unlock(g_dtlsContextMutex);
+ oc_mutex_unlock(g_dtlsContextMutex);
return CA_STATUS_FAILED;
}
provServerDeviceID, provServerDeviceIDLen, ownerPSK, ownerPSKSize))
{
OIC_LOG(ERROR, NET_DTLS_TAG, "Failed to DTLS PRF");
- ca_mutex_unlock(g_dtlsContextMutex);
+ oc_mutex_unlock(g_dtlsContextMutex);
return CA_STATUS_FAILED;
}
- ca_mutex_unlock(g_dtlsContextMutex);
+ oc_mutex_unlock(g_dtlsContextMutex);
OIC_LOG(DEBUG, NET_DTLS_TAG, "OUT CADtlsGenerateOwnerPSK");
//clear previous timer
unregisterTimer(timerId);
- ca_mutex_lock(g_dtlsContextMutex);
+ oc_mutex_lock(g_dtlsContextMutex);
//stop retransmission if context is invalid
if(NULL == g_caDtlsContext)
{
OIC_LOG(ERROR, NET_DTLS_TAG, "Context is NULL. Stop retransmission");
- ca_mutex_unlock(g_dtlsContextMutex);
+ oc_mutex_unlock(g_dtlsContextMutex);
return;
}
dtls_check_retransmit(g_caDtlsContext->dtlsContext, NULL);
- ca_mutex_unlock(g_dtlsContextMutex);
+ oc_mutex_unlock(g_dtlsContextMutex);
}
//start new timer
registerTimer(RETRANSMISSION_TIME, &timerId, CAStartRetransmit);
// Initialize mutex for DtlsContext
if (NULL == g_dtlsContextMutex)
{
- g_dtlsContextMutex = ca_mutex_new();
+ g_dtlsContextMutex = oc_mutex_new();
VERIFY_NON_NULL_RET(g_dtlsContextMutex, NET_DTLS_TAG, "malloc failed",
CA_MEMORY_ALLOC_FAILED);
}
}
// Lock DtlsContext mutex and create DtlsContext
- ca_mutex_lock(g_dtlsContextMutex);
+ oc_mutex_lock(g_dtlsContextMutex);
g_caDtlsContext = (stCADtlsContext_t *)OICCalloc(1, sizeof(stCADtlsContext_t));
if (NULL == g_caDtlsContext)
{
OIC_LOG(ERROR, NET_DTLS_TAG, "Context malloc failed");
- ca_mutex_unlock(g_dtlsContextMutex);
- ca_mutex_free(g_dtlsContextMutex);
+ oc_mutex_unlock(g_dtlsContextMutex);
+ oc_mutex_free(g_dtlsContextMutex);
return CA_MEMORY_ALLOC_FAILED;
}
CAFreePeerInfoList();
OICFree(g_caDtlsContext);
g_caDtlsContext = NULL;
- ca_mutex_unlock(g_dtlsContextMutex);
- ca_mutex_free(g_dtlsContextMutex);
+ oc_mutex_unlock(g_dtlsContextMutex);
+ oc_mutex_free(g_dtlsContextMutex);
return CA_STATUS_FAILED;
}
if (NULL == g_caDtlsContext->dtlsContext)
{
OIC_LOG(ERROR, NET_DTLS_TAG, "dtls_new_context failed");
- ca_mutex_unlock(g_dtlsContextMutex);
+ oc_mutex_unlock(g_dtlsContextMutex);
CAAdapterNetDtlsDeInit();
return CA_STATUS_FAILED;
}
g_caDtlsContext->callbacks.is_x509_active = CAIsX509Active;
#endif //__WITH_X509__*
dtls_set_handler(g_caDtlsContext->dtlsContext, &(g_caDtlsContext->callbacks));
- ca_mutex_unlock(g_dtlsContextMutex);
+ oc_mutex_unlock(g_dtlsContextMutex);
CAStartRetransmit();
VERIFY_NON_NULL_VOID(g_dtlsContextMutex, NET_DTLS_TAG, "context mutex is NULL");
//Lock DtlsContext mutex
- ca_mutex_lock(g_dtlsContextMutex);
+ oc_mutex_lock(g_dtlsContextMutex);
// Clear all lists
CAFreePeerInfoList();
g_caDtlsContext = NULL;
// Unlock DtlsContext mutex and de-initialize it
- ca_mutex_unlock(g_dtlsContextMutex);
- ca_mutex_free(g_dtlsContextMutex);
+ oc_mutex_unlock(g_dtlsContextMutex);
+ oc_mutex_free(g_dtlsContextMutex);
g_dtlsContextMutex = NULL;
OIC_LOG(DEBUG, NET_DTLS_TAG, "OUT");
addrInfo.ifIndex = 0;
addrInfo.size = CASizeOfAddrInfo(&addrInfo);
- ca_mutex_lock(g_dtlsContextMutex);
+ oc_mutex_lock(g_dtlsContextMutex);
if(NULL == g_caDtlsContext)
{
OIC_LOG(ERROR, NET_DTLS_TAG, "Context is NULL");
- ca_mutex_unlock(g_dtlsContextMutex);
+ oc_mutex_unlock(g_dtlsContextMutex);
return CA_STATUS_FAILED;
}
if (NULL == message)
{
OIC_LOG(ERROR, NET_DTLS_TAG, "calloc failed!");
- ca_mutex_unlock(g_dtlsContextMutex);
+ oc_mutex_unlock(g_dtlsContextMutex);
return CA_MEMORY_ALLOC_FAILED;
}
{
OIC_LOG(ERROR, NET_DTLS_TAG, "calloc failed!");
OICFree(message);
- ca_mutex_unlock(g_dtlsContextMutex);
+ oc_mutex_unlock(g_dtlsContextMutex);
return CA_MEMORY_ALLOC_FAILED;
}
memcpy(message->data, data, dataLen);
CAFreeCacheMsg(message);
}
OIC_LOG_V(DEBUG, NET_DTLS_TAG, "OUT Initiating Dtls session [%d]", result);
- ca_mutex_unlock(g_dtlsContextMutex);
+ oc_mutex_unlock(g_dtlsContextMutex);
return result;
}
- ca_mutex_unlock(g_dtlsContextMutex);
+ oc_mutex_unlock(g_dtlsContextMutex);
if (ret != DTLS_OK)
{
addrInfo.ifIndex = 0;
addrInfo.size = CASizeOfAddrInfo(&addrInfo);
- ca_mutex_lock(g_dtlsContextMutex);
+ oc_mutex_lock(g_dtlsContextMutex);
if (NULL == g_caDtlsContext)
{
OIC_LOG(ERROR, NET_DTLS_TAG, "Context is NULL");
- ca_mutex_unlock(g_dtlsContextMutex);
+ oc_mutex_unlock(g_dtlsContextMutex);
return CA_STATUS_FAILED;
}
eDtlsRet_t ret = CAAdapterNetDtlsDecryptInternal(&addrInfo, data, dataLen);
- ca_mutex_unlock(g_dtlsContextMutex);
+ oc_mutex_unlock(g_dtlsContextMutex);
if (DTLS_OK == ret || DTLS_HS_MSG == ret)
{
* @var g_mutexStateList
* @brief Mutex to synchronize device state list
*/
-static ca_mutex g_mutexStateList = NULL;
+static oc_mutex g_mutexStateList = NULL;
/**
* @var g_mutexObjectList
* @brief Mutex to synchronize device object list
*/
-static ca_mutex g_mutexObjectList = NULL;
+static oc_mutex g_mutexObjectList = NULL;
/**
* @var g_edrErrorHandler
{
if (g_mutexStateList)
{
- ca_mutex_free(g_mutexStateList);
+ oc_mutex_free(g_mutexStateList);
g_mutexStateList = NULL;
}
if (g_mutexObjectList)
{
- ca_mutex_free(g_mutexObjectList);
+ oc_mutex_free(g_mutexObjectList);
g_mutexObjectList = NULL;
}
}
static CAResult_t CAEDRCreateMutex()
{
- g_mutexStateList = ca_mutex_new();
+ g_mutexStateList = oc_mutex_new();
if (!g_mutexStateList)
{
OIC_LOG(ERROR, TAG, "Failed to created mutex!");
return CA_STATUS_FAILED;
}
- g_mutexObjectList = ca_mutex_new();
+ g_mutexObjectList = oc_mutex_new();
if (!g_mutexObjectList)
{
OIC_LOG(ERROR, TAG, "Failed to created mutex!");
}
(*env)->DeleteLocalRef(env, jni_address);
- ca_mutex_lock(g_mutexStateList);
+ oc_mutex_lock(g_mutexStateList);
CAEDRNativeCreateDeviceStateList();
- ca_mutex_unlock(g_mutexStateList);
+ oc_mutex_unlock(g_mutexStateList);
- ca_mutex_lock(g_mutexObjectList);
+ oc_mutex_lock(g_mutexObjectList);
CAEDRNativeCreateDeviceSocketList();
- ca_mutex_unlock(g_mutexObjectList);
+ oc_mutex_unlock(g_mutexObjectList);
if (isAttached)
{
(*env)->DeleteLocalRef(env, jni_obj_BTSocket);
return CA_STATUS_FAILED;
}
- ca_mutex_lock(g_mutexObjectList);
+ oc_mutex_lock(g_mutexObjectList);
CAEDRNativeAddDeviceSocketToList(env, jni_socket);
(*env)->DeleteGlobalRef(env, jni_socket);
(*env)->DeleteLocalRef(env, jni_obj_BTSocket);
- ca_mutex_unlock(g_mutexObjectList);
+ oc_mutex_unlock(g_mutexObjectList);
// update state
- ca_mutex_lock(g_mutexStateList);
+ oc_mutex_lock(g_mutexStateList);
CAEDRUpdateDeviceState(STATE_CONNECTED, address);
- ca_mutex_unlock(g_mutexStateList);
+ oc_mutex_unlock(g_mutexStateList);
OIC_LOG(DEBUG, TAG, "successfully connected");
CAEDRNativeRemoveDeviceSocket(env, jni_obj_socket);
// update state
- ca_mutex_lock(g_mutexStateList);
+ oc_mutex_lock(g_mutexStateList);
CAEDRUpdateDeviceState(STATE_DISCONNECTED, address);
- ca_mutex_unlock(g_mutexStateList);
+ oc_mutex_unlock(g_mutexStateList);
OIC_LOG_V(DEBUG, TAG, "disconnected with [%s]", address);
}
/**
* Mutex to synchronize receive server.
*/
-static ca_mutex g_mutexReceiveServer = NULL;
+static oc_mutex g_mutexReceiveServer = NULL;
/**
* Flag to control the Receive Unicast Data Thread.
/**
* Mutex to synchronize accept server.
*/
-static ca_mutex g_mutexAcceptServer = NULL;
+static oc_mutex g_mutexAcceptServer = NULL;
/**
* Flag to control the Accept Thread.
/**
* Mutex to synchronize server socket.
*/
-static ca_mutex g_mutexServerSocket = NULL;
+static oc_mutex g_mutexServerSocket = NULL;
/**
* Flag to control the server socket.
/**
* Mutex to synchronize device state list.
*/
-static ca_mutex g_mutexStateList = NULL;
+static oc_mutex g_mutexStateList = NULL;
/**
* Mutex to synchronize device object list.
*/
-static ca_mutex g_mutexObjectList = NULL;
+static oc_mutex g_mutexObjectList = NULL;
/**
* Thread context information for unicast, multicast and secured unicast server.
return;
}
- ca_mutex_lock(g_mutexServerSocket);
+ oc_mutex_lock(g_mutexServerSocket);
g_serverSocket = (*env)->NewGlobalRef(env, jni_obj_BTServerSocket);
- ca_mutex_unlock(g_mutexServerSocket);
+ oc_mutex_unlock(g_mutexServerSocket);
CAAdapterAcceptThreadContext_t *ctx = (CAAdapterAcceptThreadContext_t *) data;
// it should be initialized for restart accept thread
- ca_mutex_lock(g_mutexAcceptServer);
+ oc_mutex_lock(g_mutexAcceptServer);
g_stopAccept = false;
- ca_mutex_unlock(g_mutexAcceptServer);
+ oc_mutex_unlock(g_mutexAcceptServer);
while (true != *(ctx->stopFlag))
{
if (!CAEDRNativeIsEnableBTAdapter(env))
{
OIC_LOG(INFO, TAG, "BT adapter is not enabled");
- ca_mutex_lock(g_mutexAcceptServer);
+ oc_mutex_lock(g_mutexAcceptServer);
g_stopAccept = true;
- ca_mutex_unlock(g_mutexAcceptServer);
- ca_mutex_lock(g_mutexServerSocket);
+ oc_mutex_unlock(g_mutexAcceptServer);
+ oc_mutex_lock(g_mutexServerSocket);
g_serverSocket = NULL;
- ca_mutex_unlock(g_mutexServerSocket);
+ oc_mutex_unlock(g_mutexServerSocket);
}
else
{
{
CAEDRStopReceiveThread();
- ca_mutex_lock(g_mutexAcceptServer);
+ oc_mutex_lock(g_mutexAcceptServer);
g_stopAccept = true;
- ca_mutex_unlock(g_mutexAcceptServer);
+ oc_mutex_unlock(g_mutexAcceptServer);
if (!g_jvm)
{
{
if (g_mutexReceiveServer)
{
- ca_mutex_free(g_mutexReceiveServer);
+ oc_mutex_free(g_mutexReceiveServer);
g_mutexReceiveServer = NULL;
}
if (g_mutexAcceptServer)
{
- ca_mutex_free(g_mutexAcceptServer);
+ oc_mutex_free(g_mutexAcceptServer);
g_mutexAcceptServer = NULL;
}
if (g_mutexServerSocket)
{
- ca_mutex_free(g_mutexServerSocket);
+ oc_mutex_free(g_mutexServerSocket);
g_mutexServerSocket = NULL;
}
if (g_mutexStateList)
{
- ca_mutex_free(g_mutexStateList);
+ oc_mutex_free(g_mutexStateList);
g_mutexStateList = NULL;
}
if (g_mutexObjectList)
{
- ca_mutex_free(g_mutexObjectList);
+ oc_mutex_free(g_mutexObjectList);
g_mutexObjectList = NULL;
}
}
static CAResult_t CAEDRServerCreateMutex()
{
- g_mutexReceiveServer = ca_mutex_new();
+ g_mutexReceiveServer = oc_mutex_new();
if (!g_mutexReceiveServer)
{
OIC_LOG(ERROR, TAG, "Failed to created mutex!");
return CA_STATUS_FAILED;
}
- g_mutexAcceptServer = ca_mutex_new();
+ g_mutexAcceptServer = oc_mutex_new();
if (!g_mutexAcceptServer)
{
OIC_LOG(ERROR, TAG, "Failed to created mutex!");
return CA_STATUS_FAILED;
}
- g_mutexServerSocket = ca_mutex_new();
+ g_mutexServerSocket = oc_mutex_new();
if (!g_mutexServerSocket)
{
OIC_LOG(ERROR, TAG, "Failed to created mutex!");
return CA_STATUS_FAILED;
}
- g_mutexStateList = ca_mutex_new();
+ g_mutexStateList = oc_mutex_new();
if (!g_mutexStateList)
{
OIC_LOG(ERROR, TAG, "Failed to created mutex!");
return CA_STATUS_FAILED;
}
- g_mutexObjectList = ca_mutex_new();
+ g_mutexObjectList = oc_mutex_new();
if (!g_mutexObjectList)
{
OIC_LOG(ERROR, TAG, "Failed to created mutex!");
(*env)->ReleaseStringUTFChars(env, jni_address, localAddress);
}
- ca_mutex_lock(g_mutexStateList);
+ oc_mutex_lock(g_mutexStateList);
CAEDRNativeCreateDeviceStateList();
- ca_mutex_unlock(g_mutexStateList);
+ oc_mutex_unlock(g_mutexStateList);
- ca_mutex_lock(g_mutexObjectList);
+ oc_mutex_lock(g_mutexObjectList);
CAEDRNativeCreateDeviceSocketList();
- ca_mutex_unlock(g_mutexObjectList);
+ oc_mutex_unlock(g_mutexObjectList);
if (isAttached)
{
{
OIC_LOG(DEBUG, TAG, "CAEDRStartReceiveThread");
- ca_mutex_lock(g_mutexReceiveServer);
+ oc_mutex_lock(g_mutexReceiveServer);
/**
* The task to listen for data from unicast is added to the thread pool.
if (!ctx)
{
OIC_LOG(ERROR, TAG, "Out of memory!");
- ca_mutex_unlock(g_mutexReceiveServer);
+ oc_mutex_unlock(g_mutexReceiveServer);
return CA_MEMORY_ALLOC_FAILED;
}
if (CA_STATUS_OK != ca_thread_pool_add_task(g_threadPoolHandle, CAReceiveHandler, (void *) ctx))
{
OIC_LOG(ERROR, TAG, "Failed to create read thread!");
- ca_mutex_unlock(g_mutexReceiveServer);
+ oc_mutex_unlock(g_mutexReceiveServer);
OICFree((void *) ctx);
return CA_STATUS_FAILED;
}
- ca_mutex_unlock(g_mutexReceiveServer);
+ oc_mutex_unlock(g_mutexReceiveServer);
OIC_LOG(DEBUG, TAG, "OUT");
return CA_STATUS_OK;
{
OIC_LOG(DEBUG, TAG, "CAEDRStopReceiveThread");
- ca_mutex_lock(g_mutexReceiveServer);
+ oc_mutex_lock(g_mutexReceiveServer);
g_stopUnicast = true;
- ca_mutex_unlock(g_mutexReceiveServer);
+ oc_mutex_unlock(g_mutexReceiveServer);
return CA_STATUS_OK;
}
// update state to disconnect
// the socket will be close next read thread routine
- ca_mutex_lock(g_mutexStateList);
+ oc_mutex_lock(g_mutexStateList);
CAEDRUpdateDeviceState(STATE_DISCONNECTED, address);
- ca_mutex_unlock(g_mutexStateList);
+ oc_mutex_unlock(g_mutexStateList);
(*env)->ReleaseStringUTFChars(env, jni_str_address, address);
(*env)->DeleteLocalRef(env, jni_str_address);
return;
}
- ca_mutex_lock(g_mutexServerSocket);
+ oc_mutex_lock(g_mutexServerSocket);
g_serverSocket = (*env)->NewGlobalRef(env, jni_obj_BTServerSocket);
- ca_mutex_unlock(g_mutexServerSocket);
+ oc_mutex_unlock(g_mutexServerSocket);
}
jobject CAEDRNativeListen(JNIEnv *env)
OIC_LOG_V(INFO, TAG, "accept a new connection from [%s]", address);
// update state
- ca_mutex_lock(g_mutexStateList);
+ oc_mutex_lock(g_mutexStateList);
CAEDRUpdateDeviceState(STATE_CONNECTED, address);
- ca_mutex_unlock(g_mutexStateList);
+ oc_mutex_unlock(g_mutexStateList);
(*env)->ReleaseStringUTFChars(env, j_str_address, address);
(*env)->DeleteLocalRef(env, j_str_address);
return;
}
- ca_mutex_lock(g_mutexObjectList);
+ oc_mutex_lock(g_mutexObjectList);
CAEDRNativeAddDeviceSocketToList(env, jni_socket);
- ca_mutex_unlock(g_mutexObjectList);
+ oc_mutex_unlock(g_mutexObjectList);
(*env)->DeleteGlobalRef(env, jni_socket);
(*env)->DeleteLocalRef(env, jni_obj_BTSocket);
/**
* Mutex to synchronize the access to Bluetooth device information list.
*/
-static ca_mutex g_edrDeviceListMutex = NULL;
+static oc_mutex g_edrDeviceListMutex = NULL;
/**
* Peer Bluetooth device information list.
/**
* Mutex to synchronize the access to Pending multicast data list.
*/
-static ca_mutex g_multicastDataListMutex = NULL;
+static oc_mutex g_multicastDataListMutex = NULL;
/**
* To Store Adapter Mode information
{
case BT_SOCKET_CONNECTED:
{
- ca_mutex_lock(g_edrDeviceListMutex);
+ oc_mutex_lock(g_edrDeviceListMutex);
CAResult_t res = CAGetEDRDevice(g_edrDeviceList, connection->remote_address,
&device);
if (CA_STATUS_OK != res)
if (CA_STATUS_OK != res)
{
OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Failed add device to list ret[%d]", res);
- ca_mutex_unlock(g_edrDeviceListMutex);
+ oc_mutex_unlock(g_edrDeviceListMutex);
return;
}
if(!device)
{
OIC_LOG(ERROR, EDR_ADAPTER_TAG, "EDRDevice is null!");
- ca_mutex_unlock(g_edrDeviceListMutex);
+ oc_mutex_unlock(g_edrDeviceListMutex);
return;
}
device->socketFD = connection->socket_fd;
- ca_mutex_unlock(g_edrDeviceListMutex);
+ oc_mutex_unlock(g_edrDeviceListMutex);
return;
}
if(!device)
{
OIC_LOG(ERROR, EDR_ADAPTER_TAG, "EDRDevice is null!");
- ca_mutex_unlock(g_edrDeviceListMutex);
+ oc_mutex_unlock(g_edrDeviceListMutex);
return;
}
device->socketFD = connection->socket_fd;
// Remove the data which send from pending list
CARemoveEDRDataFromList(&device->pendingDataList);
}
- ca_mutex_unlock(g_edrDeviceListMutex);
+ oc_mutex_unlock(g_edrDeviceListMutex);
}
break;
case BT_SOCKET_DISCONNECTED:
{
- ca_mutex_lock(g_edrDeviceListMutex);
+ oc_mutex_lock(g_edrDeviceListMutex);
CARemoveEDRDeviceFromList(&g_edrDeviceList, connection->remote_address);
- ca_mutex_unlock(g_edrDeviceListMutex);
+ oc_mutex_unlock(g_edrDeviceListMutex);
}
break;
case BT_ADAPTER_DEVICE_DISCOVERY_FINISHED:
{
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "Discovery finished!");
- ca_mutex_lock(g_multicastDataListMutex);
+ oc_mutex_lock(g_multicastDataListMutex);
u_arraylist_destroy(g_multicastDataList);
g_multicastDataList = NULL;
- ca_mutex_unlock(g_multicastDataListMutex);
+ oc_mutex_unlock(g_multicastDataListMutex);
}
break;
OIC_EDR_SERVICE_ID))
{
// Check if the deivce is already in the list
- ca_mutex_lock(g_edrDeviceListMutex);
+ oc_mutex_lock(g_edrDeviceListMutex);
if (CA_STATUS_OK == CAGetEDRDevice(g_edrDeviceList,
discoveryInfo->remote_address, &device))
{
if(!device)
{
OIC_LOG(ERROR, EDR_ADAPTER_TAG, "EDRDevice is null!");
- ca_mutex_unlock(g_edrDeviceListMutex);
+ oc_mutex_unlock(g_edrDeviceListMutex);
return;
}
device->serviceSearched = true;
- ca_mutex_unlock(g_edrDeviceListMutex);
+ oc_mutex_unlock(g_edrDeviceListMutex);
return;
}
if (CA_STATUS_OK != res)
{
OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to add device to list!");
- ca_mutex_unlock(g_edrDeviceListMutex);
+ oc_mutex_unlock(g_edrDeviceListMutex);
return;
}
if(!device)
{
OIC_LOG(ERROR, EDR_ADAPTER_TAG, "EDRDevice is null!");
- ca_mutex_unlock(g_edrDeviceListMutex);
+ oc_mutex_unlock(g_edrDeviceListMutex);
return;
}
}
}
device->serviceSearched = true;
- ca_mutex_unlock(g_edrDeviceListMutex);
+ oc_mutex_unlock(g_edrDeviceListMutex);
}
else
{
return;
}
- ca_mutex_lock(g_edrDeviceListMutex);
+ oc_mutex_lock(g_edrDeviceListMutex);
EDRDevice *device = NULL;
CAResult_t res = CAGetEDRDevice(g_edrDeviceList, sdpInfo->remote_address, &device);
if (device->serviceSearched)
{
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "Service is already searched for this device!");
- ca_mutex_unlock(g_edrDeviceListMutex);
+ oc_mutex_unlock(g_edrDeviceListMutex);
return;
}
}
}
- ca_mutex_unlock(g_edrDeviceListMutex);
+ oc_mutex_unlock(g_edrDeviceListMutex);
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
}
if (!g_edrDeviceListMutex)
{
- g_edrDeviceListMutex = ca_mutex_new();
+ g_edrDeviceListMutex = oc_mutex_new();
}
if (!g_multicastDataListMutex)
{
- g_multicastDataListMutex = ca_mutex_new();
+ g_multicastDataListMutex = oc_mutex_new();
}
if (!g_edrDeviceListMutex || !g_multicastDataListMutex)
if (g_edrDeviceListMutex)
{
- ca_mutex_free(g_edrDeviceListMutex);
+ oc_mutex_free(g_edrDeviceListMutex);
g_edrDeviceListMutex = NULL;
}
if (g_multicastDataListMutex)
{
- ca_mutex_free(g_multicastDataListMutex);
+ oc_mutex_free(g_multicastDataListMutex);
g_multicastDataListMutex = NULL;
}
// Free EDRDevices list
if (g_edrDeviceListMutex)
{
- ca_mutex_lock(g_edrDeviceListMutex);
+ oc_mutex_lock(g_edrDeviceListMutex);
CADestroyEDRDeviceList(&g_edrDeviceList);
- ca_mutex_unlock(g_edrDeviceListMutex);
+ oc_mutex_unlock(g_edrDeviceListMutex);
}
if (g_multicastDataListMutex)
{
- ca_mutex_lock(g_multicastDataListMutex);
+ oc_mutex_lock(g_multicastDataListMutex);
u_arraylist_destroy(g_multicastDataList);
g_multicastDataList = NULL;
- ca_mutex_unlock(g_multicastDataListMutex);
+ oc_mutex_unlock(g_multicastDataListMutex);
}
// Free the mutex
{
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
- ca_mutex_lock(g_edrDeviceListMutex);
+ oc_mutex_lock(g_edrDeviceListMutex);
EDRDeviceList *cur = g_edrDeviceList;
while (cur != NULL)
}
}
- ca_mutex_unlock(g_edrDeviceListMutex);
+ oc_mutex_unlock(g_edrDeviceListMutex);
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
}
}
// Check the connection existence with remote device
- ca_mutex_lock(g_edrDeviceListMutex);
+ oc_mutex_lock(g_edrDeviceListMutex);
CAResult_t result = CAGetEDRDevice(g_edrDeviceList, remoteAddress, &device);
if (CA_STATUS_OK != result)
{
{
OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed create device and add to list!");
- ca_mutex_unlock(g_edrDeviceListMutex);
+ oc_mutex_unlock(g_edrDeviceListMutex);
return CA_STATUS_FAILED;
}
// Remove device from list
CARemoveEDRDeviceFromList(&g_edrDeviceList, remoteAddress);
- ca_mutex_unlock(g_edrDeviceListMutex);
+ oc_mutex_unlock(g_edrDeviceListMutex);
return CA_STATUS_FAILED;
}
}
// Remove device from list
CARemoveEDRDeviceFromList(&g_edrDeviceList, remoteAddress);
- ca_mutex_unlock(g_edrDeviceListMutex);
+ oc_mutex_unlock(g_edrDeviceListMutex);
return CA_STATUS_FAILED;
}
- ca_mutex_unlock(g_edrDeviceListMutex);
+ oc_mutex_unlock(g_edrDeviceListMutex);
if (-1 == device->socketFD)
{
}
// Send the packet to all OIC devices
- ca_mutex_lock(g_edrDeviceListMutex);
+ oc_mutex_lock(g_edrDeviceListMutex);
EDRDeviceList *curList = g_edrDeviceList;
CAResult_t result = CA_STATUS_FAILED;
}
}
- ca_mutex_unlock(g_edrDeviceListMutex);
+ oc_mutex_unlock(g_edrDeviceListMutex);
if(g_isDiscoveryServer)
{
multicastData->dataLength = dataLength;
// Add the data to pending multicast data list.
- ca_mutex_lock(g_multicastDataListMutex);
+ oc_mutex_lock(g_multicastDataListMutex);
if (NULL == g_multicastDataList)
{
g_multicastDataList = u_arraylist_create();
}
u_arraylist_add(g_multicastDataList, (void *)multicastData);
- ca_mutex_unlock(g_multicastDataListMutex);
+ oc_mutex_unlock(g_multicastDataListMutex);
}
}
}
// Get EDR device from list
- ca_mutex_lock(g_edrDeviceListMutex);
+ oc_mutex_lock(g_edrDeviceListMutex);
CAResult_t result = CAGetEDRDeviceBySocketId(g_edrDeviceList, data->socket_fd, &device);
if (CA_STATUS_OK != result)
{
OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Could not find the device!");
- ca_mutex_unlock(g_edrDeviceListMutex);
+ oc_mutex_unlock(g_edrDeviceListMutex);
return;
}
- ca_mutex_unlock(g_edrDeviceListMutex);
+ oc_mutex_unlock(g_edrDeviceListMutex);
//: TODO Need to check if 'check required for socket still connected or not'
if (!device)
static uint32_t g_targetCnt = 0;
static uint32_t g_currentSentCnt = 0;
static bool g_isFinishedSendData = false;
-static ca_mutex g_SendFinishMutex = NULL;
-static ca_mutex g_threadMutex = NULL;
-static ca_cond g_threadCond = NULL;
-static ca_cond g_deviceDescCond = NULL;
-
-static ca_mutex g_threadSendMutex = NULL;
-static ca_mutex g_threadWriteCharacteristicMutex = NULL;
-static ca_cond g_threadWriteCharacteristicCond = NULL;
+static oc_mutex g_SendFinishMutex = NULL;
+static oc_mutex g_threadMutex = NULL;
+static oc_cond g_threadCond = NULL;
+static oc_cond g_deviceDescCond = NULL;
+
+static oc_mutex g_threadSendMutex = NULL;
+static oc_mutex g_threadWriteCharacteristicMutex = NULL;
+static oc_cond g_threadWriteCharacteristicCond = NULL;
static bool g_isSignalSetFlag = false;
-static ca_mutex g_bleReqRespClientCbMutex = NULL;
-static ca_mutex g_bleServerBDAddressMutex = NULL;
+static oc_mutex g_bleReqRespClientCbMutex = NULL;
+static oc_mutex g_bleServerBDAddressMutex = NULL;
-static ca_mutex g_deviceListMutex = NULL;
-static ca_mutex g_gattObjectMutex = NULL;
-static ca_mutex g_deviceStateListMutex = NULL;
+static oc_mutex g_deviceListMutex = NULL;
+static oc_mutex g_gattObjectMutex = NULL;
+static oc_mutex g_deviceStateListMutex = NULL;
-static ca_mutex g_deviceScanRetryDelayMutex = NULL;
-static ca_cond g_deviceScanRetryDelayCond = NULL;
+static oc_mutex g_deviceScanRetryDelayMutex = NULL;
+static oc_cond g_deviceScanRetryDelayCond = NULL;
-static ca_mutex g_threadScanIntervalMutex = NULL;
-static ca_cond g_threadScanIntervalCond = NULL;
+static oc_mutex g_threadScanIntervalMutex = NULL;
+static oc_cond g_threadScanIntervalCond = NULL;
-static ca_mutex g_threadSendStateMutex = NULL;
+static oc_mutex g_threadSendStateMutex = NULL;
static int32_t g_scanIntervalTime = WAIT_TIME_SCAN_INTERVAL_DEFAULT;
static int32_t g_scanIntervalTimePrev = WAIT_TIME_SCAN_INTERVAL_DEFAULT;
{
// restart scan with interval
CALEClientSetScanInterval(intervalTime, workingCount);
- ca_cond_signal(g_threadScanIntervalCond);
+ oc_cond_signal(g_threadScanIntervalCond);
}
static void CALEScanThread(void* object)
isAttached = true;
}
- ca_mutex_lock(g_threadScanIntervalMutex);
+ oc_mutex_lock(g_threadScanIntervalMutex);
while(g_isWorkingScanThread)
{
OIC_LOG(DEBUG, TAG, "scan waiting time out");
}
OIC_LOG_V(DEBUG, TAG, "wait for Scan Interval Time during %d sec", g_scanIntervalTime);
- if (CA_WAIT_SUCCESS == ca_cond_wait_for(g_threadScanIntervalCond,
+ if (OC_WAIT_SUCCESS == oc_cond_wait_for(g_threadScanIntervalCond,
g_threadScanIntervalMutex,
g_scanIntervalTime * MICROSECS_PER_SEC))
{
}
}
}
- ca_mutex_unlock(g_threadScanIntervalMutex);
+ oc_mutex_unlock(g_threadScanIntervalMutex);
if (isAttached)
{
void CALEClientStopScanWithInterval()
{
g_isWorkingScanThread = false;
- ca_cond_signal(g_threadScanIntervalCond);
+ oc_cond_signal(g_threadScanIntervalCond);
}
//getting jvm
return ret;
}
- g_deviceDescCond = ca_cond_new();
+ g_deviceDescCond = oc_cond_new();
// init mutex for send logic
- g_threadCond = ca_cond_new();
- g_threadWriteCharacteristicCond = ca_cond_new();
- g_deviceScanRetryDelayCond = ca_cond_new();
- g_threadScanIntervalCond = ca_cond_new();
+ g_threadCond = oc_cond_new();
+ g_threadWriteCharacteristicCond = oc_cond_new();
+ g_deviceScanRetryDelayCond = oc_cond_new();
+ g_threadScanIntervalCond = oc_cond_new();
CALEClientCreateDeviceList();
CALEClientJNISetContext();
CALEClientTerminateGattMutexVariables();
CALEClientDestroyJniInterface();
- ca_cond_free(g_deviceDescCond);
- ca_cond_free(g_threadCond);
- ca_cond_free(g_threadWriteCharacteristicCond);
- ca_cond_free(g_deviceScanRetryDelayCond);
- ca_cond_free(g_threadScanIntervalCond);
+ oc_cond_free(g_deviceDescCond);
+ oc_cond_free(g_threadCond);
+ oc_cond_free(g_threadWriteCharacteristicCond);
+ oc_cond_free(g_deviceScanRetryDelayCond);
+ oc_cond_free(g_threadScanIntervalCond);
g_deviceDescCond = NULL;
g_threadCond = NULL;
for (size_t i = 0; i < RETRIES; ++i)
{
OIC_LOG(DEBUG, TAG, "waiting for target device");
- if (ca_cond_wait_for(g_deviceDescCond,
+ if (oc_cond_wait_for(g_deviceDescCond,
g_threadSendMutex,
- TIMEOUT) == CA_WAIT_SUCCESS)
+ TIMEOUT) == OC_WAIT_SUCCESS)
{
- ca_mutex_lock(g_deviceListMutex);
+ oc_mutex_lock(g_deviceListMutex);
size_t scannedDeviceLen = u_arraylist_length(g_deviceList);
- ca_mutex_unlock(g_deviceListMutex);
+ oc_mutex_unlock(g_deviceListMutex);
if (0 < scannedDeviceLen)
{
{
OIC_LOG(INFO, TAG, "waiting..");
- ca_mutex_lock(g_deviceScanRetryDelayMutex);
- if (ca_cond_wait_for(g_deviceScanRetryDelayCond,
+ oc_mutex_lock(g_deviceScanRetryDelayMutex);
+ if (oc_cond_wait_for(g_deviceScanRetryDelayCond,
g_deviceScanRetryDelayMutex,
- MICROSECS_PER_SEC) == CA_WAIT_SUCCESS)
+ MICROSECS_PER_SEC) == OC_WAIT_SUCCESS)
{
OIC_LOG(INFO, TAG, "finish to waiting for target device");
- ca_mutex_unlock(g_deviceScanRetryDelayMutex);
+ oc_mutex_unlock(g_deviceScanRetryDelayMutex);
break;
}
- ca_mutex_unlock(g_deviceScanRetryDelayMutex);
+ oc_mutex_unlock(g_deviceScanRetryDelayMutex);
// time out
// checking whether a target device is found while waiting for time-out.
isAttached = true;
}
- ca_mutex_lock(g_threadSendMutex);
+ oc_mutex_lock(g_threadSendMutex);
CALEClientSetSendFinishFlag(false);
// wait for finish to send data through "CALeGattServicesDiscoveredCallback"
// if there is no connection state.
- ca_mutex_lock(g_threadMutex);
+ oc_mutex_lock(g_threadMutex);
if (!g_isFinishedSendData)
{
OIC_LOG(DEBUG, TAG, "waiting send finish signal");
- ca_cond_wait(g_threadCond, g_threadMutex);
+ oc_cond_wait(g_threadCond, g_threadMutex);
OIC_LOG(DEBUG, TAG, "the data was sent");
}
- ca_mutex_unlock(g_threadMutex);
+ oc_mutex_unlock(g_threadMutex);
if (isAttached)
{
if (CA_STATUS_OK != ret)
{
OIC_LOG(ERROR, TAG, "CALEClientStartScanWithInterval has failed");
- ca_mutex_unlock(g_threadSendMutex);
+ oc_mutex_unlock(g_threadSendMutex);
return ret;
}
- ca_mutex_unlock(g_threadSendMutex);
+ oc_mutex_unlock(g_threadSendMutex);
OIC_LOG(INFO, TAG, "unicast - send logic has finished");
if (CALEClientIsValidState(address, CA_LE_SEND_STATE,
STATE_SEND_SUCCESS))
if (CA_STATUS_OK != ret)
{
OIC_LOG(ERROR, TAG, "CALEClientStartScanWithInterval has failed");
- ca_mutex_unlock(g_threadSendMutex);
+ oc_mutex_unlock(g_threadSendMutex);
if (isAttached)
{
(*g_jvm)->DetachCurrentThread(g_jvm);
(*g_jvm)->DetachCurrentThread(g_jvm);
}
- ca_mutex_unlock(g_threadSendMutex);
+ oc_mutex_unlock(g_threadSendMutex);
return CA_SEND_FAILED;
}
return CA_STATUS_FAILED;
}
- ca_mutex_lock(g_threadSendMutex);
+ oc_mutex_lock(g_threadSendMutex);
CALEClientSetSendFinishFlag(false);
OIC_LOG(DEBUG, TAG, "connection routine is finished for multicast");
// wait for finish to send data through "CALeGattServicesDiscoveredCallback"
- ca_mutex_lock(g_threadMutex);
+ oc_mutex_lock(g_threadMutex);
if (!g_isFinishedSendData)
{
OIC_LOG(DEBUG, TAG, "waiting send finish signal");
- ca_cond_wait(g_threadCond, g_threadMutex);
+ oc_cond_wait(g_threadCond, g_threadMutex);
OIC_LOG(DEBUG, TAG, "the data was sent");
}
- ca_mutex_unlock(g_threadMutex);
+ oc_mutex_unlock(g_threadMutex);
// start LE Scan again
res = CALEClientStartScanWithInterval();
if (CA_STATUS_OK != res)
{
OIC_LOG(ERROR, TAG, "CALEClientStartScanWithInterval has failed");
- ca_mutex_unlock(g_threadSendMutex);
+ oc_mutex_unlock(g_threadSendMutex);
return res;
}
- ca_mutex_unlock(g_threadSendMutex);
+ oc_mutex_unlock(g_threadSendMutex);
OIC_LOG(DEBUG, TAG, "OUT - CALEClientSendMulticastMessageImpl");
return CA_STATUS_OK;
if (CA_STATUS_OK != res)
{
OIC_LOG(ERROR, TAG, "CALEClientStartScanWithInterval has failed");
- ca_mutex_unlock(g_threadSendMutex);
+ oc_mutex_unlock(g_threadSendMutex);
return res;
}
- ca_mutex_unlock(g_threadSendMutex);
+ oc_mutex_unlock(g_threadSendMutex);
OIC_LOG(DEBUG, TAG, "OUT - CALEClientSendMulticastMessageImpl");
return CA_SEND_FAILED;
}
OIC_LOG(ERROR, TAG, "address is not available");
return CA_STATUS_FAILED;
}
- ca_mutex_lock(g_deviceStateListMutex);
+ oc_mutex_lock(g_deviceStateListMutex);
state = CALEClientGetStateInfo(address);
- ca_mutex_unlock(g_deviceStateListMutex);
+ oc_mutex_unlock(g_deviceStateListMutex);
}
if (!state)
VERIFY_NON_NULL(env, TAG, "env");
VERIFY_NON_NULL(jni_address, TAG, "jni_address");
- ca_mutex_lock(g_deviceStateListMutex);
+ oc_mutex_lock(g_deviceStateListMutex);
char* address = (char*)(*env)->GetStringUTFChars(env, jni_address, NULL);
if (!address)
{
OIC_LOG(ERROR, TAG, "curState is null");
(*env)->ReleaseStringUTFChars(env, jni_address, address);
- ca_mutex_unlock(g_deviceStateListMutex);
+ oc_mutex_unlock(g_deviceStateListMutex);
return CA_STATUS_FAILED;
}
OIC_LOG_V(INFO, TAG, "%d flag is set : %d", state_idx, flag);
}
(*env)->ReleaseStringUTFChars(env, jni_address, address);
- ca_mutex_unlock(g_deviceStateListMutex);
+ oc_mutex_unlock(g_deviceStateListMutex);
OIC_LOG(DEBUG, TAG, "OUT - CALEClientSetFlagToState");
return CA_STATUS_OK;
}
VERIFY_NON_NULL_RET(env, TAG, "env", false);
VERIFY_NON_NULL_RET(jni_address, TAG, "jni_address", false);
- ca_mutex_lock(g_deviceStateListMutex);
+ oc_mutex_lock(g_deviceStateListMutex);
char* address = (char*)(*env)->GetStringUTFChars(env, jni_address, NULL);
if (!address)
{
OIC_LOG(ERROR, TAG, "address is not available");
- ca_mutex_unlock(g_deviceStateListMutex);
+ oc_mutex_unlock(g_deviceStateListMutex);
return JNI_FALSE;
}
if(!curState)
{
OIC_LOG(INFO, TAG, "there is no information. auto connect flag is false");
- ca_mutex_unlock(g_deviceStateListMutex);
+ oc_mutex_unlock(g_deviceStateListMutex);
return JNI_FALSE;
}
default:
break;
}
- ca_mutex_unlock(g_deviceStateListMutex);
+ oc_mutex_unlock(g_deviceStateListMutex);
OIC_LOG_V(INFO, TAG, "%d flag is %d", state_idx, ret);
OIC_LOG(DEBUG, TAG, "OUT - CALEClientGetFlagFromState");
VERIFY_NON_NULL(env, TAG, "env is null");
VERIFY_NON_NULL(bluetoothDevice, TAG, "bluetoothDevice is null");
- ca_mutex_lock(g_threadSendMutex);
+ oc_mutex_lock(g_threadSendMutex);
jstring jni_address = CALEGetAddressFromBTDevice(env, bluetoothDevice);
if (!jni_address)
{
OIC_LOG(ERROR, TAG, "jni_address is not available");
- ca_mutex_unlock(g_threadSendMutex);
+ oc_mutex_unlock(g_threadSendMutex);
return CA_STATUS_FAILED;
}
if (!address)
{
OIC_LOG(ERROR, TAG, "address is not available");
- ca_mutex_unlock(g_threadSendMutex);
+ oc_mutex_unlock(g_threadSendMutex);
return CA_STATUS_FAILED;
}
res = CA_STATUS_FAILED;
}
}
- ca_mutex_unlock(g_threadSendMutex);
+ oc_mutex_unlock(g_threadSendMutex);
return res;
}
return CA_STATUS_FAILED;
}
- ca_mutex_lock(g_threadSendStateMutex);
+ oc_mutex_lock(g_threadSendStateMutex);
if (CALEClientIsValidState(address, CA_LE_SEND_STATE, STATE_SENDING))
{
OIC_LOG(INFO, TAG, "current state is SENDING");
(*env)->ReleaseStringUTFChars(env, jni_address, address);
- ca_mutex_unlock(g_threadSendStateMutex);
+ oc_mutex_unlock(g_threadSendStateMutex);
return CA_STATUS_OK;
}
OIC_LOG(ERROR, TAG, "CALEClientUpdateDeviceState has failed");
(*env)->ReleaseStringUTFChars(env, jni_address, address);
CALEClientSendFinish(env, gatt);
- ca_mutex_unlock(g_threadSendStateMutex);
+ oc_mutex_unlock(g_threadSendStateMutex);
return CA_STATUS_FAILED;
}
(*env)->ReleaseStringUTFChars(env, jni_address, address);
- ca_mutex_unlock(g_threadSendStateMutex);
+ oc_mutex_unlock(g_threadSendStateMutex);
// send data
jobject jni_obj_character = CALEClientCreateGattCharacteristic(env, gatt, g_sendBuffer);
// wait for callback for write Characteristic with success to sent data
OIC_LOG_V(DEBUG, TAG, "callback flag is %d", g_isSignalSetFlag);
- ca_mutex_lock(g_threadWriteCharacteristicMutex);
+ oc_mutex_lock(g_threadWriteCharacteristicMutex);
if (!g_isSignalSetFlag)
{
OIC_LOG(DEBUG, TAG, "wait for callback to notify writeCharacteristic is success");
- if (CA_WAIT_SUCCESS != ca_cond_wait_for(g_threadWriteCharacteristicCond,
+ if (OC_WAIT_SUCCESS != oc_cond_wait_for(g_threadWriteCharacteristicCond,
g_threadWriteCharacteristicMutex,
WAIT_TIME_WRITE_CHARACTERISTIC))
{
OIC_LOG(ERROR, TAG, "there is no response. write has failed");
g_isSignalSetFlag = false;
- ca_mutex_unlock(g_threadWriteCharacteristicMutex);
+ oc_mutex_unlock(g_threadWriteCharacteristicMutex);
return CA_STATUS_FAILED;
}
}
// reset flag set by writeCharacteristic Callback
g_isSignalSetFlag = false;
- ca_mutex_unlock(g_threadWriteCharacteristicMutex);
+ oc_mutex_unlock(g_threadWriteCharacteristicMutex);
CALEClientUpdateSendCnt(env);
OIC_LOG(DEBUG, TAG, "CALEClientCreateScanDeviceList");
VERIFY_NON_NULL_VOID(env, TAG, "env is null");
- ca_mutex_lock(g_deviceListMutex);
+ oc_mutex_lock(g_deviceListMutex);
// create new object array
if (g_deviceList == NULL)
{
g_deviceList = u_arraylist_create();
}
- ca_mutex_unlock(g_deviceListMutex);
+ oc_mutex_unlock(g_deviceListMutex);
}
CAResult_t CALEClientAddScanDeviceToList(JNIEnv *env, jobject device)
VERIFY_NON_NULL(device, TAG, "device is null");
VERIFY_NON_NULL(env, TAG, "env is null");
- ca_mutex_lock(g_deviceListMutex);
+ oc_mutex_lock(g_deviceListMutex);
if (!g_deviceList)
{
OIC_LOG(ERROR, TAG, "gdevice_list is null");
CALEClientStopScanWithInterval();
- ca_mutex_unlock(g_deviceListMutex);
+ oc_mutex_unlock(g_deviceListMutex);
return CA_STATUS_FAILED;
}
if (!jni_remoteAddress)
{
OIC_LOG(ERROR, TAG, "jni_remoteAddress is null");
- ca_mutex_unlock(g_deviceListMutex);
+ oc_mutex_unlock(g_deviceListMutex);
return CA_STATUS_FAILED;
}
{
OIC_LOG(ERROR, TAG, "remoteAddress is null");
(*env)->DeleteLocalRef(env, jni_remoteAddress);
- ca_mutex_unlock(g_deviceListMutex);
+ oc_mutex_unlock(g_deviceListMutex);
return CA_STATUS_FAILED;
}
{
jobject gdevice = (*env)->NewGlobalRef(env, device);
u_arraylist_add(g_deviceList, gdevice);
- ca_cond_signal(g_deviceDescCond);
+ oc_cond_signal(g_deviceDescCond);
OIC_LOG_V(DEBUG, TAG, "Added a new BT Device in deviceList [%s]", remoteAddress);
}
(*env)->ReleaseStringUTFChars(env, jni_remoteAddress, remoteAddress);
(*env)->DeleteLocalRef(env, jni_remoteAddress);
- ca_mutex_unlock(g_deviceListMutex);
+ oc_mutex_unlock(g_deviceListMutex);
return CA_STATUS_OK;
}
OIC_LOG(DEBUG, TAG, "CALEClientRemoveAllScanDevices");
VERIFY_NON_NULL(env, TAG, "env is null");
- ca_mutex_lock(g_deviceListMutex);
+ oc_mutex_lock(g_deviceListMutex);
if (!g_deviceList)
{
OIC_LOG(ERROR, TAG, "g_deviceList is null");
- ca_mutex_unlock(g_deviceListMutex);
+ oc_mutex_unlock(g_deviceListMutex);
return CA_STATUS_FAILED;
}
OICFree(g_deviceList);
g_deviceList = NULL;
- ca_mutex_unlock(g_deviceListMutex);
+ oc_mutex_unlock(g_deviceListMutex);
return CA_STATUS_OK;
}
VERIFY_NON_NULL(address, TAG, "address is null");
VERIFY_NON_NULL(env, TAG, "env is null");
- ca_mutex_lock(g_deviceListMutex);
+ oc_mutex_lock(g_deviceListMutex);
if (!g_deviceList)
{
OIC_LOG(ERROR, TAG, "g_deviceList is null");
- ca_mutex_unlock(g_deviceListMutex);
+ oc_mutex_unlock(g_deviceListMutex);
return CA_STATUS_FAILED;
}
if (!jarrayObj)
{
OIC_LOG(ERROR, TAG, "jarrayObj is null");
- ca_mutex_unlock(g_deviceListMutex);
+ oc_mutex_unlock(g_deviceListMutex);
return CA_STATUS_FAILED;
}
if (!jni_setAddress)
{
OIC_LOG(ERROR, TAG, "jni_setAddress is null");
- ca_mutex_unlock(g_deviceListMutex);
+ oc_mutex_unlock(g_deviceListMutex);
return CA_STATUS_FAILED;
}
if (!setAddress)
{
OIC_LOG(ERROR, TAG, "setAddress is null");
- ca_mutex_unlock(g_deviceListMutex);
+ oc_mutex_unlock(g_deviceListMutex);
return CA_STATUS_FAILED;
}
{
OIC_LOG(ERROR, TAG, "remoteAddress is null");
(*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
- ca_mutex_unlock(g_deviceListMutex);
+ oc_mutex_unlock(g_deviceListMutex);
return CA_STATUS_FAILED;
}
if (NULL == u_arraylist_remove(g_deviceList, index))
{
OIC_LOG(ERROR, TAG, "List removal failed.");
- ca_mutex_unlock(g_deviceListMutex);
+ oc_mutex_unlock(g_deviceListMutex);
return CA_STATUS_FAILED;
}
- ca_mutex_unlock(g_deviceListMutex);
+ oc_mutex_unlock(g_deviceListMutex);
return CA_STATUS_OK;
}
(*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
(*env)->ReleaseStringUTFChars(env, address, remoteAddress);
}
- ca_mutex_unlock(g_deviceListMutex);
+ oc_mutex_unlock(g_deviceListMutex);
OIC_LOG(DEBUG, TAG, "There are no object in the device list");
return CA_STATUS_OK;
VERIFY_NON_NULL(env, TAG, "env is null");
VERIFY_NON_NULL(gatt, TAG, "gatt is null");
- ca_mutex_lock(g_gattObjectMutex);
+ oc_mutex_lock(g_gattObjectMutex);
if (!g_gattObjectList)
{
OIC_LOG(ERROR, TAG, "g_gattObjectList is not available");
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
return CA_STATUS_FAILED;
}
if (!jni_remoteAddress)
{
OIC_LOG(ERROR, TAG, "jni_remoteAddress is null");
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
return CA_STATUS_FAILED;
}
if (!remoteAddress)
{
OIC_LOG(ERROR, TAG, "remoteAddress is null");
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
return CA_STATUS_FAILED;
}
}
(*env)->ReleaseStringUTFChars(env, jni_remoteAddress, remoteAddress);
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
return CA_STATUS_OK;
}
VERIFY_NON_NULL_RET(env, TAG, "env is null", NULL);
VERIFY_NON_NULL_RET(remoteAddress, TAG, "remoteAddress is null", NULL);
- ca_mutex_lock(g_gattObjectMutex);
+ oc_mutex_lock(g_gattObjectMutex);
uint32_t length = u_arraylist_length(g_gattObjectList);
for (uint32_t index = 0; index < length; index++)
{
if (!jarrayObj)
{
OIC_LOG(ERROR, TAG, "jarrayObj is null");
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
return NULL;
}
if (!jni_setAddress)
{
OIC_LOG(ERROR, TAG, "jni_setAddress is null");
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
return NULL;
}
if (!setAddress)
{
OIC_LOG(ERROR, TAG, "setAddress is null");
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
return NULL;
}
{
OIC_LOG(DEBUG, TAG, "the device is already set");
(*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
return jarrayObj;
}
(*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
}
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
OIC_LOG(DEBUG, TAG, "There are no the gatt object in list");
return NULL;
}
OIC_LOG(DEBUG, TAG, "CALEClientRemoveAllGattObjs");
VERIFY_NON_NULL(env, TAG, "env is null");
- ca_mutex_lock(g_gattObjectMutex);
+ oc_mutex_lock(g_gattObjectMutex);
if (!g_gattObjectList)
{
OIC_LOG(DEBUG, TAG, "already removed for g_gattObjectList");
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
return CA_STATUS_OK;
}
OICFree(g_gattObjectList);
g_gattObjectList = NULL;
OIC_LOG(INFO, TAG, "g_gattObjectList is removed");
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
return CA_STATUS_OK;
}
VERIFY_NON_NULL(gatt, TAG, "gatt is null");
VERIFY_NON_NULL(env, TAG, "env is null");
- ca_mutex_lock(g_gattObjectMutex);
+ oc_mutex_lock(g_gattObjectMutex);
if (!g_gattObjectList)
{
OIC_LOG(DEBUG, TAG, "already removed for g_gattObjectList");
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
return CA_STATUS_OK;
}
if (!jarrayObj)
{
OIC_LOG(ERROR, TAG, "jarrayObj is null");
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
return CA_STATUS_FAILED;
}
if (!jni_setAddress)
{
OIC_LOG(ERROR, TAG, "jni_setAddress is null");
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
return CA_STATUS_FAILED;
}
if (!setAddress)
{
OIC_LOG(ERROR, TAG, "setAddress is null");
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
return CA_STATUS_FAILED;
}
{
OIC_LOG(ERROR, TAG, "jni_remoteAddress is null");
(*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
return CA_STATUS_FAILED;
}
{
OIC_LOG(ERROR, TAG, "remoteAddress is null");
(*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
return CA_STATUS_FAILED;
}
if (NULL == u_arraylist_remove(g_gattObjectList, index))
{
OIC_LOG(ERROR, TAG, "List removal failed.");
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
return CA_STATUS_FAILED;
}
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
return CA_STATUS_OK;
}
(*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
(*env)->ReleaseStringUTFChars(env, jni_remoteAddress, remoteAddress);
}
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
OIC_LOG(DEBUG, TAG, "there are no target object");
return CA_STATUS_OK;
}
VERIFY_NON_NULL(addr, TAG, "addr is null");
VERIFY_NON_NULL(env, TAG, "env is null");
- ca_mutex_lock(g_gattObjectMutex);
+ oc_mutex_lock(g_gattObjectMutex);
if (!g_gattObjectList)
{
OIC_LOG(DEBUG, TAG, "already removed for g_gattObjectList");
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
return CA_STATUS_OK;
}
if (!jarrayObj)
{
OIC_LOG(ERROR, TAG, "jarrayObj is null");
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
return CA_STATUS_FAILED;
}
if (!jni_setAddress)
{
OIC_LOG(ERROR, TAG, "jni_setAddress is null");
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
return CA_STATUS_FAILED;
}
if (!setAddress)
{
OIC_LOG(ERROR, TAG, "setAddress is null");
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
return CA_STATUS_FAILED;
}
{
OIC_LOG(ERROR, TAG, "remoteAddress is null");
(*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
return CA_STATUS_FAILED;
}
if (NULL == u_arraylist_remove(g_gattObjectList, index))
{
OIC_LOG(ERROR, TAG, "List removal failed.");
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
return CA_STATUS_FAILED;
}
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
return CA_STATUS_OK;
}
(*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
(*env)->ReleaseStringUTFChars(env, addr, remoteAddress);
}
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
OIC_LOG(DEBUG, TAG, "there are no target object");
return CA_STATUS_FAILED;
}
return NULL;
}
- ca_mutex_lock(g_gattObjectMutex);
+ oc_mutex_lock(g_gattObjectMutex);
size_t length = u_arraylist_length(g_gattObjectList);
OIC_LOG_V(DEBUG, TAG, "length of gattObjectList : %d", length);
jobject jarrayObj = (jobject) u_arraylist_get(g_gattObjectList, index);
if (!jarrayObj)
{
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
OIC_LOG(ERROR, TAG, "jarrayObj is null");
(*env)->ReleaseStringUTFChars(env, jni_btTargetAddress, targetAddress);
return NULL;
jobject jni_obj_device = (*env)->CallObjectMethod(env, jarrayObj, jni_mid_getDevice);
if (!jni_obj_device)
{
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
OIC_LOG(ERROR, TAG, "jni_obj_device is null");
(*env)->ReleaseStringUTFChars(env, jni_btTargetAddress, targetAddress);
return NULL;
jstring jni_btAddress = CALEGetAddressFromBTDevice(env, jni_obj_device);
if (!jni_btAddress)
{
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
OIC_LOG(ERROR, TAG, "CALEGetAddressFromBTDevice has failed");
(*env)->ReleaseStringUTFChars(env, jni_btTargetAddress, targetAddress);
return NULL;
const char* btAddress = (*env)->GetStringUTFChars(env, jni_btAddress, NULL);
if (!btAddress)
{
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
OIC_LOG(ERROR, TAG, "btAddress is not available");
(*env)->ReleaseStringUTFChars(env, jni_btTargetAddress, targetAddress);
return NULL;
{
OIC_LOG(ERROR, TAG, "jni_LEAddress is null");
}
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
(*env)->ReleaseStringUTFChars(env, jni_btTargetAddress, targetAddress);
(*env)->ReleaseStringUTFChars(env, jni_btAddress, btAddress);
(*env)->DeleteLocalRef(env, jni_btAddress);
(*env)->DeleteLocalRef(env, jni_btAddress);
(*env)->DeleteLocalRef(env, jni_obj_device);
}
- ca_mutex_unlock(g_gattObjectMutex);
+ oc_mutex_unlock(g_gattObjectMutex);
(*env)->ReleaseStringUTFChars(env, jni_btTargetAddress, targetAddress);
OIC_LOG_V(DEBUG, TAG, "[%s] doesn't exist in gattObjectList", targetAddress);
return CA_STATUS_FAILED;
}
- ca_mutex_lock(g_deviceStateListMutex);
+ oc_mutex_lock(g_deviceStateListMutex);
if (CALEClientIsDeviceInList(address))
{
if(!curState)
{
OIC_LOG(ERROR, TAG, "curState is null");
- ca_mutex_unlock(g_deviceStateListMutex);
+ oc_mutex_unlock(g_deviceStateListMutex);
return CA_STATUS_FAILED;
}
if (strlen(address) > CA_MACADDR_SIZE)
{
OIC_LOG(ERROR, TAG, "address is not proper");
- ca_mutex_unlock(g_deviceStateListMutex);
+ oc_mutex_unlock(g_deviceStateListMutex);
return CA_STATUS_INVALID_PARAM;
}
if (!newstate)
{
OIC_LOG(ERROR, TAG, "out of memory");
- ca_mutex_unlock(g_deviceStateListMutex);
+ oc_mutex_unlock(g_deviceStateListMutex);
return CA_MEMORY_ALLOC_FAILED;
}
newstate->autoConnectFlag);
u_arraylist_add(g_deviceStateList, newstate); // update new state
}
- ca_mutex_unlock(g_deviceStateListMutex);
+ oc_mutex_unlock(g_deviceStateListMutex);
return CA_STATUS_OK;
}
{
OIC_LOG(DEBUG, TAG, "CALEClientRemoveAllDeviceState");
- ca_mutex_lock(g_deviceStateListMutex);
+ oc_mutex_lock(g_deviceStateListMutex);
if (!g_deviceStateList)
{
OIC_LOG(ERROR, TAG, "g_deviceStateList is null");
- ca_mutex_unlock(g_deviceStateListMutex);
+ oc_mutex_unlock(g_deviceStateListMutex);
return CA_STATUS_FAILED;
}
OICFree(g_deviceStateList);
g_deviceStateList = NULL;
- ca_mutex_unlock(g_deviceStateListMutex);
+ oc_mutex_unlock(g_deviceStateListMutex);
return CA_STATUS_OK;
}
{
OIC_LOG(DEBUG, TAG, "CALEClientResetDeviceStateForAll");
- ca_mutex_lock(g_deviceStateListMutex);
+ oc_mutex_lock(g_deviceStateListMutex);
if (!g_deviceStateList)
{
OIC_LOG(ERROR, TAG, "g_deviceStateList is null");
- ca_mutex_unlock(g_deviceStateListMutex);
+ oc_mutex_unlock(g_deviceStateListMutex);
return CA_STATUS_FAILED;
}
state->connectedState = STATE_DISCONNECTED;
state->sendState = STATE_SEND_NONE;
}
- ca_mutex_unlock(g_deviceStateListMutex);
+ oc_mutex_unlock(g_deviceStateListMutex);
return CA_STATUS_OK;
}
state_type, target_state);
VERIFY_NON_NULL_RET(remoteAddress, TAG, "remoteAddress is null", false);
- ca_mutex_lock(g_deviceStateListMutex);
+ oc_mutex_lock(g_deviceStateListMutex);
if (!g_deviceStateList)
{
OIC_LOG(ERROR, TAG, "g_deviceStateList is null");
- ca_mutex_unlock(g_deviceStateListMutex);
+ oc_mutex_unlock(g_deviceStateListMutex);
return false;
}
if (NULL == state)
{
OIC_LOG(ERROR, TAG, "state is null");
- ca_mutex_unlock(g_deviceStateListMutex);
+ oc_mutex_unlock(g_deviceStateListMutex);
return false;
}
if (target_state == curValue)
{
- ca_mutex_unlock(g_deviceStateListMutex);
+ oc_mutex_unlock(g_deviceStateListMutex);
return true;
}
else
{
- ca_mutex_unlock(g_deviceStateListMutex);
+ oc_mutex_unlock(g_deviceStateListMutex);
return false;
}
- ca_mutex_unlock(g_deviceStateListMutex);
+ oc_mutex_unlock(g_deviceStateListMutex);
return false;
}
VERIFY_NON_NULL_VOID(env, TAG, "env is null");
// mutex lock
- ca_mutex_lock(g_threadMutex);
+ oc_mutex_lock(g_threadMutex);
g_currentSentCnt++;
g_sendBuffer = NULL;
}
// notity the thread
- ca_cond_signal(g_threadCond);
+ oc_cond_signal(g_threadCond);
CALEClientSetSendFinishFlag(true);
OIC_LOG(DEBUG, TAG, "set signal for send data");
}
// mutex unlock
- ca_mutex_unlock(g_threadMutex);
+ oc_mutex_unlock(g_threadMutex);
}
CAResult_t CALEClientInitGattMutexVaraibles()
{
if (NULL == g_bleReqRespClientCbMutex)
{
- g_bleReqRespClientCbMutex = ca_mutex_new();
+ g_bleReqRespClientCbMutex = oc_mutex_new();
if (NULL == g_bleReqRespClientCbMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new has failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new has failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_bleServerBDAddressMutex)
{
- g_bleServerBDAddressMutex = ca_mutex_new();
+ g_bleServerBDAddressMutex = oc_mutex_new();
if (NULL == g_bleServerBDAddressMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new has failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new has failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_threadMutex)
{
- g_threadMutex = ca_mutex_new();
+ g_threadMutex = oc_mutex_new();
if (NULL == g_threadMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new has failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new has failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_threadSendMutex)
{
- g_threadSendMutex = ca_mutex_new();
+ g_threadSendMutex = oc_mutex_new();
if (NULL == g_threadSendMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new has failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new has failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_deviceListMutex)
{
- g_deviceListMutex = ca_mutex_new();
+ g_deviceListMutex = oc_mutex_new();
if (NULL == g_deviceListMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new has failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new has failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_gattObjectMutex)
{
- g_gattObjectMutex = ca_mutex_new();
+ g_gattObjectMutex = oc_mutex_new();
if (NULL == g_gattObjectMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new has failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new has failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_deviceStateListMutex)
{
- g_deviceStateListMutex = ca_mutex_new();
+ g_deviceStateListMutex = oc_mutex_new();
if (NULL == g_deviceStateListMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new has failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new has failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_SendFinishMutex)
{
- g_SendFinishMutex = ca_mutex_new();
+ g_SendFinishMutex = oc_mutex_new();
if (NULL == g_SendFinishMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new has failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new has failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_threadWriteCharacteristicMutex)
{
- g_threadWriteCharacteristicMutex = ca_mutex_new();
+ g_threadWriteCharacteristicMutex = oc_mutex_new();
if (NULL == g_threadWriteCharacteristicMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new has failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new has failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_deviceScanRetryDelayMutex)
{
- g_deviceScanRetryDelayMutex = ca_mutex_new();
+ g_deviceScanRetryDelayMutex = oc_mutex_new();
if (NULL == g_deviceScanRetryDelayMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new has failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new has failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_threadSendStateMutex)
{
- g_threadSendStateMutex = ca_mutex_new();
+ g_threadSendStateMutex = oc_mutex_new();
if (NULL == g_threadSendStateMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new has failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new has failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_threadScanIntervalMutex)
{
- g_threadScanIntervalMutex = ca_mutex_new();
+ g_threadScanIntervalMutex = oc_mutex_new();
if (NULL == g_threadScanIntervalMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new has failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new has failed");
return CA_STATUS_FAILED;
}
}
void CALEClientTerminateGattMutexVariables()
{
- ca_mutex_free(g_bleReqRespClientCbMutex);
+ oc_mutex_free(g_bleReqRespClientCbMutex);
g_bleReqRespClientCbMutex = NULL;
- ca_mutex_free(g_bleServerBDAddressMutex);
+ oc_mutex_free(g_bleServerBDAddressMutex);
g_bleServerBDAddressMutex = NULL;
- ca_mutex_free(g_threadMutex);
+ oc_mutex_free(g_threadMutex);
g_threadMutex = NULL;
- ca_mutex_free(g_threadSendMutex);
+ oc_mutex_free(g_threadSendMutex);
g_threadSendMutex = NULL;
- ca_mutex_free(g_deviceListMutex);
+ oc_mutex_free(g_deviceListMutex);
g_deviceListMutex = NULL;
- ca_mutex_free(g_SendFinishMutex);
+ oc_mutex_free(g_SendFinishMutex);
g_SendFinishMutex = NULL;
- ca_mutex_free(g_threadWriteCharacteristicMutex);
+ oc_mutex_free(g_threadWriteCharacteristicMutex);
g_threadWriteCharacteristicMutex = NULL;
- ca_mutex_free(g_deviceScanRetryDelayMutex);
+ oc_mutex_free(g_deviceScanRetryDelayMutex);
g_deviceScanRetryDelayMutex = NULL;
- ca_mutex_free(g_threadSendStateMutex);
+ oc_mutex_free(g_threadSendStateMutex);
g_threadSendStateMutex = NULL;
- ca_mutex_free(g_threadScanIntervalMutex);
+ oc_mutex_free(g_threadScanIntervalMutex);
g_threadScanIntervalMutex = NULL;
}
{
OIC_LOG_V(DEBUG, TAG, "g_isFinishedSendData is %d", flag);
- ca_mutex_lock(g_SendFinishMutex);
+ oc_mutex_lock(g_SendFinishMutex);
g_isFinishedSendData = flag;
- ca_mutex_unlock(g_SendFinishMutex);
+ oc_mutex_unlock(g_SendFinishMutex);
}
/**
// init mutex for send logic
if (!g_deviceDescCond)
{
- g_deviceDescCond = ca_cond_new();
+ g_deviceDescCond = oc_cond_new();
}
if (!g_threadCond)
{
- g_threadCond = ca_cond_new();
+ g_threadCond = oc_cond_new();
}
if (!g_threadWriteCharacteristicCond)
{
- g_threadWriteCharacteristicCond = ca_cond_new();
+ g_threadWriteCharacteristicCond = oc_cond_new();
}
if (!g_threadScanIntervalCond)
{
- g_threadScanIntervalCond = ca_cond_new();
+ g_threadScanIntervalCond = oc_cond_new();
}
CAResult_t ret = CALEClientStartScanWithInterval();
CALEClientStopScanWithInterval();
- ca_mutex_lock(g_threadMutex);
+ oc_mutex_lock(g_threadMutex);
OIC_LOG(DEBUG, TAG, "signal - connection cond");
- ca_cond_signal(g_threadCond);
+ oc_cond_signal(g_threadCond);
CALEClientSetSendFinishFlag(true);
- ca_mutex_unlock(g_threadMutex);
+ oc_mutex_unlock(g_threadMutex);
- ca_mutex_lock(g_threadWriteCharacteristicMutex);
+ oc_mutex_lock(g_threadWriteCharacteristicMutex);
OIC_LOG(DEBUG, TAG, "signal - WriteCharacteristic cond");
- ca_cond_signal(g_threadWriteCharacteristicCond);
- ca_mutex_unlock(g_threadWriteCharacteristicMutex);
+ oc_cond_signal(g_threadWriteCharacteristicCond);
+ oc_mutex_unlock(g_threadWriteCharacteristicMutex);
- ca_mutex_lock(g_deviceScanRetryDelayMutex);
+ oc_mutex_lock(g_deviceScanRetryDelayMutex);
OIC_LOG(DEBUG, TAG, "signal - delay cond");
- ca_cond_signal(g_deviceScanRetryDelayCond);
- ca_mutex_unlock(g_deviceScanRetryDelayMutex);
+ oc_cond_signal(g_deviceScanRetryDelayCond);
+ oc_mutex_unlock(g_deviceScanRetryDelayMutex);
- ca_mutex_lock(g_threadScanIntervalMutex);
+ oc_mutex_lock(g_threadScanIntervalMutex);
OIC_LOG(DEBUG, TAG, "signal - delay cond");
- ca_cond_signal(g_threadScanIntervalCond);
- ca_mutex_unlock(g_threadScanIntervalMutex);
+ oc_cond_signal(g_threadScanIntervalCond);
+ oc_mutex_unlock(g_threadScanIntervalMutex);
- ca_cond_free(g_deviceDescCond);
- ca_cond_free(g_threadCond);
- ca_cond_free(g_threadWriteCharacteristicCond);
- ca_cond_free(g_deviceScanRetryDelayCond);
- ca_cond_free(g_threadScanIntervalCond);
+ oc_cond_free(g_deviceDescCond);
+ oc_cond_free(g_threadCond);
+ oc_cond_free(g_threadWriteCharacteristicCond);
+ oc_cond_free(g_deviceScanRetryDelayCond);
+ oc_cond_free(g_threadScanIntervalCond);
g_deviceDescCond = NULL;
g_threadCond = NULL;
void CASetLEReqRespClientCallback(CABLEDataReceivedCallback callback)
{
- ca_mutex_lock(g_bleReqRespClientCbMutex);
+ oc_mutex_lock(g_bleReqRespClientCbMutex);
g_CABLEClientDataReceivedCallback = callback;
- ca_mutex_unlock(g_bleReqRespClientCbMutex);
+ oc_mutex_unlock(g_bleReqRespClientCbMutex);
}
void CASetLEClientThreadPoolHandle(ca_thread_pool_t handle)
if (CA_STATUS_OK != res)
{
OIC_LOG(ERROR, TAG, "WriteCharacteristic has failed");
- ca_mutex_lock(g_threadWriteCharacteristicMutex);
+ oc_mutex_lock(g_threadWriteCharacteristicMutex);
g_isSignalSetFlag = true;
- ca_cond_signal(g_threadWriteCharacteristicCond);
- ca_mutex_unlock(g_threadWriteCharacteristicMutex);
+ oc_cond_signal(g_threadWriteCharacteristicCond);
+ oc_mutex_unlock(g_threadWriteCharacteristicMutex);
CAResult_t res = CALEClientUpdateDeviceState(address, CA_LE_SEND_STATE,
STATE_SEND_FAIL);
OIC_LOG(ERROR, TAG, "CALEClientUpdateDeviceState has failed");
}
- ca_mutex_lock(g_threadWriteCharacteristicMutex);
+ oc_mutex_lock(g_threadWriteCharacteristicMutex);
OIC_LOG(DEBUG, TAG, "g_isSignalSetFlag is set true and signal");
g_isSignalSetFlag = true;
- ca_cond_signal(g_threadWriteCharacteristicCond);
- ca_mutex_unlock(g_threadWriteCharacteristicMutex);
+ oc_cond_signal(g_threadWriteCharacteristicCond);
+ oc_mutex_unlock(g_threadWriteCharacteristicMutex);
}
(*env)->ReleaseStringUTFChars(env, jni_address, address);
receivedData, length);
uint32_t sentLength = 0;
- ca_mutex_lock(g_bleServerBDAddressMutex);
+ oc_mutex_lock(g_bleServerBDAddressMutex);
g_CABLEClientDataReceivedCallback(address, receivedData, length, &sentLength);
- ca_mutex_unlock(g_bleServerBDAddressMutex);
+ oc_mutex_unlock(g_bleServerBDAddressMutex);
(*env)->ReleaseStringUTFChars(env, jni_address, address);
}
* @brief Mutex to synchronize access to the deviceStateChanged Callback when the state
* of the LE adapter gets change.
*/
-static ca_mutex g_bleDeviceStateChangedCbMutex = NULL;
+static oc_mutex g_bleDeviceStateChangedCbMutex = NULL;
/**
* @var g_bleConnectionStateChangedCbMutex
* @brief Mutex to synchronize access to the LE ConnectionStateChanged Callback when the state
* of the LE adapter gets change.
*/
-static ca_mutex g_bleConnectionStateChangedCbMutex = NULL;
+static oc_mutex g_bleConnectionStateChangedCbMutex = NULL;
//getting context
void CALENetworkMonitorJNISetContext()
OIC_LOG(DEBUG, TAG, "IN");
if (NULL == g_bleDeviceStateChangedCbMutex)
{
- g_bleDeviceStateChangedCbMutex = ca_mutex_new();
+ g_bleDeviceStateChangedCbMutex = oc_mutex_new();
if (NULL == g_bleDeviceStateChangedCbMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new has failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new has failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_bleConnectionStateChangedCbMutex)
{
- g_bleConnectionStateChangedCbMutex = ca_mutex_new();
+ g_bleConnectionStateChangedCbMutex = oc_mutex_new();
if (NULL == g_bleConnectionStateChangedCbMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new has failed");
- ca_mutex_free(g_bleDeviceStateChangedCbMutex);
+ OIC_LOG(ERROR, TAG, "oc_mutex_new has failed");
+ oc_mutex_free(g_bleDeviceStateChangedCbMutex);
return CA_STATUS_FAILED;
}
}
{
OIC_LOG(DEBUG, TAG, "IN");
- ca_mutex_free(g_bleDeviceStateChangedCbMutex);
+ oc_mutex_free(g_bleDeviceStateChangedCbMutex);
g_bleDeviceStateChangedCbMutex = NULL;
- ca_mutex_free(g_bleConnectionStateChangedCbMutex);
+ oc_mutex_free(g_bleConnectionStateChangedCbMutex);
g_bleConnectionStateChangedCbMutex = NULL;
OIC_LOG(DEBUG, TAG, "OUT");
OIC_LOG(DEBUG, TAG, "Setting CALEDeviceStateChangedCallback");
- ca_mutex_lock(g_bleDeviceStateChangedCbMutex);
+ oc_mutex_lock(g_bleDeviceStateChangedCbMutex);
CALESetAdapterStateCallback(callback);
- ca_mutex_unlock(g_bleDeviceStateChangedCbMutex);
+ oc_mutex_unlock(g_bleDeviceStateChangedCbMutex);
OIC_LOG(DEBUG, TAG, "OUT");
return CA_STATUS_OK;
CAResult_t CASetLENWConnectionStateChangedCb(CALEConnectionStateChangedCallback callback)
{
OIC_LOG(DEBUG, TAG, "IN");
- ca_mutex_lock(g_bleConnectionStateChangedCbMutex);
+ oc_mutex_lock(g_bleConnectionStateChangedCbMutex);
g_bleConnectionStateChangedCallback = callback;
- ca_mutex_unlock(g_bleConnectionStateChangedCbMutex);
+ oc_mutex_unlock(g_bleConnectionStateChangedCbMutex);
OIC_LOG(DEBUG, TAG, "OUT");
return CA_STATUS_OK;
}
CAResult_t CAUnsetLENWConnectionStateChangedCb()
{
OIC_LOG(DEBUG, TAG, "IN");
- ca_mutex_lock(g_bleConnectionStateChangedCbMutex);
+ oc_mutex_lock(g_bleConnectionStateChangedCbMutex);
g_bleConnectionStateChangedCallback = NULL;
- ca_mutex_unlock(g_bleConnectionStateChangedCbMutex);
+ oc_mutex_unlock(g_bleConnectionStateChangedCbMutex);
OIC_LOG(DEBUG, TAG, "OUT");
return CA_STATUS_OK;
}
static jobject g_obj_bluetoothDevice = NULL;
static CABLEDataReceivedCallback g_CABLEServerDataReceivedCallback = NULL;
-static ca_mutex g_bleReqRespCbMutex = NULL;
-static ca_mutex g_bleClientBDAddressMutex = NULL;
-static ca_mutex g_connectedDeviceListMutex = NULL;
+static oc_mutex g_bleReqRespCbMutex = NULL;
+static oc_mutex g_bleClientBDAddressMutex = NULL;
+static oc_mutex g_connectedDeviceListMutex = NULL;
-static ca_mutex g_threadSendMutex = NULL;
-static ca_mutex g_threadSendNotifyMutex = NULL;
-static ca_cond g_threadSendNotifyCond = NULL;
+static oc_mutex g_threadSendMutex = NULL;
+static oc_mutex g_threadSendNotifyMutex = NULL;
+static oc_cond g_threadSendNotifyCond = NULL;
static bool g_isSignalSetFlag = false;
static jint g_state_connected = INVALID_STATE;
}
OIC_LOG_V(DEBUG, TAG, "callback flag is %d", g_isSignalSetFlag);
- ca_mutex_lock(g_threadSendNotifyMutex);
+ oc_mutex_lock(g_threadSendNotifyMutex);
if (!g_isSignalSetFlag)
{
OIC_LOG(DEBUG, TAG, "wait for callback to notify notifyCharacteristic is success");
- if (0 != ca_cond_wait_for(g_threadSendNotifyCond, g_threadSendNotifyMutex,
+ if (0 != oc_cond_wait_for(g_threadSendNotifyCond, g_threadSendNotifyMutex,
WAIT_TIME_WRITE_CHARACTERISTIC))
{
OIC_LOG(ERROR, TAG, "there is no response. notifyCharacteristic has failed");
- ca_mutex_unlock(g_threadSendNotifyMutex);
+ oc_mutex_unlock(g_threadSendNotifyMutex);
return CA_STATUS_FAILED;
}
}
// reset flag set by writeCharacteristic Callback
g_isSignalSetFlag = false;
- ca_mutex_unlock(g_threadSendNotifyMutex);
+ oc_mutex_unlock(g_threadSendNotifyMutex);
OIC_LOG(INFO, TAG, "notifyCharacteristic success");
return CA_STATUS_OK;
}
OIC_LOG(DEBUG, TAG, "IN - CALEServerDisconnectAllDevices");
VERIFY_NON_NULL(env, TAG, "env is null");
- ca_mutex_lock(g_connectedDeviceListMutex);
+ oc_mutex_lock(g_connectedDeviceListMutex);
if (!g_connectedDeviceList)
{
OIC_LOG(ERROR, TAG, "g_connectedDeviceList is null");
- ca_mutex_unlock(g_connectedDeviceListMutex);
+ oc_mutex_unlock(g_connectedDeviceListMutex);
return CA_STATUS_FAILED;
}
}
}
- ca_mutex_unlock(g_connectedDeviceListMutex);
+ oc_mutex_unlock(g_connectedDeviceListMutex);
OIC_LOG(DEBUG, TAG, "OUT - CALEServerDisconnectAllDevices");
return CA_STATUS_OK;
}
return ret;
}
- g_threadSendNotifyCond = ca_cond_new();
+ g_threadSendNotifyCond = oc_cond_new();
ret = CALEServerInitMutexVaraibles();
if (CA_STATUS_OK != ret)
g_bluetoothManager = NULL;
}
- ca_cond_free(g_threadSendNotifyCond);
+ oc_cond_free(g_threadSendNotifyCond);
g_threadSendNotifyCond = NULL;
CALEServerTerminateMutexVaraibles();
return CA_STATUS_FAILED;
}
- ca_mutex_lock(g_threadSendMutex);
+ oc_mutex_lock(g_threadSendMutex);
uint32_t length = u_arraylist_length(g_connectedDeviceList);
for (uint32_t index = 0; index < length; index++)
g_sendBuffer = NULL;
}
- ca_mutex_unlock(g_threadSendMutex);
+ oc_mutex_unlock(g_threadSendMutex);
OIC_LOG(INFO, TAG, "unicast - send request is successful");
return CA_STATUS_OK;
g_obj_bluetoothDevice = NULL;
}
- ca_mutex_unlock(g_threadSendMutex);
+ oc_mutex_unlock(g_threadSendMutex);
return CA_SEND_FAILED;
}
return CA_STATUS_FAILED;
}
- ca_mutex_lock(g_threadSendMutex);
+ oc_mutex_lock(g_threadSendMutex);
OIC_LOG(DEBUG, TAG, "set data into g_sendBuffer for notify");
if (g_sendBuffer)
g_sendBuffer = NULL;
}
- ca_mutex_unlock(g_threadSendMutex);
+ oc_mutex_unlock(g_threadSendMutex);
return CA_STATUS_OK;
}
void CALEServerCreateCachedDeviceList()
{
- ca_mutex_lock(g_connectedDeviceListMutex);
+ oc_mutex_lock(g_connectedDeviceListMutex);
// create new object array
if (!g_connectedDeviceList)
{
OIC_LOG(DEBUG, TAG, "Create device list");
g_connectedDeviceList = u_arraylist_create();
}
- ca_mutex_unlock(g_connectedDeviceListMutex);
+ oc_mutex_unlock(g_connectedDeviceListMutex);
}
bool CALEServerIsDeviceInList(JNIEnv *env, const char* remoteAddress)
VERIFY_NON_NULL(device, TAG, "device is null");
VERIFY_NON_NULL(env, TAG, "env is null");
- ca_mutex_lock(g_connectedDeviceListMutex);
+ oc_mutex_lock(g_connectedDeviceListMutex);
if (!g_connectedDeviceList)
{
OIC_LOG(ERROR, TAG, "list is null");
- ca_mutex_unlock(g_connectedDeviceListMutex);
+ oc_mutex_unlock(g_connectedDeviceListMutex);
return CA_STATUS_FAILED;
}
if (!jni_remoteAddress)
{
OIC_LOG(ERROR, TAG, "jni_remoteAddress is null");
- ca_mutex_unlock(g_connectedDeviceListMutex);
+ oc_mutex_unlock(g_connectedDeviceListMutex);
return CA_STATUS_FAILED;
}
if (!remoteAddress)
{
OIC_LOG(ERROR, TAG, "remoteAddress is null");
- ca_mutex_unlock(g_connectedDeviceListMutex);
+ oc_mutex_unlock(g_connectedDeviceListMutex);
return CA_STATUS_FAILED;
}
}
(*env)->ReleaseStringUTFChars(env, jni_remoteAddress, remoteAddress);
- ca_mutex_unlock(g_connectedDeviceListMutex);
+ oc_mutex_unlock(g_connectedDeviceListMutex);
OIC_LOG(DEBUG, TAG, "OUT - CALEServerAddDeviceToList");
return CA_STATUS_OK;
}
OIC_LOG(DEBUG, TAG, "IN - CALEServerRemoveAllDevices");
VERIFY_NON_NULL(env, TAG, "env is null");
- ca_mutex_lock(g_connectedDeviceListMutex);
+ oc_mutex_lock(g_connectedDeviceListMutex);
if (!g_connectedDeviceList)
{
OIC_LOG(ERROR, TAG, "g_connectedDeviceList is null");
- ca_mutex_unlock(g_connectedDeviceListMutex);
+ oc_mutex_unlock(g_connectedDeviceListMutex);
return CA_STATUS_FAILED;
}
OICFree(g_connectedDeviceList);
g_connectedDeviceList = NULL;
- ca_mutex_unlock(g_connectedDeviceListMutex);
+ oc_mutex_unlock(g_connectedDeviceListMutex);
OIC_LOG(DEBUG, TAG, "OUT - CALEServerRemoveAllDevices");
return CA_STATUS_OK;
VERIFY_NON_NULL(env, TAG, "env is null");
VERIFY_NON_NULL(address, TAG, "address is null");
- ca_mutex_lock(g_connectedDeviceListMutex);
+ oc_mutex_lock(g_connectedDeviceListMutex);
if (!g_connectedDeviceList)
{
OIC_LOG(ERROR, TAG, "no deviceList");
- ca_mutex_unlock(g_connectedDeviceListMutex);
+ oc_mutex_unlock(g_connectedDeviceListMutex);
return CA_STATUS_FAILED;
}
if (NULL == u_arraylist_remove(g_connectedDeviceList, index))
{
OIC_LOG(ERROR, TAG, "List removal failed.");
- ca_mutex_unlock(g_connectedDeviceListMutex);
+ oc_mutex_unlock(g_connectedDeviceListMutex);
return CA_STATUS_FAILED;
}
- ca_mutex_unlock(g_connectedDeviceListMutex);
+ oc_mutex_unlock(g_connectedDeviceListMutex);
return CA_STATUS_OK;
}
(*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
}
}
- ca_mutex_unlock(g_connectedDeviceListMutex);
+ oc_mutex_unlock(g_connectedDeviceListMutex);
OIC_LOG(DEBUG, TAG, "there are no device in the device list");
OIC_LOG_V(DEBUG, TAG, "remote device address : %s, %p, %d", address, requestData, length);
- ca_mutex_lock(g_bleClientBDAddressMutex);
+ oc_mutex_lock(g_bleClientBDAddressMutex);
uint32_t sentLength = 0;
g_CABLEServerDataReceivedCallback(address, requestData, length,
&sentLength);
- ca_mutex_unlock(g_bleClientBDAddressMutex);
+ oc_mutex_unlock(g_bleClientBDAddressMutex);
(*env)->ReleaseStringUTFChars(env, jni_address, address);
}
g_obj_bluetoothDevice = NULL;
}
- ca_mutex_lock(g_threadSendNotifyMutex);
+ oc_mutex_lock(g_threadSendNotifyMutex);
g_isSignalSetFlag = true;
- ca_cond_signal(g_threadSendNotifyCond);
- ca_mutex_unlock(g_threadSendNotifyMutex);
+ oc_cond_signal(g_threadSendNotifyCond);
+ oc_mutex_unlock(g_threadSendNotifyMutex);
return;
}
}
}
// next data can be sent
- ca_mutex_lock(g_threadSendNotifyMutex);
+ oc_mutex_lock(g_threadSendNotifyMutex);
OIC_LOG(DEBUG, TAG, "g_isSignalSetFlag is set true and signal");
g_isSignalSetFlag = true;
- ca_cond_signal(g_threadSendNotifyCond);
- ca_mutex_unlock(g_threadSendNotifyMutex);
+ oc_cond_signal(g_threadSendNotifyCond);
+ oc_mutex_unlock(g_threadSendNotifyMutex);
}
}
g_obj_bluetoothDevice = NULL;
}
- ca_mutex_lock(g_threadSendNotifyMutex);
- ca_cond_signal(g_threadSendNotifyCond);
- ca_mutex_unlock(g_threadSendNotifyMutex);
+ oc_mutex_lock(g_threadSendNotifyMutex);
+ oc_cond_signal(g_threadSendNotifyCond);
+ oc_mutex_unlock(g_threadSendNotifyMutex);
g_isStartServer = false;
void CASetLEReqRespServerCallback(CABLEDataReceivedCallback callback)
{
- ca_mutex_lock(g_bleReqRespCbMutex);
+ oc_mutex_lock(g_bleReqRespCbMutex);
g_CABLEServerDataReceivedCallback = callback;
- ca_mutex_unlock(g_bleReqRespCbMutex);
+ oc_mutex_unlock(g_bleReqRespCbMutex);
}
void CASetBLEServerErrorHandleCallback(CABLEErrorHandleCallback callback)
{
if (NULL == g_bleReqRespCbMutex)
{
- g_bleReqRespCbMutex = ca_mutex_new();
+ g_bleReqRespCbMutex = oc_mutex_new();
if (NULL == g_bleReqRespCbMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new has failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new has failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_bleClientBDAddressMutex)
{
- g_bleClientBDAddressMutex = ca_mutex_new();
+ g_bleClientBDAddressMutex = oc_mutex_new();
if (NULL == g_bleClientBDAddressMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new has failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new has failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_connectedDeviceListMutex)
{
- g_connectedDeviceListMutex = ca_mutex_new();
+ g_connectedDeviceListMutex = oc_mutex_new();
if (NULL == g_connectedDeviceListMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new has failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new has failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_threadSendMutex)
{
- g_threadSendMutex = ca_mutex_new();
+ g_threadSendMutex = oc_mutex_new();
if (NULL == g_threadSendMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new has failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new has failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_threadSendNotifyMutex)
{
- g_threadSendNotifyMutex = ca_mutex_new();
+ g_threadSendNotifyMutex = oc_mutex_new();
if (NULL == g_threadSendNotifyMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new has failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new has failed");
return CA_STATUS_FAILED;
}
}
void CALEServerTerminateMutexVaraibles()
{
- ca_mutex_free(g_bleReqRespCbMutex);
+ oc_mutex_free(g_bleReqRespCbMutex);
g_bleReqRespCbMutex = NULL;
- ca_mutex_free(g_bleClientBDAddressMutex);
+ oc_mutex_free(g_bleClientBDAddressMutex);
g_bleClientBDAddressMutex = NULL;
- ca_mutex_free(g_connectedDeviceListMutex);
+ oc_mutex_free(g_connectedDeviceListMutex);
g_connectedDeviceListMutex = NULL;
- ca_mutex_free(g_threadSendMutex);
+ oc_mutex_free(g_threadSendMutex);
g_threadSendMutex = NULL;
- ca_mutex_free(g_threadSendNotifyMutex);
+ oc_mutex_free(g_threadSendNotifyMutex);
g_threadSendNotifyMutex = NULL;
}
* Mutex to synchronize the task to be executed on the GattServer
* function calls.
*/
-static ca_mutex g_bleIsServerMutex = NULL;
+static oc_mutex g_bleIsServerMutex = NULL;
/**
* Mutex to synchronize the callback to be called for the network
* changes.
*/
-static ca_mutex g_bleNetworkCbMutex = NULL;
+static oc_mutex g_bleNetworkCbMutex = NULL;
/**
* Mutex to synchronize the updates of the local LE address of the
* adapter.
*/
-static ca_mutex g_bleLocalAddressMutex = NULL;
+static oc_mutex g_bleLocalAddressMutex = NULL;
/**
* Reference to thread pool.
/**
* Mutex to synchronize the task to be pushed to thread pool.
*/
-static ca_mutex g_bleAdapterThreadPoolMutex = NULL;
+static oc_mutex g_bleAdapterThreadPoolMutex = NULL;
/**
* Mutex to synchronize the queing of the data from SenderQueue.
*/
-static ca_mutex g_bleClientSendDataMutex = NULL;
+static oc_mutex g_bleClientSendDataMutex = NULL;
/**
* Mutex to synchronize the queing of the data from ReceiverQueue.
*/
-static ca_mutex g_bleReceiveDataMutex = NULL;
+static oc_mutex g_bleReceiveDataMutex = NULL;
/**
* Mutex to synchronize the queing of the data from SenderQueue.
*/
-static ca_mutex g_bleServerSendDataMutex = NULL;
+static oc_mutex g_bleServerSendDataMutex = NULL;
/**
* Mutex to synchronize the callback to be called for the
* adapterReqResponse.
*/
-static ca_mutex g_bleAdapterReqRespCbMutex = NULL;
+static oc_mutex g_bleAdapterReqRespCbMutex = NULL;
/**
* Callback to be called when network packet received from either
* @param[in] address target address to remove data in queue.
*/
static void CALERemoveSendQueueData(CAQueueingThread_t *queueHandle,
- ca_mutex mutex,
+ oc_mutex mutex,
const char* address);
/**
{
OIC_LOG(DEBUG, CALEADAPTER_TAG, "IN");
- ca_mutex_lock(g_bleAdapterThreadPoolMutex);
+ oc_mutex_lock(g_bleAdapterThreadPoolMutex);
CAResult_t result = CAInitLEServerSenderQueue();
if (CA_STATUS_OK != result)
{
OIC_LOG(ERROR, CALEADAPTER_TAG, "CAInitBleServerSenderQueue failed");
- ca_mutex_unlock(g_bleAdapterThreadPoolMutex);
+ oc_mutex_unlock(g_bleAdapterThreadPoolMutex);
return CA_STATUS_FAILED;
}
if (!g_bleServerSenderInfo)
{
OIC_LOG(ERROR, CALEADAPTER_TAG, "memory allocation failed!");
- ca_mutex_unlock(g_bleAdapterThreadPoolMutex);
+ oc_mutex_unlock(g_bleAdapterThreadPoolMutex);
return CA_MEMORY_ALLOC_FAILED;
}
{
OIC_LOG(ERROR, CALEADAPTER_TAG, "CAInitLEReceiverQueue failed");
u_arraylist_free(&g_bleServerSenderInfo);
- ca_mutex_unlock(g_bleAdapterThreadPoolMutex);
+ oc_mutex_unlock(g_bleAdapterThreadPoolMutex);
return CA_STATUS_FAILED;
}
g_dataBleReceiverHandlerState = true;
- ca_mutex_unlock(g_bleAdapterThreadPoolMutex);
+ oc_mutex_unlock(g_bleAdapterThreadPoolMutex);
OIC_LOG(DEBUG, CALEADAPTER_TAG, "OUT");
return CA_STATUS_OK;
{
OIC_LOG(DEBUG, CALEADAPTER_TAG, "IN");
- ca_mutex_lock(g_bleAdapterThreadPoolMutex);
+ oc_mutex_lock(g_bleAdapterThreadPoolMutex);
CAResult_t result = CAInitLEClientSenderQueue();
if (CA_STATUS_OK != result)
{
OIC_LOG(ERROR, CALEADAPTER_TAG, "CAInitBleClientSenderQueue failed");
- ca_mutex_unlock(g_bleAdapterThreadPoolMutex);
+ oc_mutex_unlock(g_bleAdapterThreadPoolMutex);
return CA_STATUS_FAILED;
}
if (!g_bleClientSenderInfo)
{
OIC_LOG(ERROR, CALEADAPTER_TAG, "memory allocation failed!");
- ca_mutex_unlock(g_bleAdapterThreadPoolMutex);
+ oc_mutex_unlock(g_bleAdapterThreadPoolMutex);
return CA_MEMORY_ALLOC_FAILED;
}
{
OIC_LOG(ERROR, CALEADAPTER_TAG, "CAInitLEReceiverQueue failed");
u_arraylist_free(&g_bleClientSenderInfo);
- ca_mutex_unlock(g_bleAdapterThreadPoolMutex);
+ oc_mutex_unlock(g_bleAdapterThreadPoolMutex);
return CA_STATUS_FAILED;
}
g_dataBleReceiverHandlerState = true;
- ca_mutex_unlock(g_bleAdapterThreadPoolMutex);
+ oc_mutex_unlock(g_bleAdapterThreadPoolMutex);
OIC_LOG(DEBUG, CALEADAPTER_TAG, "OUT");
return CA_STATUS_OK;
{
OIC_LOG(DEBUG, CALEADAPTER_TAG, "IN - CAStopLEQueues");
- ca_mutex_lock(g_bleReceiveDataMutex);
+ oc_mutex_lock(g_bleReceiveDataMutex);
if (NULL != g_bleReceiverQueue)
{
CAQueueingThreadStop(g_bleReceiverQueue);
}
- ca_mutex_unlock(g_bleReceiveDataMutex);
+ oc_mutex_unlock(g_bleReceiveDataMutex);
OIC_LOG(DEBUG, CALEADAPTER_TAG, "OUT - CAStopLEQueues");
}
{
OIC_LOG(DEBUG, CALEADAPTER_TAG, "IN - CALEDataReceiverHandler");
- ca_mutex_lock(g_bleReceiveDataMutex);
+ oc_mutex_lock(g_bleReceiveDataMutex);
if (g_dataBleReceiverHandlerState)
{
if (!bleData)
{
OIC_LOG(DEBUG, CALEADAPTER_TAG, "Invalid bleData!");
- ca_mutex_unlock(g_bleReceiveDataMutex);
+ oc_mutex_unlock(g_bleReceiveDataMutex);
return;
}
if (!(bleData->senderInfo))
{
OIC_LOG(ERROR, CALEADAPTER_TAG, "sender info is not available");
- ca_mutex_unlock(g_bleReceiveDataMutex);
+ oc_mutex_unlock(g_bleReceiveDataMutex);
return;
}
if (!(bleData->remoteEndpoint))
{
OIC_LOG(ERROR, CALEADAPTER_TAG, "Client RemoteEndPoint NULL!!");
- ca_mutex_unlock(g_bleReceiveDataMutex);
+ oc_mutex_unlock(g_bleReceiveDataMutex);
return;
}
OIC_LOG_V(ERROR, CALEADAPTER_TAG,
"this packet is not valid for this app(port mismatch[mine:%d, packet:%d])",
g_localBLESourcePort, destPort);
- ca_mutex_unlock(g_bleReceiveDataMutex);
+ oc_mutex_unlock(g_bleReceiveDataMutex);
return;
}
else
{
OIC_LOG(ERROR, CALEADAPTER_TAG, "This packet is wrong packet! ignore.");
- ca_mutex_unlock(g_bleReceiveDataMutex);
+ oc_mutex_unlock(g_bleReceiveDataMutex);
return;
}
if (!newSender)
{
OIC_LOG(ERROR, CALEADAPTER_TAG, "Memory allocation failed for new sender");
- ca_mutex_unlock(g_bleReceiveDataMutex);
+ oc_mutex_unlock(g_bleReceiveDataMutex);
return;
}
newSender->recvDataLen = 0;
{
OIC_LOG(ERROR, CALEADAPTER_TAG, "Total Data Length is parsed as 0!!!");
OICFree(newSender);
- ca_mutex_unlock(g_bleReceiveDataMutex);
+ oc_mutex_unlock(g_bleReceiveDataMutex);
return;
}
{
OIC_LOG(ERROR, CALEADAPTER_TAG, "defragData is NULL!");
OICFree(newSender);
- ca_mutex_unlock(g_bleReceiveDataMutex);
+ oc_mutex_unlock(g_bleReceiveDataMutex);
return;
}
OIC_LOG(ERROR, CALEADAPTER_TAG, "remoteEndpoint is NULL!");
OICFree(newSender->defragData);
OICFree(newSender);
- ca_mutex_unlock(g_bleReceiveDataMutex);
+ oc_mutex_unlock(g_bleReceiveDataMutex);
return;
}
OICFree(newSender->defragData);
CAFreeEndpoint(newSender->remoteEndpoint);
OICFree(newSender);
- ca_mutex_unlock(g_bleReceiveDataMutex);
+ oc_mutex_unlock(g_bleReceiveDataMutex);
return;
}
memcpy(newSender->defragData,
OICFree(newSender->defragData);
CAFreeEndpoint(newSender->remoteEndpoint);
OICFree(newSender);
- ca_mutex_unlock(g_bleReceiveDataMutex);
+ oc_mutex_unlock(g_bleReceiveDataMutex);
return;
}
senderInfo = newSender;
u_arraylist_remove(bleData->senderInfo, senderIndex);
OICFree(senderInfo->defragData);
OICFree(senderInfo);
- ca_mutex_unlock(g_bleReceiveDataMutex);
+ oc_mutex_unlock(g_bleReceiveDataMutex);
return;
}
OIC_LOG_V(DEBUG, CALEADAPTER_TAG, "Copying the data of length [%d]",
if (senderInfo->totalDataLen == senderInfo->recvDataLen)
{
- ca_mutex_lock(g_bleAdapterReqRespCbMutex);
+ oc_mutex_lock(g_bleAdapterReqRespCbMutex);
if (NULL == g_networkPacketReceivedCallback)
{
OIC_LOG(ERROR, CALEADAPTER_TAG, "gReqRespCallback is NULL!");
u_arraylist_remove(bleData->senderInfo, senderIndex);
OICFree(senderInfo->defragData);
OICFree(senderInfo);
- ca_mutex_unlock(g_bleAdapterReqRespCbMutex);
- ca_mutex_unlock(g_bleReceiveDataMutex);
+ oc_mutex_unlock(g_bleAdapterReqRespCbMutex);
+ oc_mutex_unlock(g_bleReceiveDataMutex);
return;
}
g_networkPacketReceivedCallback(&tmp,
senderInfo->defragData,
senderInfo->recvDataLen);
- ca_mutex_unlock(g_bleAdapterReqRespCbMutex);
+ oc_mutex_unlock(g_bleAdapterReqRespCbMutex);
u_arraylist_remove(bleData->senderInfo, senderIndex);
senderInfo->remoteEndpoint = NULL;
senderInfo->defragData = NULL;
OICFree(senderInfo);
}
}
- ca_mutex_unlock(g_bleReceiveDataMutex);
+ oc_mutex_unlock(g_bleReceiveDataMutex);
OIC_LOG(DEBUG, CALEADAPTER_TAG, "OUT");
}
if (NULL == g_bleIsServerMutex)
{
- g_bleIsServerMutex = ca_mutex_new();
+ g_bleIsServerMutex = oc_mutex_new();
if (NULL == g_bleIsServerMutex)
{
- OIC_LOG(ERROR, CALEADAPTER_TAG, "ca_mutex_new failed");
+ OIC_LOG(ERROR, CALEADAPTER_TAG, "oc_mutex_new failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_bleNetworkCbMutex)
{
- g_bleNetworkCbMutex = ca_mutex_new();
+ g_bleNetworkCbMutex = oc_mutex_new();
if (NULL == g_bleNetworkCbMutex)
{
- OIC_LOG(ERROR, CALEADAPTER_TAG, "ca_mutex_new failed");
+ OIC_LOG(ERROR, CALEADAPTER_TAG, "oc_mutex_new failed");
CATerminateLEAdapterMutex();
return CA_STATUS_FAILED;
}
if (NULL == g_bleLocalAddressMutex)
{
- g_bleLocalAddressMutex = ca_mutex_new();
+ g_bleLocalAddressMutex = oc_mutex_new();
if (NULL == g_bleLocalAddressMutex)
{
- OIC_LOG(ERROR, CALEADAPTER_TAG, "ca_mutex_new failed");
+ OIC_LOG(ERROR, CALEADAPTER_TAG, "oc_mutex_new failed");
CATerminateLEAdapterMutex();
return CA_STATUS_FAILED;
}
if (NULL == g_bleAdapterThreadPoolMutex)
{
- g_bleAdapterThreadPoolMutex = ca_mutex_new();
+ g_bleAdapterThreadPoolMutex = oc_mutex_new();
if (NULL == g_bleAdapterThreadPoolMutex)
{
- OIC_LOG(ERROR, CALEADAPTER_TAG, "ca_mutex_new failed");
+ OIC_LOG(ERROR, CALEADAPTER_TAG, "oc_mutex_new failed");
CATerminateLEAdapterMutex();
return CA_STATUS_FAILED;
}
if (NULL == g_bleClientSendDataMutex)
{
- g_bleClientSendDataMutex = ca_mutex_new();
+ g_bleClientSendDataMutex = oc_mutex_new();
if (NULL == g_bleClientSendDataMutex)
{
- OIC_LOG(ERROR, CALEADAPTER_TAG, "ca_mutex_new failed");
+ OIC_LOG(ERROR, CALEADAPTER_TAG, "oc_mutex_new failed");
CATerminateLEAdapterMutex();
return CA_STATUS_FAILED;
}
if (NULL == g_bleServerSendDataMutex)
{
- g_bleServerSendDataMutex = ca_mutex_new();
+ g_bleServerSendDataMutex = oc_mutex_new();
if (NULL == g_bleServerSendDataMutex)
{
- OIC_LOG(ERROR, CALEADAPTER_TAG, "ca_mutex_new failed");
+ OIC_LOG(ERROR, CALEADAPTER_TAG, "oc_mutex_new failed");
CATerminateLEAdapterMutex();
return CA_STATUS_FAILED;
}
if (NULL == g_bleAdapterReqRespCbMutex)
{
- g_bleAdapterReqRespCbMutex = ca_mutex_new();
+ g_bleAdapterReqRespCbMutex = oc_mutex_new();
if (NULL == g_bleAdapterReqRespCbMutex)
{
- OIC_LOG(ERROR, CALEADAPTER_TAG, "ca_mutex_new failed");
+ OIC_LOG(ERROR, CALEADAPTER_TAG, "oc_mutex_new failed");
CATerminateLEAdapterMutex();
return CA_STATUS_FAILED;
}
if (NULL == g_bleReceiveDataMutex)
{
- g_bleReceiveDataMutex = ca_mutex_new();
+ g_bleReceiveDataMutex = oc_mutex_new();
if (NULL == g_bleReceiveDataMutex)
{
- OIC_LOG(ERROR, CALEADAPTER_TAG, "ca_mutex_new failed");
+ OIC_LOG(ERROR, CALEADAPTER_TAG, "oc_mutex_new failed");
return CA_STATUS_FAILED;
}
}
{
OIC_LOG(DEBUG, CALEADAPTER_TAG, "IN - CATerminateLEAdapterMutex");
- ca_mutex_free(g_bleIsServerMutex);
+ oc_mutex_free(g_bleIsServerMutex);
g_bleIsServerMutex = NULL;
- ca_mutex_free(g_bleNetworkCbMutex);
+ oc_mutex_free(g_bleNetworkCbMutex);
g_bleNetworkCbMutex = NULL;
- ca_mutex_free(g_bleLocalAddressMutex);
+ oc_mutex_free(g_bleLocalAddressMutex);
g_bleLocalAddressMutex = NULL;
- ca_mutex_free(g_bleAdapterThreadPoolMutex);
+ oc_mutex_free(g_bleAdapterThreadPoolMutex);
g_bleAdapterThreadPoolMutex = NULL;
- ca_mutex_free(g_bleClientSendDataMutex);
+ oc_mutex_free(g_bleClientSendDataMutex);
g_bleClientSendDataMutex = NULL;
- ca_mutex_free(g_bleServerSendDataMutex);
+ oc_mutex_free(g_bleServerSendDataMutex);
g_bleServerSendDataMutex = NULL;
- ca_mutex_free(g_bleAdapterReqRespCbMutex);
+ oc_mutex_free(g_bleAdapterReqRespCbMutex);
g_bleAdapterReqRespCbMutex = NULL;
- ca_mutex_free(g_bleReceiveDataMutex);
+ oc_mutex_free(g_bleReceiveDataMutex);
g_bleReceiveDataMutex = NULL;
OIC_LOG(DEBUG, CALEADAPTER_TAG, "OUT");
*/
if (CA_STATUS_OK == result)
{
- ca_mutex_lock(g_bleServerSendDataMutex);
+ oc_mutex_lock(g_bleServerSendDataMutex);
result = CAQueueingThreadStart(g_bleServerSendQueueHandle);
- ca_mutex_unlock(g_bleServerSendDataMutex);
+ oc_mutex_unlock(g_bleServerSendDataMutex);
if (CA_STATUS_OK != result)
{
OIC_LOG(DEBUG, CALEADAPTER_TAG, "CALEAdapterGattServerStop");
CAResult_t result = CAStopLEGattServer();
- ca_mutex_lock(g_bleServerSendDataMutex);
+ oc_mutex_lock(g_bleServerSendDataMutex);
if (CA_STATUS_OK == result)
{
result = CAQueueingThreadStop(g_bleServerSendQueueHandle);
}
- ca_mutex_unlock(g_bleServerSendDataMutex);
+ oc_mutex_unlock(g_bleServerSendDataMutex);
return result;
#else
*/
if (CA_STATUS_OK == result)
{
- ca_mutex_lock(g_bleClientSendDataMutex);
+ oc_mutex_lock(g_bleClientSendDataMutex);
result = CAQueueingThreadStart(g_bleClientSendQueueHandle);
- ca_mutex_unlock(g_bleClientSendDataMutex);
+ oc_mutex_unlock(g_bleClientSendDataMutex);
if (CA_STATUS_OK != result)
{
OIC_LOG(DEBUG, CALEADAPTER_TAG, "CALEAdapterGattClientStop");
CAStopLEGattClient();
- ca_mutex_lock(g_bleClientSendDataMutex);
+ oc_mutex_lock(g_bleClientSendDataMutex);
CAResult_t result = CAQueueingThreadStop(g_bleClientSendQueueHandle);
- ca_mutex_unlock(g_bleClientSendDataMutex);
+ oc_mutex_unlock(g_bleClientSendDataMutex);
return result;
#else
CAStopLEQueues();
#endif
- ca_mutex_lock(g_bleIsServerMutex);
+ oc_mutex_lock(g_bleIsServerMutex);
switch (g_adapterType)
{
case ADAPTER_SERVER:
default:
break;
}
- ca_mutex_unlock(g_bleIsServerMutex);
+ oc_mutex_unlock(g_bleIsServerMutex);
OIC_LOG(DEBUG, CALEADAPTER_TAG, "OUT");
CASetLEReqRespAdapterCallback(NULL);
CATerminateLENetworkMonitor();
- ca_mutex_lock(g_bleIsServerMutex);
+ oc_mutex_lock(g_bleIsServerMutex);
switch (g_adapterType)
{
case ADAPTER_SERVER:
break;
}
g_adapterType = ADAPTER_EMPTY;
- ca_mutex_unlock(g_bleIsServerMutex);
+ oc_mutex_unlock(g_bleIsServerMutex);
#ifndef SINGLE_THREAD
CATerminateLEQueues();
}
#endif
- ca_mutex_lock(g_bleIsServerMutex);
+ oc_mutex_lock(g_bleIsServerMutex);
switch (g_adapterType)
{
case ADAPTER_CLIENT:
default:
g_adapterType = ADAPTER_SERVER;
}
- ca_mutex_unlock(g_bleIsServerMutex);
+ oc_mutex_unlock(g_bleIsServerMutex);
result = CAGetLEAdapterState();
if (CA_STATUS_OK != result)
}
#endif
- ca_mutex_lock(g_bleIsServerMutex);
+ oc_mutex_lock(g_bleIsServerMutex);
switch (g_adapterType)
{
case ADAPTER_SERVER:
default:
g_adapterType = ADAPTER_CLIENT;
}
- ca_mutex_unlock(g_bleIsServerMutex);
+ oc_mutex_unlock(g_bleIsServerMutex);
result = CAGetLEAdapterState();
if (CA_STATUS_OK != result)
OIC_LOG(ERROR, CALEADAPTER_TAG, "g_adapterType is Empty");
}
- ca_mutex_lock(g_bleIsServerMutex);
+ oc_mutex_lock(g_bleIsServerMutex);
if (ADAPTER_SERVER == g_adapterType ||
(ADAPTER_BOTH_CLIENT_SERVER == g_adapterType && CA_RESPONSE_DATA == dataType))
{
result = CALEAdapterServerSendData(endpoint, data, dataLen);
if (CA_STATUS_OK != result)
{
- ca_mutex_unlock(g_bleIsServerMutex);
+ oc_mutex_unlock(g_bleIsServerMutex);
OIC_LOG(ERROR, CALEADAPTER_TAG, "Send unicast data for server failed");
if (g_errorHandler)
{
result = CALEAdapterClientSendData(endpoint, data, dataLen);
if (CA_STATUS_OK != result)
{
- ca_mutex_unlock(g_bleIsServerMutex);
+ oc_mutex_unlock(g_bleIsServerMutex);
OIC_LOG(ERROR, CALEADAPTER_TAG, "Send unicast data for client failed" );
if (g_errorHandler)
return -1;
}
}
- ca_mutex_unlock(g_bleIsServerMutex);
+ oc_mutex_unlock(g_bleIsServerMutex);
OIC_LOG(DEBUG, CALEADAPTER_TAG, "OUT");
return dataLen;
OIC_LOG(ERROR, CALEADAPTER_TAG, "g_adapterType is Empty");
}
- ca_mutex_lock(g_bleIsServerMutex);
+ oc_mutex_lock(g_bleIsServerMutex);
if (ADAPTER_SERVER == g_adapterType ||
(ADAPTER_BOTH_CLIENT_SERVER == g_adapterType && CA_RESPONSE_DATA == dataType))
{
result = CALEAdapterServerSendData(NULL, data, dataLen);
if (CA_STATUS_OK != result)
{
- ca_mutex_unlock(g_bleIsServerMutex);
+ oc_mutex_unlock(g_bleIsServerMutex);
OIC_LOG(ERROR, CALEADAPTER_TAG, "Send multicast data for server failed" );
result = CALEAdapterClientSendData(NULL, data, dataLen);
if (CA_STATUS_OK != result)
{
- ca_mutex_unlock(g_bleIsServerMutex);
+ oc_mutex_unlock(g_bleIsServerMutex);
OIC_LOG(ERROR, CALEADAPTER_TAG, "Send Multicast data for client failed" );
return -1;
}
}
- ca_mutex_unlock(g_bleIsServerMutex);
+ oc_mutex_unlock(g_bleIsServerMutex);
OIC_LOG(DEBUG, CALEADAPTER_TAG, "OUT - CASendLEMulticastData");
return dataLen;
}
OICStrcpy((*info)->addr, sizeof((*info)->addr), local_address);
- ca_mutex_lock(g_bleLocalAddressMutex);
+ oc_mutex_lock(g_bleLocalAddressMutex);
OICStrcpy(g_localBLEAddress, sizeof(g_localBLEAddress), local_address);
- ca_mutex_unlock(g_bleLocalAddressMutex);
+ oc_mutex_unlock(g_bleLocalAddressMutex);
(*info)->adapter = CA_ADAPTER_GATT_BTLE;
*size = 1;
{
OIC_LOG(DEBUG, CALEADAPTER_TAG, "IN");
- ca_mutex_lock(g_bleNetworkCbMutex);
+ oc_mutex_lock(g_bleNetworkCbMutex);
g_networkCallback = netCallback;
g_connectionCallback = connCallback;
- ca_mutex_unlock(g_bleNetworkCbMutex);
+ oc_mutex_unlock(g_bleNetworkCbMutex);
CAResult_t res = CA_STATUS_OK;
if (netCallback)
{
(void)adapter;
#ifdef __TIZEN__
- ca_mutex_lock(g_bleIsServerMutex);
+ oc_mutex_lock(g_bleIsServerMutex);
switch (g_adapterType)
{
case ADAPTER_SERVER:
default:
break;
}
- ca_mutex_unlock(g_bleIsServerMutex);
+ oc_mutex_unlock(g_bleIsServerMutex);
#endif
if(!isConnected)
CAEndpoint_t localEndpoint = { .adapter = CA_ADAPTER_GATT_BTLE };
OICStrcpy(localEndpoint.addr, sizeof(localEndpoint.addr), address);
- ca_mutex_lock(g_bleNetworkCbMutex);
+ oc_mutex_lock(g_bleNetworkCbMutex);
if (g_connectionCallback)
{
g_connectionCallback(&localEndpoint, isConnected);
}
- ca_mutex_unlock(g_bleNetworkCbMutex);
+ oc_mutex_unlock(g_bleNetworkCbMutex);
OIC_LOG(DEBUG, CALEADAPTER_TAG, "OUT");
}
if (CA_ADAPTER_ENABLED == adapter_state)
{
- ca_mutex_lock(g_bleIsServerMutex);
+ oc_mutex_lock(g_bleIsServerMutex);
switch (g_adapterType)
{
case ADAPTER_SERVER:
default:
break;
}
- ca_mutex_unlock(g_bleIsServerMutex);
+ oc_mutex_unlock(g_bleIsServerMutex);
}
else
{
- ca_mutex_lock(g_bleIsServerMutex);
+ oc_mutex_lock(g_bleIsServerMutex);
switch (g_adapterType)
{
case ADAPTER_SERVER:
default:
break;
}
- ca_mutex_unlock(g_bleIsServerMutex);
+ oc_mutex_unlock(g_bleIsServerMutex);
}
- ca_mutex_lock(g_bleNetworkCbMutex);
+ oc_mutex_lock(g_bleNetworkCbMutex);
if (NULL != g_networkCallback)
{
g_networkCallback(CA_ADAPTER_GATT_BTLE, adapter_state);
{
OIC_LOG(ERROR, CALEADAPTER_TAG, "g_networkCallback is NULL");
}
- ca_mutex_unlock(g_bleNetworkCbMutex);
+ oc_mutex_unlock(g_bleNetworkCbMutex);
OIC_LOG(DEBUG, CALEADAPTER_TAG, "OUT");
}
return CA_MEMORY_ALLOC_FAILED;
}
// Add message to send queue
- ca_mutex_lock(g_bleClientSendDataMutex);
+ oc_mutex_lock(g_bleClientSendDataMutex);
CAQueueingThreadAddData(g_bleClientSendQueueHandle, bleData, sizeof(CALEData_t));
- ca_mutex_unlock(g_bleClientSendDataMutex);
+ oc_mutex_unlock(g_bleClientSendDataMutex);
#endif
OIC_LOG(DEBUG, CALEADAPTER_TAG, "OUT");
return CA_STATUS_OK;
}
// Add message to send queue
- ca_mutex_lock(g_bleServerSendDataMutex);
+ oc_mutex_lock(g_bleServerSendDataMutex);
CAQueueingThreadAddData(g_bleServerSendQueueHandle,
bleData,
sizeof(CALEData_t));
- ca_mutex_unlock(g_bleServerSendDataMutex);
+ oc_mutex_unlock(g_bleServerSendDataMutex);
#endif
OIC_LOG(DEBUG, CALEADAPTER_TAG, "OUT");
return CA_STATUS_OK;
{
OIC_LOG(DEBUG, CALEADAPTER_TAG, "IN");
- ca_mutex_lock(g_bleAdapterThreadPoolMutex);
+ oc_mutex_lock(g_bleAdapterThreadPoolMutex);
g_bleAdapterThreadPool = handle;
- ca_mutex_unlock(g_bleAdapterThreadPoolMutex);
+ oc_mutex_unlock(g_bleAdapterThreadPoolMutex);
OIC_LOG(DEBUG, CALEADAPTER_TAG, "OUT");
}
{
OIC_LOG(DEBUG, CALEADAPTER_TAG, "IN");
- ca_mutex_lock(g_bleAdapterReqRespCbMutex);
+ oc_mutex_lock(g_bleAdapterReqRespCbMutex);
g_networkPacketReceivedCallback = callback;
- ca_mutex_unlock(g_bleAdapterReqRespCbMutex);
+ oc_mutex_unlock(g_bleAdapterReqRespCbMutex);
OIC_LOG(DEBUG, CALEADAPTER_TAG, "OUT");
}
}
#ifndef SINGLE_THREAD
-static void CALERemoveSendQueueData(CAQueueingThread_t *queueHandle, ca_mutex mutex,
+static void CALERemoveSendQueueData(CAQueueingThread_t *queueHandle, oc_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);
+ oc_mutex_lock(mutex);
while (u_queue_get_size(queueHandle->dataQueue) > 0)
{
OIC_LOG(DEBUG, CALEADAPTER_TAG, "get data from queue");
}
}
}
- ca_mutex_unlock(mutex);
+ oc_mutex_unlock(mutex);
}
static void CALERemoveReceiveQueueData(u_arraylist_t *dataInfoList, const char* address)
static bool CALECheckStarted()
{
- ca_mutex_lock(g_context.lock);
+ oc_mutex_lock(g_context.lock);
bool const started =
(g_context.event_loop != NULL
&& g_main_loop_is_running(g_context.event_loop));
- ca_mutex_unlock(g_context.lock);
+ oc_mutex_unlock(g_context.lock);
/**
* @todo Fix potential TOCTOU race condition. A LE transport
return;
}
- ca_mutex_lock(g_context.lock);
+ oc_mutex_lock(g_context.lock);
/*
Add the object information to the list.
*/
*proxy_list = g_list_prepend(*proxy_list, proxy);
- ca_mutex_unlock(g_context.lock);
+ oc_mutex_unlock(g_context.lock);
/**
* Let the thread that may be blocked waiting for Devices to be
*/
if (strcmp(interface, BLUEZ_DEVICE_INTERFACE) == 0)
{
- ca_cond_signal(g_context.condition);
+ oc_cond_signal(g_context.condition);
}
}
gchar const * path = NULL;
g_variant_get_child(parameters, 0, "&o", &path);
- ca_mutex_lock(g_context.lock);
+ oc_mutex_lock(g_context.lock);
for (GList * l = *list; l != NULL; l = g_list_next(l))
{
}
}
- ca_mutex_unlock(g_context.lock);
+ oc_mutex_unlock(g_context.lock);
g_variant_unref(child);
}
G_CALLBACK(CALEOnInterfaceProxyPropertiesChanged),
context);
- ca_mutex_lock(context->lock);
+ oc_mutex_lock(context->lock);
context->interfaces_added_sub_id = interfaces_added_sub_id;
context->interfaces_removed_sub_id = interfaces_removed_sub_id;
- ca_mutex_unlock(context->lock);
+ oc_mutex_unlock(context->lock);
}
static bool CALESetUpDBus(CALEContext * context)
CALESubscribeToSignals(context, connection, object_manager);
- ca_mutex_lock(context->lock);
+ oc_mutex_lock(context->lock);
context->connection = connection;
context->object_manager = object_manager;
- ca_mutex_unlock(context->lock);
+ oc_mutex_unlock(context->lock);
success = CALESetUpBlueZObjects(context);
global state, and pushing resource finalization outside the global
lock.
*/
- ca_mutex_lock(context->lock);
+ oc_mutex_lock(context->lock);
GDBusConnection * const connection = context->connection;
context->connection = NULL;
context->interfaces_added_sub_id = 0;
context->interfaces_removed_sub_id = 0;
- ca_mutex_unlock(context->lock);
+ oc_mutex_unlock(context->lock);
// Destroy the device proxies list.
g_list_free_full(devices, g_object_unref);
return success;
}
- ca_mutex_lock(context->lock);
+ oc_mutex_lock(context->lock);
context->objects = objects;
- ca_mutex_unlock(context->lock);
+ oc_mutex_unlock(context->lock);
/*
Create a proxies to the org.bluez.Adapter1 D-Bus objects that
// An empty adapters list is NULL.
if (success && adapters != NULL)
{
- ca_mutex_lock(context->lock);
+ oc_mutex_lock(context->lock);
context->adapters = adapters;
- ca_mutex_unlock(context->lock);
+ oc_mutex_unlock(context->lock);
}
/*
// An empty device list is NULL.
if (success && devices != NULL)
{
- ca_mutex_lock(context->lock);
+ oc_mutex_lock(context->lock);
context->devices = devices;
- ca_mutex_unlock(context->lock);
+ oc_mutex_unlock(context->lock);
}
return success;
*/
if (CALESetUpDBus(&g_context))
{
- ca_mutex_lock(context->lock);
+ oc_mutex_lock(context->lock);
assert(context->event_loop == NULL);
context->event_loop = event_loop;
- ca_mutex_unlock(context->lock);
+ oc_mutex_unlock(context->lock);
/*
Add an idle handler that notifies a thread waiting for the
static void CALEStopEventLoop(CALEContext * context)
{
- ca_mutex_lock(context->lock);
+ oc_mutex_lock(context->lock);
GMainLoop * const event_loop = context->event_loop;
context->event_loop = NULL;
- ca_mutex_unlock(context->lock);
+ oc_mutex_unlock(context->lock);
if (event_loop != NULL)
{
{
bool success = false;
- ca_mutex_lock(g_context.lock);
+ oc_mutex_lock(g_context.lock);
for (int i = 0; *list == NULL && i < retries; ++i)
{
- if (ca_cond_wait_for(g_context.condition,
+ if (oc_cond_wait_for(g_context.condition,
g_context.lock,
- timeout) == CA_WAIT_SUCCESS)
+ timeout) == OC_WAIT_SUCCESS)
{
/*
Condition variable was signaled before the timeout was
}
}
- ca_mutex_unlock(g_context.lock);
+ oc_mutex_unlock(g_context.lock);
return success;
}
{
CAResult_t result = CA_ADAPTER_NOT_ENABLED;
- ca_mutex_lock(g_context.lock);
+ oc_mutex_lock(g_context.lock);
for (GList * l = g_context.adapters; l != NULL; l = l->next)
{
}
}
- ca_mutex_unlock(g_context.lock);
+ oc_mutex_unlock(g_context.lock);
return result;
}
* @see @c CAStartLEAdapter() for further details.
*/
- g_context.lock = ca_mutex_new();
- g_context.condition = ca_cond_new();
+ g_context.lock = oc_mutex_new();
+ g_context.condition = oc_cond_new();
static int const PSHARED = 0; // shared between threads
static unsigned int const VALUE = 0; // force sem_wait() to block
(void) sem_destroy(&g_context.le_started);
- ca_mutex_lock(g_context.lock);
+ oc_mutex_lock(g_context.lock);
g_context.on_device_state_changed = NULL;
g_context.on_server_received_data = NULL;
g_context.on_client_error = NULL;
g_context.on_server_error = NULL;
- ca_cond_free(g_context.condition);
+ oc_cond_free(g_context.condition);
g_context.condition = NULL;
- ca_mutex_unlock(g_context.lock);
+ oc_mutex_unlock(g_context.lock);
- ca_mutex_free(g_context.lock);
+ oc_mutex_free(g_context.lock);
g_context.lock = NULL;
}
CAResult_t CASetLEAdapterStateChangedCb(
CALEDeviceStateChangedCallback callback)
{
- ca_mutex_lock(g_context.lock);
+ oc_mutex_lock(g_context.lock);
g_context.on_device_state_changed = callback;
- ca_mutex_unlock(g_context.lock);
+ oc_mutex_unlock(g_context.lock);
return CA_STATUS_OK;
}
*local_address = NULL;
- ca_mutex_lock(g_context.lock);
+ oc_mutex_lock(g_context.lock);
for (GList * l = g_context.adapters; l != NULL; l = l->next)
{
break;
}
- ca_mutex_unlock(g_context.lock);
+ oc_mutex_unlock(g_context.lock);
return *local_address != NULL ? CA_STATUS_OK : CA_STATUS_FAILED;
}
void CASetLEReqRespServerCallback(CABLEDataReceivedCallback callback)
{
- ca_mutex_lock(g_context.lock);
+ oc_mutex_lock(g_context.lock);
g_context.on_server_received_data = callback;
- ca_mutex_unlock(g_context.lock);
+ oc_mutex_unlock(g_context.lock);
}
CAResult_t CAUpdateCharacteristicsToGattClient(char const * address,
return result;
}
- ca_mutex_lock(g_context.lock);
+ oc_mutex_lock(g_context.lock);
bool found_peripherals = (g_context.devices != NULL);
- ca_mutex_unlock(g_context.lock);
+ oc_mutex_unlock(g_context.lock);
if (!found_peripherals)
{
void CASetLEReqRespClientCallback(CABLEDataReceivedCallback callback)
{
- ca_mutex_lock(g_context.lock);
+ oc_mutex_lock(g_context.lock);
g_context.on_client_received_data = callback;
- ca_mutex_unlock(g_context.lock);
+ oc_mutex_unlock(g_context.lock);
}
void CASetLEServerThreadPoolHandle(ca_thread_pool_t handle)
{
- ca_mutex_lock(g_context.lock);
+ oc_mutex_lock(g_context.lock);
g_context.server_thread_pool = handle;
- ca_mutex_unlock(g_context.lock);
+ oc_mutex_unlock(g_context.lock);
}
void CASetLEClientThreadPoolHandle(ca_thread_pool_t handle)
{
- ca_mutex_lock(g_context.lock);
+ oc_mutex_lock(g_context.lock);
g_context.client_thread_pool = handle;
- ca_mutex_unlock(g_context.lock);
+ oc_mutex_unlock(g_context.lock);
}
CAResult_t CAUnSetLEAdapterStateChangedCb()
{
- ca_mutex_lock(g_context.lock);
+ oc_mutex_lock(g_context.lock);
g_context.on_device_state_changed = NULL;
- ca_mutex_unlock(g_context.lock);
+ oc_mutex_unlock(g_context.lock);
return CA_STATUS_OK;
}
void CASetBLEClientErrorHandleCallback(CABLEErrorHandleCallback callback)
{
- ca_mutex_lock(g_context.lock);
+ oc_mutex_lock(g_context.lock);
g_context.on_client_error = callback;
- ca_mutex_unlock(g_context.lock);
+ oc_mutex_unlock(g_context.lock);
}
void CASetBLEServerErrorHandleCallback(CABLEErrorHandleCallback callback)
{
- ca_mutex_lock(g_context.lock);
+ oc_mutex_lock(g_context.lock);
g_context.on_server_error = callback;
- ca_mutex_unlock(g_context.lock);
+ oc_mutex_unlock(g_context.lock);
}
{
assert(context != NULL);
- ca_mutex_lock(context->lock);
+ oc_mutex_lock(context->lock);
for (GList * l = context->devices; l != NULL; l = l->next)
{
}
}
- ca_mutex_unlock(context->lock);
+ oc_mutex_unlock(context->lock);
}
// -----------------------------------------------------------------------
Synchronize access to the adapter information using the base
context lock since we don't own the adapters.
*/
- ca_mutex_lock(context->lock);
+ oc_mutex_lock(context->lock);
/**
* Start discovery on all detected adapters.
CACentralStartDiscoveryImpl,
&result);
- ca_mutex_unlock(context->lock);
+ oc_mutex_unlock(context->lock);
return result;
}
Synchronize access to the adapter information using the base
context lock since we don't own the adapters.
*/
- ca_mutex_lock(context->lock);
+ oc_mutex_lock(context->lock);
// Start discovery on all detected adapters.
g_list_foreach(context->adapters,
CACentralStartDiscoveryImpl,
&result);
- ca_mutex_unlock(context->lock);
+ oc_mutex_unlock(context->lock);
return result;
}
Synchronize access to the adapter information using the base
context lock since we don't own the adapters.
*/
- ca_mutex_lock(context->lock);
+ oc_mutex_lock(context->lock);
// Stop discovery on all detected adapters.
g_list_foreach(context->adapters,
* @todo Stop notifications on all response characteristics.
*/
- ca_mutex_unlock(context->lock);
+ oc_mutex_unlock(context->lock);
return result;
}
{
bool connected = true;
- ca_mutex_lock(context->lock);
+ oc_mutex_lock(context->lock);
// Connect to the LE peripherals, if we're not already connected.
g_list_foreach(context->devices,
CACentralConnectToDevice,
&connected);
- ca_mutex_unlock(context->lock);
+ oc_mutex_unlock(context->lock);
return connected;
}
return false;
}
- ca_mutex_lock(context->lock);
+ oc_mutex_lock(context->lock);
c->recv_info.on_packet_received = context->on_server_received_data;
- ca_mutex_unlock(context->lock);
+ oc_mutex_unlock(context->lock);
c->recv_info.peer = peer;
c->recv_info.context = context;
GHashTable * address_map;
/// Mutex used to synchronize access to context fields.
- ca_mutex lock;
+ oc_mutex lock;
} CAGattClientContext;
char const * const object_path =
g_dbus_proxy_get_object_path(characteristic);
- ca_mutex_lock(g_context.lock);
+ oc_mutex_lock(g_context.lock);
char * const address =
g_hash_table_lookup(g_context.address_map, object_path);
}
}
- ca_mutex_unlock(g_context.lock);
+ oc_mutex_unlock(g_context.lock);
}
// ---------------------------------------------------------------------
{
CALEContext * const context = user_data;
- ca_mutex_lock(g_context.lock);
+ oc_mutex_lock(g_context.lock);
CAGattClientSetupService(device,
g_context.characteristic_map,
services_prop,
context);
- ca_mutex_unlock(g_context.lock);
+ oc_mutex_unlock(g_context.lock);
g_variant_unref(services_prop);
}
CAResult_t CAGattClientInitialize(CALEContext * context)
{
- g_context.lock = ca_mutex_new();
+ g_context.lock = oc_mutex_new();
/*
Map Bluetooth MAC address to OIC Transport Profile
OICFree,
OICFree);
- ca_mutex_lock(context->lock);
+ oc_mutex_lock(context->lock);
for (GList * l = context->devices; l != NULL; l = l->next)
{
context);
}
- ca_mutex_unlock(context->lock);
+ oc_mutex_unlock(context->lock);
- ca_mutex_lock(g_context.lock);
+ oc_mutex_lock(g_context.lock);
g_context.characteristic_map = characteristic_map;
g_context.address_map = address_map;
- ca_mutex_unlock(g_context.lock);
+ oc_mutex_unlock(g_context.lock);
return CA_STATUS_OK;
}
return; // Initialization did not complete.
}
- ca_mutex_lock(g_context.lock);
+ oc_mutex_lock(g_context.lock);
if (g_context.characteristic_map != NULL)
{
g_context.address_map = NULL;
}
- ca_mutex_unlock(g_context.lock);
+ oc_mutex_unlock(g_context.lock);
- ca_mutex_free(g_context.lock);
+ oc_mutex_free(g_context.lock);
g_context.lock = NULL;
/*
g_error_free(error);
- ca_mutex_lock(context->lock);
+ oc_mutex_lock(context->lock);
if (context->on_client_error != NULL)
{
CA_STATUS_FAILED);
}
- ca_mutex_unlock(context->lock);
+ oc_mutex_unlock(context->lock);
return CA_STATUS_FAILED;
}
CAResult_t result = CA_STATUS_FAILED;
- ca_mutex_lock(g_context.lock);
+ oc_mutex_lock(g_context.lock);
GDBusProxy * const characteristic =
G_DBUS_PROXY(
length,
context);
- ca_mutex_unlock(g_context.lock);
+ oc_mutex_unlock(g_context.lock);
return result;
}
CAResult_t result = CA_STATUS_FAILED;
- ca_mutex_lock(g_context.lock);
+ oc_mutex_lock(g_context.lock);
if (g_context.characteristic_map == NULL)
{
// Remote OIC GATT service was not found prior to getting here.
- ca_mutex_unlock(g_context.lock);
+ oc_mutex_unlock(g_context.lock);
return result;
}
}
}
- ca_mutex_unlock(g_context.lock);
+ oc_mutex_unlock(g_context.lock);
return result;
}
CABLEErrorHandleCallback on_server_error;
/// Mutex used to synchronize access to context fields.
- ca_mutex lock;
+ oc_mutex lock;
/**
* BlueZ adapter list initialization condition variable.
*
* @see @c GMainLoop documentation for further details.
*/
- ca_cond condition;
+ oc_cond condition;
/**
* Semaphore that indicates completed start of the LE transport.
static bool CAPeripheralCheckStarted()
{
- ca_mutex_lock(g_context.lock);
+ oc_mutex_lock(g_context.lock);
bool const started =
(g_context.event_loop != NULL
&& g_main_loop_is_running(g_context.event_loop));
- ca_mutex_unlock(g_context.lock);
+ oc_mutex_unlock(g_context.lock);
/**
* @todo Fix potential TOCTOU race condition. A peripheral could
static bool CAPeripheralAdaptersFound(CALEContext * context)
{
// Check if BlueZ detected bluetooth hardware adapters.
- ca_mutex_lock(context->lock);
+ oc_mutex_lock(context->lock);
bool const found = (context->adapters != NULL);
- ca_mutex_unlock(context->lock);
+ oc_mutex_unlock(context->lock);
if (!found)
{
bool success = true;
- ca_mutex_lock(context->lock);
+ oc_mutex_lock(context->lock);
for (GList * l = context->gatt_services; l != NULL; l = l->next)
{
g_variant_unref(ret);
}
- ca_mutex_unlock(context->lock);
+ oc_mutex_unlock(context->lock);
return success;
}
LE Advertisement Manager.
*/
- ca_mutex_lock(context->lock);
+ oc_mutex_lock(context->lock);
char const * const advertisement_path =
g_dbus_interface_skeleton_get_object_path(
success = true;
}
- ca_mutex_unlock(context->lock);
+ oc_mutex_unlock(context->lock);
return success;
}
Synchronize access to the adapter information using the base
context lock since we don't own the adapter_infos.
*/
- ca_mutex_lock(context->lock);
+ oc_mutex_lock(context->lock);
// Make all detected adapters discoverable.
g_list_foreach(context->adapters,
discoverability_func,
&result);
- ca_mutex_unlock(context->lock);
+ oc_mutex_unlock(context->lock);
return result;
}
*/
static gboolean CAPeripheralEventLoopStarted(gpointer user_data)
{
- ca_cond const condition = user_data;
+ oc_cond const condition = user_data;
- ca_cond_signal(condition); // For service registration
+ oc_cond_signal(condition); // For service registration
return G_SOURCE_REMOVE;
}
"manager interface.");
}
- ca_mutex_lock(g_context.lock);
+ oc_mutex_lock(g_context.lock);
assert(g_context.event_loop == NULL);
g_context.event_loop = event_loop;
context->connection,
advertising_managers);
- ca_mutex_unlock(g_context.lock);
+ oc_mutex_unlock(g_context.lock);
/*
Add an idle handler that notifies a thread waiting for the
static void CAPeripheralStopEventLoop(CAPeripheralContext * context)
{
- ca_mutex_lock(context->lock);
+ oc_mutex_lock(context->lock);
GMainLoop * const event_loop = context->event_loop;
context->event_loop = NULL;
- ca_mutex_unlock(context->lock);
+ oc_mutex_unlock(context->lock);
if (event_loop != NULL)
{
void CAPeripheralInitialize()
{
- g_context.lock = ca_mutex_new();
- g_context.condition = ca_cond_new();
+ g_context.lock = oc_mutex_new();
+ g_context.condition = oc_cond_new();
}
void CAPeripheralFinalize()
{
- ca_cond_free(g_context.condition);
- ca_mutex_free(g_context.lock);
+ oc_cond_free(g_context.condition);
+ oc_mutex_free(g_context.lock);
}
CAResult_t CAPeripheralStart(CALEContext * context)
static uint64_t const timeout =
2 * MICROSECS_PER_SEC; // Microseconds
- ca_mutex_lock(g_context.lock);
+ oc_mutex_lock(g_context.lock);
for (int i = 0;
g_context.gatt_services == NULL && i < max_retries;
++i)
{
- if (ca_cond_wait_for(g_context.condition,
+ if (oc_cond_wait_for(g_context.condition,
g_context.lock,
- timeout) == CA_WAIT_SUCCESS)
+ timeout) == OC_WAIT_SUCCESS)
{
result = CA_STATUS_OK;
}
}
- ca_mutex_unlock(g_context.lock);
+ oc_mutex_unlock(g_context.lock);
if (result != CA_STATUS_OK)
{
CAPeripheralStopEventLoop(&g_context);
- ca_mutex_lock(g_context.lock);
+ oc_mutex_lock(g_context.lock);
guint const owner_id = g_context.owner_id;
g_context.owner_id = 0;
g_context.base = NULL;
- ca_mutex_unlock(g_context.lock);
+ oc_mutex_unlock(g_context.lock);
CALEAdvertisementDestroy(&g_context.advertisement);
void CAPeripheralForEachService(GFunc func, void * user_data)
{
- ca_mutex_lock(g_context.lock);
+ oc_mutex_lock(g_context.lock);
g_list_foreach(g_context.gatt_services, func, user_data);
- ca_mutex_unlock(g_context.lock);
+ oc_mutex_unlock(g_context.lock);
}
GMainLoop * event_loop;
/// Mutex used to synchronize access to context fields.
- ca_mutex lock;
+ oc_mutex lock;
/**
* Service registration condition variable.
*
* @see @c GMainLoop documentation for further details.
*/
- ca_cond condition;
+ oc_cond condition;
} CAPeripheralContext;
{
uint32_t sent_length = 0;
- ca_mutex_lock(info->context->lock);
+ oc_mutex_lock(info->context->lock);
bool const success =
info->on_packet_received(info->peer,
length,
&sent_length) == CA_STATUS_OK;
- ca_mutex_unlock(info->context->lock);
+ oc_mutex_unlock(info->context->lock);
return success && length == sent_length;
}
*/
bool success = true;
- ca_mutex_lock(context->lock);
+ oc_mutex_lock(context->lock);
if (context->objects == NULL)
{
- ca_mutex_unlock(context->lock);
+ oc_mutex_unlock(context->lock);
return success;
}
}
}
- ca_mutex_unlock(context->lock);
+ oc_mutex_unlock(context->lock);
return success;
}
/**
* Mutex to synchronize the access to Pending multicast data list.
*/
-static ca_mutex g_multicastDataListMutex = NULL;
+static oc_mutex g_multicastDataListMutex = NULL;
/**
* List of devices discovered.
/**
* Mutex to synchronize the access to discovered devices list.
*/
-static ca_mutex g_deviceDiscoveredListMutex = NULL;
+static oc_mutex g_deviceDiscoveredListMutex = NULL;
/**
* Condition to start the timer for scanning.
*/
-static ca_cond g_startTimerCond = NULL;
+static oc_cond g_startTimerCond = NULL;
/**
* Condition for scanning Time interval.
*/
-static ca_cond g_scanningTimeCond = NULL;
+static oc_cond g_scanningTimeCond = NULL;
/**
* This contains the list of OIC services a client connect tot.
/**
* Mutex to synchronize access to BleServiceList.
*/
-static ca_mutex g_LEServerListMutex = NULL;
+static oc_mutex g_LEServerListMutex = NULL;
/**
* Boolean variable to keep the state of the GATT Client.
* Mutex to synchronize access to the requestResponse callback to be called
* when the data needs to be sent from GATTClient.
*/
-static ca_mutex g_LEReqRespClientCbMutex = NULL;
+static oc_mutex g_LEReqRespClientCbMutex = NULL;
/**
* Mutex to synchronize access to the requestResponse callback to be called
* when the data needs to be sent from GATTClient.
*/
-static ca_mutex g_LEClientConnectMutex = NULL;
+static oc_mutex g_LEClientConnectMutex = NULL;
/**
* Mutex to synchronize the calls to be done to the platform from GATTClient
* interfaces from different threads.
*/
-static ca_mutex g_LEClientStateMutex = NULL;
+static oc_mutex g_LEClientStateMutex = NULL;
/**
* Mutex to synchronize the task to be pushed to thread pool.
*/
-static ca_mutex g_LEClientThreadPoolMutex = NULL;
+static oc_mutex g_LEClientThreadPoolMutex = NULL;
/**
* Mutex to synchronize the task to write characteristic one packet after another.
*/
-static ca_mutex g_threadWriteCharacteristicMutex = NULL;
+static oc_mutex g_threadWriteCharacteristicMutex = NULL;
/**
* Condition for Writing characteristic.
*/
-static ca_cond g_threadWriteCharacteristicCond = NULL;
+static oc_cond g_threadWriteCharacteristicCond = NULL;
/**
* Flag to check status of write characteristic.
OIC_LOG(DEBUG, TAG, "IN");
if (g_deviceDiscoveredList)
{
- ca_mutex_lock(g_deviceDiscoveredListMutex);
+ oc_mutex_lock(g_deviceDiscoveredListMutex);
uint32_t arrayLength = u_arraylist_length(g_deviceDiscoveredList);
for (int i = 0; i < arrayLength; i++)
{
if (0 == strcasecmp(deviceAddr, address))
{
OIC_LOG(DEBUG, TAG, "Device Found");
- ca_mutex_unlock(g_deviceDiscoveredListMutex);
+ oc_mutex_unlock(g_deviceDiscoveredListMutex);
return true;
}
}
- ca_mutex_unlock(g_deviceDiscoveredListMutex);
+ oc_mutex_unlock(g_deviceDiscoveredListMutex);
}
OIC_LOG(DEBUG, TAG, "OUT");
return false;
OIC_LOG(DEBUG, TAG, "IN");
OIC_LOG_V(DEBUG, TAG, "Changed characteristic value length [%d]", valueLen);
- ca_mutex_lock(g_LEReqRespClientCbMutex);
+ oc_mutex_lock(g_LEReqRespClientCbMutex);
if (NULL == g_LEClientDataReceivedCallback)
{
OIC_LOG(ERROR, TAG, "Request response callback is not set");
- ca_mutex_unlock(g_LEReqRespClientCbMutex);
+ oc_mutex_unlock(g_LEReqRespClientCbMutex);
return;
}
OIC_LOG_V(DEBUG, TAG, "Sent data Length is %d", sentLength);
- ca_mutex_unlock(g_LEReqRespClientCbMutex);
+ oc_mutex_unlock(g_LEReqRespClientCbMutex);
OIC_LOG(DEBUG, TAG, "OUT");
}
}
else
{
- ca_mutex_lock(g_threadWriteCharacteristicMutex);
+ oc_mutex_lock(g_threadWriteCharacteristicMutex);
OIC_LOG(DEBUG, TAG, "g_isSignalSetFlag is set true and signal");
g_isSignalSetFlag = true;
- ca_cond_signal(g_threadWriteCharacteristicCond);
- ca_mutex_unlock(g_threadWriteCharacteristicMutex);
+ oc_cond_signal(g_threadWriteCharacteristicCond);
+ oc_mutex_unlock(g_threadWriteCharacteristicMutex);
}
OIC_LOG(DEBUG, TAG, "OUT ");
OIC_LOG(ERROR, TAG, "CALEGattStartDeviceDiscovery Failed");
}
// Signal the start timer.
- ca_cond_signal(g_scanningTimeCond);
+ oc_cond_signal(g_scanningTimeCond);
if (!connected)
{
OIC_LOG_V(DEBUG, TAG, "DisConnected from [%s] ", remoteAddress);
- ca_mutex_lock(g_LEServerListMutex);
+ oc_mutex_lock(g_LEServerListMutex);
CARemoveLEServerInfoFromList(&g_LEServerList, remoteAddress);
- ca_mutex_unlock(g_LEServerListMutex);
+ oc_mutex_unlock(g_LEServerListMutex);
}
else
{
return;
}
- ca_mutex_lock(g_LEClientThreadPoolMutex);
+ oc_mutex_lock(g_LEClientThreadPoolMutex);
if (NULL == g_LEClientThreadPool)
{
OIC_LOG(ERROR, TAG, "g_LEClientThreadPool is NULL");
OICFree(addr);
- ca_mutex_unlock(g_LEClientThreadPoolMutex);
+ oc_mutex_unlock(g_LEClientThreadPoolMutex);
return;
}
OIC_LOG_V(ERROR, TAG, "ca_thread_pool_add_task failed with ret [%d]", ret);
OICFree(addr);
}
- ca_mutex_unlock(g_LEClientThreadPoolMutex);
+ oc_mutex_unlock(g_LEClientThreadPoolMutex);
}
OIC_LOG(DEBUG, TAG, "OUT");
}
// Stop the scan before invoking bt_gatt_connect().
CALEGattStopDeviceScanning();
- ca_mutex_lock(g_deviceDiscoveredListMutex);
+ oc_mutex_lock(g_deviceDiscoveredListMutex);
// Add the the device Discovered list.
if (NULL == g_deviceDiscoveredList)
{
if (NULL == deviceAddr)
{
OIC_LOG_V(ERROR, TAG, "Device address is NULL");
- ca_mutex_unlock(g_deviceDiscoveredListMutex);
+ oc_mutex_unlock(g_deviceDiscoveredListMutex);
return;
}
u_arraylist_add(g_deviceDiscoveredList, (void *) deviceAddr);
- ca_mutex_unlock(g_deviceDiscoveredListMutex);
+ oc_mutex_unlock(g_deviceDiscoveredListMutex);
size_t len = strlen(scanInfo->remote_address);
OIC_LOG_V(DEBUG, TAG,
"Trying to do Gatt connection to [%s]", addr);
- ca_mutex_lock(g_LEClientThreadPoolMutex);
+ oc_mutex_lock(g_LEClientThreadPoolMutex);
if (NULL == g_LEClientThreadPool)
{
OIC_LOG(ERROR, TAG, "g_LEClientThreadPool is NULL");
OICFree(addr);
- ca_mutex_unlock(g_LEClientThreadPoolMutex);
+ oc_mutex_unlock(g_LEClientThreadPoolMutex);
return;
}
"ca_thread_pool_add_task failed with ret [%d]", res);
OICFree(addr);
}
- ca_mutex_unlock(g_LEClientThreadPoolMutex);
+ oc_mutex_unlock(g_LEClientThreadPoolMutex);
OIC_LOG(DEBUG, TAG, "OUT");
}
{
OIC_LOG(DEBUG, TAG, "IN");
- ca_mutex_lock(g_LEClientThreadPoolMutex);
+ oc_mutex_lock(g_LEClientThreadPoolMutex);
g_LEClientThreadPool = handle;
- ca_mutex_unlock(g_LEClientThreadPoolMutex);
+ oc_mutex_unlock(g_LEClientThreadPoolMutex);
OIC_LOG(DEBUG, TAG, "OUT");
}
{
OIC_LOG(DEBUG, TAG, "IN");
- ca_mutex_lock(g_LEReqRespClientCbMutex);
+ oc_mutex_lock(g_LEReqRespClientCbMutex);
g_LEClientDataReceivedCallback = callback;
- ca_mutex_unlock(g_LEReqRespClientCbMutex);
+ oc_mutex_unlock(g_LEReqRespClientCbMutex);
OIC_LOG(DEBUG, TAG, "OUT");
}
{
OIC_LOG(DEBUG, TAG, "IN");
- ca_mutex_lock(g_LEClientStateMutex);
+ oc_mutex_lock(g_LEClientStateMutex);
if (true == g_isLEGattClientStarted)
{
OIC_LOG(ERROR, TAG, "Gatt Client is already running!!");
- ca_mutex_unlock(g_LEClientStateMutex);
+ oc_mutex_unlock(g_LEClientStateMutex);
return CA_STATUS_FAILED;
}
if (CA_STATUS_OK != result)
{
OIC_LOG(ERROR, TAG, "CABleGattSetCallbacks Failed");
- ca_mutex_unlock(g_LEClientStateMutex);
+ oc_mutex_unlock(g_LEClientStateMutex);
CATerminateLEGattClient();
return CA_STATUS_FAILED;
}
g_isLEGattClientStarted = true;
- ca_mutex_unlock(g_LEClientStateMutex);
+ oc_mutex_unlock(g_LEClientStateMutex);
- ca_mutex_lock(g_LEClientThreadPoolMutex);
+ oc_mutex_lock(g_LEClientThreadPoolMutex);
if (NULL == g_LEClientThreadPool)
{
OIC_LOG(ERROR, TAG, "gBleServerThreadPool is NULL");
CATerminateGattClientMutexVariables();
- ca_mutex_unlock(g_LEClientThreadPoolMutex);
+ oc_mutex_unlock(g_LEClientThreadPoolMutex);
return CA_STATUS_FAILED;
}
{
OIC_LOG(ERROR, TAG, "ca_thread_pool_add_task failed");
CATerminateGattClientMutexVariables();
- ca_mutex_unlock(g_LEClientThreadPoolMutex);
+ oc_mutex_unlock(g_LEClientThreadPoolMutex);
return CA_STATUS_FAILED;
}
- ca_mutex_unlock(g_LEClientThreadPoolMutex);
+ oc_mutex_unlock(g_LEClientThreadPoolMutex);
OIC_LOG(DEBUG, TAG, "OUT");
return CA_STATUS_OK;
OIC_LOG(DEBUG, TAG, "IN");
while (g_isLEGattClientStarted)
{
- ca_mutex_lock(g_multicastDataListMutex);
+ oc_mutex_lock(g_multicastDataListMutex);
if (!g_isMulticastInProgress)
{
OIC_LOG(DEBUG, TAG, "waiting....");
- ca_cond_wait(g_startTimerCond, g_multicastDataListMutex);
+ oc_cond_wait(g_startTimerCond, g_multicastDataListMutex);
OIC_LOG(DEBUG, TAG, "Wake up");
g_isMulticastInProgress = true;
}
// Timed conditional wait for stopping the scan.
- CAWaitResult_t ret = ca_cond_wait_for(g_scanningTimeCond, g_multicastDataListMutex,
+ CAWaitResult_t ret = oc_cond_wait_for(g_scanningTimeCond, g_multicastDataListMutex,
TIMEOUT);
- if (CA_WAIT_TIMEDOUT == ret)
+ if (OC_WAIT_TIMEDOUT == ret)
{
OIC_LOG(DEBUG, TAG, "Scan is timed Out");
// Call stop scan.
u_arraylist_destroy(g_multicastDataList);
g_multicastDataList = NULL;
- ca_mutex_lock(g_deviceDiscoveredListMutex);
+ oc_mutex_lock(g_deviceDiscoveredListMutex);
u_arraylist_destroy(g_deviceDiscoveredList);
g_deviceDiscoveredList = NULL;
- ca_mutex_unlock(g_deviceDiscoveredListMutex);
+ oc_mutex_unlock(g_deviceDiscoveredListMutex);
g_isMulticastInProgress = false;
}
- ca_mutex_unlock(g_multicastDataListMutex);
+ oc_mutex_unlock(g_multicastDataListMutex);
}
OIC_LOG(DEBUG, TAG, "OUT");
{
OIC_LOG(DEBUG, TAG, "IN");
- ca_mutex_lock(g_LEClientStateMutex);
+ oc_mutex_lock(g_LEClientStateMutex);
if (false == g_isLEGattClientStarted)
{
OIC_LOG(ERROR, TAG, "Gatt Client is not running to stop");
- ca_mutex_unlock(g_LEClientStateMutex);
+ oc_mutex_unlock(g_LEClientStateMutex);
return;
}
g_isLEGattClientStarted = false;
// Signal the conditions waiting in Start timer.
- ca_cond_signal(g_startTimerCond);
- ca_cond_signal(g_scanningTimeCond);
+ oc_cond_signal(g_startTimerCond);
+ oc_cond_signal(g_scanningTimeCond);
// Destroy the multicast data list and device list if not empty.
if (NULL != g_multicastDataList)
{
- ca_mutex_lock(g_multicastDataListMutex);
+ oc_mutex_lock(g_multicastDataListMutex);
u_arraylist_destroy(g_multicastDataList);
g_multicastDataList = NULL;
- ca_mutex_unlock(g_multicastDataListMutex);
+ oc_mutex_unlock(g_multicastDataListMutex);
}
if (NULL != g_deviceDiscoveredList)
{
- ca_mutex_lock(g_deviceDiscoveredListMutex);
+ oc_mutex_lock(g_deviceDiscoveredListMutex);
u_arraylist_destroy(g_deviceDiscoveredList);
g_deviceDiscoveredList = NULL;
- ca_mutex_unlock(g_deviceDiscoveredListMutex);
+ oc_mutex_unlock(g_deviceDiscoveredListMutex);
}
- ca_mutex_lock(g_LEServerListMutex);
+ oc_mutex_lock(g_LEServerListMutex);
CAFreeLEServerList(g_LEServerList);
g_LEServerList = NULL;
- ca_mutex_unlock(g_LEServerListMutex);
+ oc_mutex_unlock(g_LEServerListMutex);
- ca_mutex_lock(g_threadWriteCharacteristicMutex);
- ca_cond_signal(g_threadWriteCharacteristicCond);
- ca_mutex_unlock(g_threadWriteCharacteristicMutex);
+ oc_mutex_lock(g_threadWriteCharacteristicMutex);
+ oc_cond_signal(g_threadWriteCharacteristicCond);
+ oc_mutex_unlock(g_threadWriteCharacteristicMutex);
CAResetRegisteredServiceCount();
OIC_LOG(ERROR, TAG, "g_eventLoop context is NULL");
}
- ca_mutex_unlock(g_LEClientStateMutex);
+ oc_mutex_unlock(g_LEClientStateMutex);
OIC_LOG(DEBUG, TAG, "OUT");
}
OIC_LOG(DEBUG, TAG, "IN");
if (NULL == g_LEClientStateMutex)
{
- g_LEClientStateMutex = ca_mutex_new();
+ g_LEClientStateMutex = oc_mutex_new();
if (NULL == g_LEClientStateMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_LEServerListMutex)
{
- g_LEServerListMutex = ca_mutex_new();
+ g_LEServerListMutex = oc_mutex_new();
if (NULL == g_LEServerListMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_LEReqRespClientCbMutex)
{
- g_LEReqRespClientCbMutex = ca_mutex_new();
+ g_LEReqRespClientCbMutex = oc_mutex_new();
if (NULL == g_LEReqRespClientCbMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_LEClientThreadPoolMutex)
{
- g_LEClientThreadPoolMutex = ca_mutex_new();
+ g_LEClientThreadPoolMutex = oc_mutex_new();
if (NULL == g_LEClientThreadPoolMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_LEClientConnectMutex)
{
- g_LEClientConnectMutex = ca_mutex_new();
+ g_LEClientConnectMutex = oc_mutex_new();
if (NULL == g_LEClientConnectMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_multicastDataListMutex)
{
- g_multicastDataListMutex = ca_mutex_new();
+ g_multicastDataListMutex = oc_mutex_new();
if (NULL == g_multicastDataListMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_deviceDiscoveredListMutex)
{
- g_deviceDiscoveredListMutex = ca_mutex_new();
+ g_deviceDiscoveredListMutex = oc_mutex_new();
if (NULL == g_deviceDiscoveredListMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_threadWriteCharacteristicMutex)
{
- g_threadWriteCharacteristicMutex = ca_mutex_new();
+ g_threadWriteCharacteristicMutex = oc_mutex_new();
if (NULL == g_threadWriteCharacteristicMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new has failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new has failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_startTimerCond)
{
- g_startTimerCond = ca_cond_new();
+ g_startTimerCond = oc_cond_new();
if (NULL == g_startTimerCond)
{
- OIC_LOG(ERROR, TAG, "ca_cond_new failed");
+ OIC_LOG(ERROR, TAG, "oc_cond_new failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_scanningTimeCond)
{
- g_scanningTimeCond = ca_cond_new();
+ g_scanningTimeCond = oc_cond_new();
if (NULL == g_scanningTimeCond)
{
- OIC_LOG(ERROR, TAG, "ca_cond_new failed");
+ OIC_LOG(ERROR, TAG, "oc_cond_new failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_threadWriteCharacteristicCond)
{
- g_threadWriteCharacteristicCond = ca_cond_new();
+ g_threadWriteCharacteristicCond = oc_cond_new();
if (NULL == g_threadWriteCharacteristicCond)
{
- OIC_LOG(ERROR, TAG, "ca_cond_new failed");
+ OIC_LOG(ERROR, TAG, "oc_cond_new failed");
return CA_STATUS_FAILED;
}
}
{
OIC_LOG(DEBUG, TAG, "IN");
- ca_mutex_free(g_LEClientStateMutex);
+ oc_mutex_free(g_LEClientStateMutex);
g_LEClientStateMutex = NULL;
- ca_mutex_free(g_LEServerListMutex);
+ oc_mutex_free(g_LEServerListMutex);
g_LEServerListMutex = NULL;
- ca_mutex_free(g_LEReqRespClientCbMutex);
+ oc_mutex_free(g_LEReqRespClientCbMutex);
g_LEReqRespClientCbMutex = NULL;
- ca_mutex_free(g_LEClientConnectMutex);
+ oc_mutex_free(g_LEClientConnectMutex);
g_LEClientConnectMutex = NULL;
- ca_mutex_free(g_LEClientThreadPoolMutex);
+ oc_mutex_free(g_LEClientThreadPoolMutex);
g_LEClientThreadPoolMutex = NULL;
- ca_mutex_free(g_multicastDataListMutex);
+ oc_mutex_free(g_multicastDataListMutex);
g_multicastDataListMutex = NULL;
- ca_mutex_free(g_deviceDiscoveredListMutex);
+ oc_mutex_free(g_deviceDiscoveredListMutex);
g_deviceDiscoveredListMutex = NULL;
- ca_mutex_free(g_threadWriteCharacteristicMutex);
+ oc_mutex_free(g_threadWriteCharacteristicMutex);
g_threadWriteCharacteristicMutex = NULL;
- ca_cond_free(g_startTimerCond);
+ oc_cond_free(g_startTimerCond);
g_startTimerCond = NULL;
- ca_cond_free(g_scanningTimeCond);
+ oc_cond_free(g_scanningTimeCond);
g_scanningTimeCond = NULL;
- ca_cond_free(g_threadWriteCharacteristicCond);
+ oc_cond_free(g_threadWriteCharacteristicCond);
g_threadWriteCharacteristicCond = NULL;
g_isSignalSetFlag = false;
VERIFY_NON_NULL_RET(remoteAddress, TAG,
"remote address is NULL", CA_STATUS_FAILED);
- ca_mutex_lock(g_LEClientConnectMutex);
+ oc_mutex_lock(g_LEClientConnectMutex);
bool isConnected = false;
int ret = bt_device_is_profile_connected(remoteAddress, BT_PROFILE_GATT, &isConnected);
if (BT_ERROR_NONE != ret)
{
OIC_LOG_V(ERROR, TAG, "bt_device_is_profile_connected Failed with ret value [%s] ",
CALEGetErrorMsg(ret));
- ca_mutex_unlock(g_LEClientConnectMutex);
+ oc_mutex_unlock(g_LEClientConnectMutex);
return CA_STATUS_FAILED;
}
{
OIC_LOG_V(ERROR, TAG, "bt_gatt_connect Failed with ret value [%s] ",
CALEGetErrorMsg(ret));
- ca_mutex_unlock(g_LEClientConnectMutex);
+ oc_mutex_unlock(g_LEClientConnectMutex);
return CA_STATUS_FAILED;
}
}
if (NULL == addr)
{
OIC_LOG(ERROR, TAG, "addr is NULL");
- ca_mutex_unlock(g_LEClientConnectMutex);
+ oc_mutex_unlock(g_LEClientConnectMutex);
return CA_STATUS_FAILED;
}
- ca_mutex_lock(g_LEClientThreadPoolMutex);
+ oc_mutex_lock(g_LEClientThreadPoolMutex);
if (NULL == g_LEClientThreadPool)
{
OIC_LOG(ERROR, TAG, "g_LEClientThreadPool is NULL");
OICFree(addr);
- ca_mutex_unlock(g_LEClientThreadPoolMutex);
- ca_mutex_unlock(g_LEClientConnectMutex);
+ oc_mutex_unlock(g_LEClientThreadPoolMutex);
+ oc_mutex_unlock(g_LEClientConnectMutex);
return CA_STATUS_FAILED;
}
OIC_LOG_V(ERROR, TAG, "ca_thread_pool_add_task failed with ret [%d]", result);
OICFree(addr);
}
- ca_mutex_unlock(g_LEClientThreadPoolMutex);
+ oc_mutex_unlock(g_LEClientThreadPoolMutex);
}
- ca_mutex_unlock(g_LEClientConnectMutex);
+ oc_mutex_unlock(g_LEClientConnectMutex);
OIC_LOG(DEBUG, TAG, "OUT");
return result;
serverInfo->writeChar = writeChrHandle;
serverInfo->remoteAddress = OICStrdup(remoteAddress);
- ca_mutex_lock(g_LEServerListMutex);
+ oc_mutex_lock(g_LEServerListMutex);
CAResult_t result = CAAddLEServerInfoToList(&g_LEServerList, serverInfo);
if (CA_STATUS_OK != result)
{
CALEGattDisConnect(remoteAddress);
return CA_STATUS_FAILED;
}
- ca_mutex_unlock(g_LEServerListMutex);
+ oc_mutex_unlock(g_LEServerListMutex);
// Send the data of pending multicast data list if any.
if (g_multicastDataList)
{
- ca_mutex_lock(g_multicastDataListMutex);
+ oc_mutex_lock(g_multicastDataListMutex);
uint32_t arrayLength = u_arraylist_length(g_multicastDataList);
for (int i = 0; i < arrayLength; i++)
{
CAUpdateCharacteristicsToGattServer(remoteAddress, multicastData->data,
multicastData->dataLen, LE_UNICAST, 0);
}
- ca_mutex_unlock(g_multicastDataListMutex);
+ oc_mutex_unlock(g_multicastDataListMutex);
}
OIC_LOG(DEBUG, TAG, "OUT");
LEServerInfo *leServerInfo = NULL;
CAResult_t ret = CA_STATUS_FAILED;
- ca_mutex_lock(g_LEServerListMutex);
+ oc_mutex_lock(g_LEServerListMutex);
if (LE_UNICAST == type)
{
ret = CAGetLEServerInfo(g_LEServerList, remoteAddress, &leServerInfo);
{
ret = CAGetLEServerInfoByPosition(g_LEServerList, position, &leServerInfo);
}
- ca_mutex_unlock(g_LEServerListMutex);
+ oc_mutex_unlock(g_LEServerListMutex);
if (CA_STATUS_OK != ret)
{
// wait for callback for write Characteristic with success to sent data
OIC_LOG_V(DEBUG, TAG, "callback flag is %d", g_isSignalSetFlag);
- ca_mutex_lock(g_threadWriteCharacteristicMutex);
+ oc_mutex_lock(g_threadWriteCharacteristicMutex);
if (!g_isSignalSetFlag)
{
OIC_LOG(DEBUG, TAG, "wait for callback to notify writeCharacteristic is success");
- if (CA_WAIT_SUCCESS != ca_cond_wait_for(g_threadWriteCharacteristicCond,
+ if (OC_WAIT_SUCCESS != oc_cond_wait_for(g_threadWriteCharacteristicCond,
g_threadWriteCharacteristicMutex,
WAIT_TIME_WRITE_CHARACTERISTIC))
{
OIC_LOG(ERROR, TAG, "there is no response. write has failed");
g_isSignalSetFlag = false;
- ca_mutex_unlock(g_threadWriteCharacteristicMutex);
+ oc_mutex_unlock(g_threadWriteCharacteristicMutex);
return CA_SEND_FAILED;
}
}
// reset flag set by writeCharacteristic Callback
g_isSignalSetFlag = false;
- ca_mutex_unlock(g_threadWriteCharacteristicMutex);
+ oc_mutex_unlock(g_threadWriteCharacteristicMutex);
OIC_LOG(DEBUG, TAG, "OUT");
return CA_STATUS_OK;
memcpy(multicastData->data, data, dataLen);
multicastData->dataLen = dataLen;
- ca_mutex_lock(g_multicastDataListMutex);
+ oc_mutex_lock(g_multicastDataListMutex);
if (NULL == g_multicastDataList)
{
g_multicastDataList = u_arraylist_create();
}
u_arraylist_add(g_multicastDataList, (void *)multicastData);
- ca_mutex_unlock(g_multicastDataListMutex);
+ oc_mutex_unlock(g_multicastDataListMutex);
// Start the scanning.
CAResult_t result = CALEGattStartDeviceScanning();
}
// Start the timer by signalling it.
- ca_cond_signal(g_startTimerCond);
+ oc_cond_signal(g_startTimerCond);
exit:
OIC_LOG(DEBUG, TAG, "OUT ");
* Mutex to synchronize access to the deviceStateChanged Callback when the state
* of the LE adapter gets change.
*/
-static ca_mutex g_bleDeviceStateChangedCbMutex = NULL;
+static oc_mutex g_bleDeviceStateChangedCbMutex = NULL;
/**
* Mutex to synchronize access to the ConnectionStateChanged Callback when the state
* of the LE adapter gets change.
*/
-static ca_mutex g_bleConnectionStateChangedCbMutex = NULL;
+static oc_mutex g_bleConnectionStateChangedCbMutex = NULL;
/**
* This is the callback which will be called when the adapter state gets changed.
if (NULL == g_bleDeviceStateChangedCbMutex)
{
- g_bleDeviceStateChangedCbMutex = ca_mutex_new();
+ g_bleDeviceStateChangedCbMutex = oc_mutex_new();
if (NULL == g_bleDeviceStateChangedCbMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_bleConnectionStateChangedCbMutex)
{
- g_bleConnectionStateChangedCbMutex = ca_mutex_new();
+ g_bleConnectionStateChangedCbMutex = oc_mutex_new();
if (NULL == g_bleConnectionStateChangedCbMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new failed");
- ca_mutex_free(g_bleDeviceStateChangedCbMutex);
+ OIC_LOG(ERROR, TAG, "oc_mutex_new failed");
+ oc_mutex_free(g_bleDeviceStateChangedCbMutex);
return CA_STATUS_FAILED;
}
}
{
OIC_LOG(DEBUG, TAG, "IN");
- ca_mutex_free(g_bleDeviceStateChangedCbMutex);
+ oc_mutex_free(g_bleDeviceStateChangedCbMutex);
g_bleDeviceStateChangedCbMutex = NULL;
- ca_mutex_free(g_bleConnectionStateChangedCbMutex);
+ oc_mutex_free(g_bleConnectionStateChangedCbMutex);
g_bleConnectionStateChangedCbMutex = NULL;
OIC_LOG(DEBUG, TAG, "OUT");
CAResult_t CASetLEAdapterStateChangedCb(CALEDeviceStateChangedCallback callback)
{
OIC_LOG(DEBUG, TAG, "IN");
- ca_mutex_lock(g_bleDeviceStateChangedCbMutex);
+ oc_mutex_lock(g_bleDeviceStateChangedCbMutex);
g_bleDeviceStateChangedCallback = callback;
- ca_mutex_unlock(g_bleDeviceStateChangedCbMutex);
+ oc_mutex_unlock(g_bleDeviceStateChangedCbMutex);
OIC_LOG(DEBUG, TAG, "OUT");
return CA_STATUS_OK;
}
CAResult_t CAUnSetLEAdapterStateChangedCb()
{
OIC_LOG(DEBUG, TAG, "IN");
- ca_mutex_lock(g_bleDeviceStateChangedCbMutex);
+ oc_mutex_lock(g_bleDeviceStateChangedCbMutex);
g_bleDeviceStateChangedCallback = NULL;
- ca_mutex_unlock(g_bleDeviceStateChangedCbMutex);
+ oc_mutex_unlock(g_bleDeviceStateChangedCbMutex);
OIC_LOG(DEBUG, TAG, "OUT");
return CA_STATUS_OK;
}
CAResult_t CASetLENWConnectionStateChangedCb(CALEConnectionStateChangedCallback callback)
{
OIC_LOG(DEBUG, TAG, "IN");
- ca_mutex_lock(g_bleConnectionStateChangedCbMutex);
+ oc_mutex_lock(g_bleConnectionStateChangedCbMutex);
g_bleConnectionStateChangedCallback = callback;
- ca_mutex_unlock(g_bleConnectionStateChangedCbMutex);
+ oc_mutex_unlock(g_bleConnectionStateChangedCbMutex);
OIC_LOG(DEBUG, TAG, "OUT");
return CA_STATUS_OK;
}
CAResult_t CAUnsetLENWConnectionStateChangedCb()
{
OIC_LOG(DEBUG, TAG, "IN");
- ca_mutex_lock(g_bleConnectionStateChangedCbMutex);
+ oc_mutex_lock(g_bleConnectionStateChangedCbMutex);
g_bleConnectionStateChangedCallback = NULL;
- ca_mutex_unlock(g_bleConnectionStateChangedCbMutex);
+ oc_mutex_unlock(g_bleConnectionStateChangedCbMutex);
OIC_LOG(DEBUG, TAG, "OUT");
return CA_STATUS_OK;
}
{
OIC_LOG(DEBUG, TAG, "IN");
- ca_mutex_lock(g_bleDeviceStateChangedCbMutex);
+ oc_mutex_lock(g_bleDeviceStateChangedCbMutex);
if (NULL == g_bleDeviceStateChangedCallback)
{
OIC_LOG(ERROR, TAG, "g_bleDeviceStateChangedCallback is NULL!");
- ca_mutex_unlock(g_bleDeviceStateChangedCbMutex);
+ oc_mutex_unlock(g_bleDeviceStateChangedCbMutex);
return;
}
{
OIC_LOG(DEBUG, TAG, "Adapter is disabled");
g_bleDeviceStateChangedCallback(CA_ADAPTER_DISABLED);
- ca_mutex_unlock(g_bleDeviceStateChangedCbMutex);
+ oc_mutex_unlock(g_bleDeviceStateChangedCbMutex);
return;
}
}
g_bleDeviceStateChangedCallback(CA_ADAPTER_ENABLED);
- ca_mutex_unlock(g_bleDeviceStateChangedCbMutex);
+ oc_mutex_unlock(g_bleDeviceStateChangedCbMutex);
OIC_LOG(DEBUG, TAG, "OUT");
}
VERIFY_NON_NULL_VOID(remoteAddress, TAG, "remote address is NULL");
- ca_mutex_lock(g_bleConnectionStateChangedCbMutex);
+ oc_mutex_lock(g_bleConnectionStateChangedCbMutex);
char *addr = OICStrdup(remoteAddress);
if (NULL == addr)
{
OIC_LOG(ERROR, TAG, "addr is NULL");
- ca_mutex_unlock(g_bleConnectionStateChangedCbMutex);
+ oc_mutex_unlock(g_bleConnectionStateChangedCbMutex);
return;
}
g_bleConnectionStateChangedCallback(CA_ADAPTER_GATT_BTLE, addr, connected);
OICFree(addr);
- ca_mutex_unlock(g_bleConnectionStateChangedCbMutex);
+ oc_mutex_unlock(g_bleConnectionStateChangedCbMutex);
OIC_LOG(DEBUG, TAG, "OUT");
}
/**
* Mutex to synchronize the calls to start and stop server.
*/
-static ca_mutex g_leServerStateMutex = NULL;
+static oc_mutex g_leServerStateMutex = NULL;
/**
* Mutex to synchronize writing operations on the characteristics.
*/
-static ca_mutex g_leCharacteristicMutex = NULL;
+static oc_mutex g_leCharacteristicMutex = NULL;
/**
* Mutex to synchronize to creation of OIC service.
*/
-static ca_mutex g_leServiceMutex = NULL;
+static oc_mutex g_leServiceMutex = NULL;
/**
* Mutex to synchronize access to the requestResponse callback to be called
* when the data needs to be sent from GATTClient.
*/
-static ca_mutex g_leReqRespCbMutex = NULL;
+static oc_mutex g_leReqRespCbMutex = NULL;
/**
* Mutex to synchronize the task to be pushed to thread pool.
*/
-static ca_mutex g_leServerThreadPoolMutex = NULL;
+static oc_mutex g_leServerThreadPoolMutex = NULL;
/**
* Reference to threadpool.
/**
* Mutex to synchronize access to LE ClientList.
*/
-static ca_mutex g_LEClientListMutex = NULL;
+static oc_mutex g_LEClientListMutex = NULL;
void CALEGattServerConnectionStateChanged(bool connected, const char *remoteAddress)
{
{
OIC_LOG_V(DEBUG, TAG, "Connected to [%s]", remoteAddress);
char *addr = OICStrdup(remoteAddress);
- ca_mutex_lock(g_LEClientListMutex);
+ oc_mutex_lock(g_LEClientListMutex);
CAResult_t result = CAAddLEClientInfoToList(&g_LEClientList, addr);
if (CA_STATUS_OK != result)
{
OIC_LOG(ERROR, TAG, "CAAddLEClientInfoToList failed");
- ca_mutex_unlock(g_LEClientListMutex);
+ oc_mutex_unlock(g_LEClientListMutex);
OICFree(addr);
return;
}
- ca_mutex_unlock(g_LEClientListMutex);
+ oc_mutex_unlock(g_LEClientListMutex);
}
else
{
OIC_LOG_V(DEBUG, TAG, "Disconnected from [%s]", remoteAddress);
- ca_mutex_lock(g_LEClientListMutex);
+ oc_mutex_lock(g_LEClientListMutex);
CARemoveLEClientInfoFromList(&g_LEClientList, remoteAddress);
- ca_mutex_unlock(g_LEClientListMutex);
+ oc_mutex_unlock(g_LEClientListMutex);
}
}
{
OIC_LOG(DEBUG, TAG, "IN");
- ca_mutex_lock(g_leServerStateMutex);
+ oc_mutex_lock(g_leServerStateMutex);
if (true == g_isLEGattServerStarted)
{
OIC_LOG(ERROR, TAG, "Gatt Server is already running");
- ca_mutex_unlock(g_leServerStateMutex);
+ oc_mutex_unlock(g_leServerStateMutex);
return CA_STATUS_OK;
}
if (CA_STATUS_OK != ret)
{
OIC_LOG_V(ERROR, TAG, "CAInitLEGattServer failed[%d]", ret);
- ca_mutex_unlock(g_leServerStateMutex);
+ oc_mutex_unlock(g_leServerStateMutex);
CATerminateLEGattServer();
return CA_STATUS_FAILED;
}
if (CA_STATUS_OK != ret)
{
OIC_LOG_V(ERROR, TAG, "CAAddNewLEServiceInGattServer failed[%d]", ret);
- ca_mutex_unlock(g_leServerStateMutex);
+ oc_mutex_unlock(g_leServerStateMutex);
CATerminateLEGattServer();
return CA_STATUS_FAILED;
}
if (CA_STATUS_OK != ret)
{
OIC_LOG_V(ERROR, TAG, "CAAddNewCharacteristicsToGattServer failed[%d]", ret);
- ca_mutex_unlock(g_leServerStateMutex);
+ oc_mutex_unlock(g_leServerStateMutex);
CATerminateLEGattServer();
return CA_STATUS_FAILED;
}
if (CA_STATUS_OK != ret )
{
OIC_LOG_V(ERROR, TAG, "CAAddNewCharacteristicsToGattServer failed[%d]", ret);
- ca_mutex_unlock(g_leServerStateMutex);
+ oc_mutex_unlock(g_leServerStateMutex);
CATerminateLEGattServer();
return CA_STATUS_FAILED;
}
if (CA_STATUS_OK != ret )
{
OIC_LOG_V(ERROR, TAG, "CARegisterLEServicewithGattServer failed[%d]", ret);
- ca_mutex_unlock(g_leServerStateMutex);
+ oc_mutex_unlock(g_leServerStateMutex);
CATerminateLEGattServer();
return CA_STATUS_FAILED;
}
if (CA_STATUS_OK != ret)
{
OIC_LOG_V(ERROR, TAG, "CALEStartAdvertise failed[%d]", ret);
- ca_mutex_unlock(g_leServerStateMutex);
+ oc_mutex_unlock(g_leServerStateMutex);
CATerminateLEGattServer();
return CA_STATUS_FAILED;
}
g_isLEGattServerStarted = true;
- ca_mutex_unlock(g_leServerStateMutex);
+ oc_mutex_unlock(g_leServerStateMutex);
OIC_LOG(DEBUG, TAG, "OUT");
return CA_STATUS_OK;
{
OIC_LOG(DEBUG, TAG, "IN");
- ca_mutex_lock(g_leServerStateMutex);
+ oc_mutex_lock(g_leServerStateMutex);
if (false == g_isLEGattServerStarted)
{
OIC_LOG(ERROR, TAG, "Gatt Server is not running to stop");
- ca_mutex_unlock(g_leServerStateMutex);
+ oc_mutex_unlock(g_leServerStateMutex);
return CA_STATUS_OK;
}
g_isLEGattServerStarted = false;
- ca_mutex_lock(g_LEClientListMutex);
+ oc_mutex_lock(g_LEClientListMutex);
CADisconnectAllClient(g_LEClientList);
g_LEClientList = NULL;
- ca_mutex_unlock(g_LEClientListMutex);
+ oc_mutex_unlock(g_LEClientListMutex);
CAResult_t res = CALEStopAdvertise();
{
OIC_LOG(ERROR, TAG, "g_eventLoop context is NULL");
}
- ca_mutex_unlock(g_leServerStateMutex);
+ oc_mutex_unlock(g_leServerStateMutex);
OIC_LOG(DEBUG, TAG, "OUT");
return CA_STATUS_OK;
OIC_LOG(DEBUG, TAG, "IN");
// Service and characteristics path will be freed by the platform.
- ca_mutex_lock(g_leServiceMutex);
+ oc_mutex_lock(g_leServiceMutex);
g_gattSvcPath = NULL;
- ca_mutex_unlock(g_leServiceMutex);
+ oc_mutex_unlock(g_leServiceMutex);
- ca_mutex_lock(g_leCharacteristicMutex);
+ oc_mutex_lock(g_leCharacteristicMutex);
g_gattReadCharPath = NULL;
g_gattWriteCharPath = NULL;
- ca_mutex_unlock(g_leCharacteristicMutex);
+ oc_mutex_unlock(g_leCharacteristicMutex);
- ca_mutex_lock(g_leServerThreadPoolMutex);
+ oc_mutex_lock(g_leServerThreadPoolMutex);
g_leServerThreadPool = NULL;
- ca_mutex_unlock(g_leServerThreadPoolMutex);
+ oc_mutex_unlock(g_leServerThreadPoolMutex);
// Terminating all mutex variables.
CATerminateGattServerMutexVariables();
OIC_LOG(DEBUG, TAG, "IN");
if (NULL == g_leServerStateMutex)
{
- g_leServerStateMutex = ca_mutex_new();
+ g_leServerStateMutex = oc_mutex_new();
if (NULL == g_leServerStateMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_leServiceMutex)
{
- g_leServiceMutex = ca_mutex_new();
+ g_leServiceMutex = oc_mutex_new();
if (NULL == g_leServiceMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_leCharacteristicMutex)
{
- g_leCharacteristicMutex = ca_mutex_new();
+ g_leCharacteristicMutex = oc_mutex_new();
if (NULL == g_leCharacteristicMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_leReqRespCbMutex)
{
- g_leReqRespCbMutex = ca_mutex_new();
+ g_leReqRespCbMutex = oc_mutex_new();
if (NULL == g_leReqRespCbMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_leServerThreadPoolMutex)
{
- g_leServerThreadPoolMutex = ca_mutex_new();
+ g_leServerThreadPoolMutex = oc_mutex_new();
if (NULL == g_leServerThreadPoolMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_LEClientListMutex)
{
- g_LEClientListMutex = ca_mutex_new();
+ g_LEClientListMutex = oc_mutex_new();
if (NULL == g_LEClientListMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new failed");
return CA_STATUS_FAILED;
}
}
void CATerminateGattServerMutexVariables()
{
OIC_LOG(DEBUG, TAG, "IN");
- ca_mutex_free(g_leServerStateMutex);
+ oc_mutex_free(g_leServerStateMutex);
g_leServerStateMutex = NULL;
- ca_mutex_free(g_leServiceMutex);
+ oc_mutex_free(g_leServiceMutex);
g_leServiceMutex = NULL;
- ca_mutex_free(g_leCharacteristicMutex);
+ oc_mutex_free(g_leCharacteristicMutex);
g_leCharacteristicMutex = NULL;
- ca_mutex_free(g_leReqRespCbMutex);
+ oc_mutex_free(g_leReqRespCbMutex);
g_leReqRespCbMutex = NULL;
- ca_mutex_free(g_leServerThreadPoolMutex);
+ oc_mutex_free(g_leServerThreadPoolMutex);
g_leServerThreadPoolMutex = NULL;
- ca_mutex_free(g_LEClientListMutex);
+ oc_mutex_free(g_LEClientListMutex);
g_LEClientListMutex = NULL;
OIC_LOG(DEBUG, TAG, "OUT");
void CASetLEServerThreadPoolHandle(ca_thread_pool_t handle)
{
OIC_LOG(DEBUG, TAG, "IN");
- ca_mutex_lock(g_leServerThreadPoolMutex);
+ oc_mutex_lock(g_leServerThreadPoolMutex);
g_leServerThreadPool = handle;
- ca_mutex_unlock(g_leServerThreadPoolMutex);
+ oc_mutex_unlock(g_leServerThreadPoolMutex);
OIC_LOG(DEBUG, TAG, "OUT");
}
bt_gatt_service_type_e type = BT_GATT_SERVICE_TYPE_PRIMARY;
- ca_mutex_lock(g_leServiceMutex);
+ oc_mutex_lock(g_leServiceMutex);
int ret = bt_gatt_service_create(serviceUUID, type, &g_gattSvcPath);
if (0 != ret)
{
- ca_mutex_unlock(g_leServiceMutex);
+ oc_mutex_unlock(g_leServiceMutex);
OIC_LOG_V(ERROR, TAG, "bt_gatt_service_create failed with ret [%s]",
CALEGetErrorMsg(ret));
return CA_STATUS_FAILED;
}
- ca_mutex_unlock(g_leServiceMutex);
+ oc_mutex_unlock(g_leServiceMutex);
if (g_gattSvcPath)
{
memcpy(data, charValue, charValueLen);
- ca_mutex_lock(g_leReqRespCbMutex);
+ oc_mutex_lock(g_leReqRespCbMutex);
if (NULL == g_leServerDataReceivedCallback)
{
OIC_LOG(ERROR, TAG, "gReqRespCallback is NULL!");
- ca_mutex_unlock(g_leReqRespCbMutex);
+ oc_mutex_unlock(g_leReqRespCbMutex);
OICFree(data);
return;
}
uint32_t sentLength = 0;
g_leServerDataReceivedCallback(remoteAddress, data, charValueLen,
&sentLength);
- ca_mutex_unlock(g_leReqRespCbMutex);
+ oc_mutex_unlock(g_leReqRespCbMutex);
OICFree(data);
OIC_LOG(DEBUG, TAG, "OUT");
}
return CA_STATUS_FAILED;
}
- ca_mutex_lock(g_leCharacteristicMutex);
+ oc_mutex_lock(g_leCharacteristicMutex);
if (read)
{
&descriptor);
if (0 != ret)
{
- ca_mutex_unlock(g_leCharacteristicMutex);
+ oc_mutex_unlock(g_leCharacteristicMutex);
OIC_LOG_V(ERROR, TAG,
"bt_gatt_descriptor_create failed with ret[%s]",
CALEGetErrorMsg(ret));
ret = bt_gatt_characteristic_add_descriptor(charPath, descriptor);
if (0 != ret)
{
- ca_mutex_unlock(g_leCharacteristicMutex);
+ oc_mutex_unlock(g_leCharacteristicMutex);
OIC_LOG_V(ERROR, TAG,
"bt_gatt_characteristic_add_descriptor failed with ret[%s]",
CALEGetErrorMsg(ret));
g_gattWriteCharPath = charPath;
}
- ca_mutex_unlock(g_leCharacteristicMutex);
+ oc_mutex_unlock(g_leCharacteristicMutex);
OIC_LOG(DEBUG, TAG, "OUT");
return CA_STATUS_OK;
OIC_LOG_V(DEBUG, TAG, "Client's Unicast address for sending data [%s]", address);
- ca_mutex_lock(g_leCharacteristicMutex);
+ oc_mutex_lock(g_leCharacteristicMutex);
if (NULL == g_gattReadCharPath)
{
OIC_LOG(ERROR, TAG, "g_gattReadCharPath is NULL");
- ca_mutex_unlock(g_leCharacteristicMutex);
+ oc_mutex_unlock(g_leCharacteristicMutex);
return CA_STATUS_FAILED;
}
{
OIC_LOG_V(ERROR, TAG,
"bt_gatt_set_value failed with return [%s]", CALEGetErrorMsg(ret));
- ca_mutex_unlock(g_leCharacteristicMutex);
+ oc_mutex_unlock(g_leCharacteristicMutex);
return CA_STATUS_FAILED;
}
{
OIC_LOG_V(ERROR, TAG,
"bt_gatt_server_notify failed with return [%s]", CALEGetErrorMsg(ret));
- ca_mutex_unlock(g_leCharacteristicMutex);
+ oc_mutex_unlock(g_leCharacteristicMutex);
return CA_STATUS_FAILED;
}
- ca_mutex_unlock(g_leCharacteristicMutex);
+ oc_mutex_unlock(g_leCharacteristicMutex);
OIC_LOG(DEBUG, TAG, "OUT");
return CA_STATUS_OK;
VERIFY_NON_NULL(charValue, TAG, "charValue");
- ca_mutex_lock(g_leCharacteristicMutex);
+ oc_mutex_lock(g_leCharacteristicMutex);
if (NULL == g_gattReadCharPath)
{
OIC_LOG(ERROR, TAG, "g_gattReadCharPath is NULL");
- ca_mutex_unlock(g_leCharacteristicMutex);
+ oc_mutex_unlock(g_leCharacteristicMutex);
return CA_STATUS_FAILED;
}
if (0 != ret)
{
OIC_LOG_V(ERROR, TAG, "bt_gatt_set_value failed with return[%s]", CALEGetErrorMsg(ret));
- ca_mutex_unlock(g_leCharacteristicMutex);
+ oc_mutex_unlock(g_leCharacteristicMutex);
return CA_STATUS_FAILED;
}
{
OIC_LOG_V(ERROR, TAG,
"bt_gatt_server_notify failed with return[%s]", CALEGetErrorMsg(ret));
- ca_mutex_unlock(g_leCharacteristicMutex);
+ oc_mutex_unlock(g_leCharacteristicMutex);
return CA_STATUS_FAILED;
}
- ca_mutex_unlock(g_leCharacteristicMutex);
+ oc_mutex_unlock(g_leCharacteristicMutex);
OIC_LOG(DEBUG, TAG, "OUT");
return CA_STATUS_OK;
{
OIC_LOG(DEBUG, TAG, "IN");
- ca_mutex_lock(g_leReqRespCbMutex);
+ oc_mutex_lock(g_leReqRespCbMutex);
g_leServerDataReceivedCallback = callback;
- ca_mutex_unlock(g_leReqRespCbMutex);
+ oc_mutex_unlock(g_leReqRespCbMutex);
OIC_LOG(DEBUG, TAG, "OUT");
}
{
if (!g_context.blockDataListMutex)
{
- g_context.blockDataListMutex = ca_mutex_new();
+ g_context.blockDataListMutex = oc_mutex_new();
if (!g_context.blockDataListMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new has failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new has failed");
return CA_STATUS_FAILED;
}
}
if (!g_context.blockDataSenderMutex)
{
- g_context.blockDataSenderMutex = ca_mutex_new();
+ g_context.blockDataSenderMutex = oc_mutex_new();
if (!g_context.blockDataSenderMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new has failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new has failed");
CATerminateBlockWiseMutexVariables();
return CA_STATUS_FAILED;
}
{
if (g_context.blockDataListMutex)
{
- ca_mutex_free(g_context.blockDataListMutex);
+ oc_mutex_free(g_context.blockDataListMutex);
g_context.blockDataListMutex = NULL;
}
if (g_context.blockDataSenderMutex)
{
- ca_mutex_free(g_context.blockDataSenderMutex);
+ oc_mutex_free(g_context.blockDataSenderMutex);
g_context.blockDataSenderMutex = NULL;
}
}
if (g_context.sendThreadFunc)
{
- ca_mutex_lock(g_context.blockDataSenderMutex);
+ oc_mutex_lock(g_context.blockDataSenderMutex);
g_context.sendThreadFunc(cloneData);
- ca_mutex_unlock(g_context.blockDataSenderMutex);
+ oc_mutex_unlock(g_context.blockDataSenderMutex);
}
else
{
// add data to send thread
if (g_context.sendThreadFunc)
{
- ca_mutex_lock(g_context.blockDataSenderMutex);
+ oc_mutex_lock(g_context.blockDataSenderMutex);
g_context.sendThreadFunc(cloneData);
- ca_mutex_unlock(g_context.blockDataSenderMutex);
+ oc_mutex_unlock(g_context.blockDataSenderMutex);
}
else
{
OIC_LOG(DEBUG, TAG, "IN-UpdateBlockOptionType");
VERIFY_NON_NULL(blockID, TAG, "blockID");
- ca_mutex_lock(g_context.blockDataListMutex);
+ oc_mutex_lock(g_context.blockDataListMutex);
size_t len = u_arraylist_length(g_context.dataList);
for (size_t i = 0; i < len; i++)
if (CABlockidMatches(currData, blockID))
{
currData->type = blockType;
- ca_mutex_unlock(g_context.blockDataListMutex);
+ oc_mutex_unlock(g_context.blockDataListMutex);
OIC_LOG(DEBUG, TAG, "OUT-UpdateBlockOptionType");
return CA_STATUS_OK;
}
}
- ca_mutex_unlock(g_context.blockDataListMutex);
+ oc_mutex_unlock(g_context.blockDataListMutex);
OIC_LOG(DEBUG, TAG, "OUT-UpdateBlockOptionType");
return CA_STATUS_FAILED;
OIC_LOG(DEBUG, TAG, "IN-GetBlockOptionType");
VERIFY_NON_NULL_RET(blockID, TAG, "blockID", 0);
- ca_mutex_lock(g_context.blockDataListMutex);
+ oc_mutex_lock(g_context.blockDataListMutex);
size_t len = u_arraylist_length(g_context.dataList);
for (size_t i = 0; i < len; i++)
CABlockData_t *currData = (CABlockData_t *) u_arraylist_get(g_context.dataList, i);
if (CABlockidMatches(currData, blockID))
{
- ca_mutex_unlock(g_context.blockDataListMutex);
+ oc_mutex_unlock(g_context.blockDataListMutex);
OIC_LOG(DEBUG, TAG, "OUT-GetBlockOptionType");
return currData->type;
}
}
- ca_mutex_unlock(g_context.blockDataListMutex);
+ oc_mutex_unlock(g_context.blockDataListMutex);
OIC_LOG(DEBUG, TAG, "OUT-GetBlockOptionType");
return 0;
{
VERIFY_NON_NULL_RET(blockID, TAG, "blockID", NULL);
- ca_mutex_lock(g_context.blockDataListMutex);
+ oc_mutex_lock(g_context.blockDataListMutex);
size_t len = u_arraylist_length(g_context.dataList);
for (size_t i = 0; i < len; i++)
CABlockData_t *currData = (CABlockData_t *) u_arraylist_get(g_context.dataList, i);
if (CABlockidMatches(currData, blockID))
{
- ca_mutex_unlock(g_context.blockDataListMutex);
+ oc_mutex_unlock(g_context.blockDataListMutex);
return currData->sentData;
}
}
- ca_mutex_unlock(g_context.blockDataListMutex);
+ oc_mutex_unlock(g_context.blockDataListMutex);
return NULL;
}
VERIFY_NON_NULL(endpoint, TAG, "endpoint");
VERIFY_NON_NULL(responseInfo, TAG, "responseInfo");
- ca_mutex_lock(g_context.blockDataListMutex);
+ oc_mutex_lock(g_context.blockDataListMutex);
size_t len = u_arraylist_length(g_context.dataList);
for (size_t i = 0; i < len; i++)
if (NULL == responseInfo->info.token)
{
OIC_LOG(ERROR, TAG, "out of memory");
- ca_mutex_unlock(g_context.blockDataListMutex);
+ oc_mutex_unlock(g_context.blockDataListMutex);
return CA_MEMORY_ALLOC_FAILED;
}
memcpy(responseInfo->info.token, currData->sentData->requestInfo->info.token,
responseInfo->info.tokenLength);
- ca_mutex_unlock(g_context.blockDataListMutex);
+ oc_mutex_unlock(g_context.blockDataListMutex);
OIC_LOG(DEBUG, TAG, "OUT-CAGetTokenFromBlockDataList");
return CA_STATUS_OK;
}
}
}
- ca_mutex_unlock(g_context.blockDataListMutex);
+ oc_mutex_unlock(g_context.blockDataListMutex);
OIC_LOG(DEBUG, TAG, "OUT-CAGetTokenFromBlockDataList");
return CA_STATUS_FAILED;
{
VERIFY_NON_NULL_RET(blockID, TAG, "blockID", NULL);
- ca_mutex_lock(g_context.blockDataListMutex);
+ oc_mutex_lock(g_context.blockDataListMutex);
size_t len = u_arraylist_length(g_context.dataList);
for (size_t i = 0; i < len; i++)
CABlockData_t *currData = (CABlockData_t *) u_arraylist_get(g_context.dataList, i);
if (CABlockidMatches(currData, blockID))
{
- ca_mutex_unlock(g_context.blockDataListMutex);
+ oc_mutex_unlock(g_context.blockDataListMutex);
return currData;
}
}
- ca_mutex_unlock(g_context.blockDataListMutex);
+ oc_mutex_unlock(g_context.blockDataListMutex);
return NULL;
}
OIC_LOG(DEBUG, TAG, "IN-GetBlockOption");
VERIFY_NON_NULL_RET(blockID, TAG, "blockID", NULL);
- ca_mutex_lock(g_context.blockDataListMutex);
+ oc_mutex_lock(g_context.blockDataListMutex);
size_t len = u_arraylist_length(g_context.dataList);
for (size_t i = 0; i < len; i++)
CABlockData_t *currData = (CABlockData_t *) u_arraylist_get(g_context.dataList, i);
if (CABlockidMatches(currData, blockID))
{
- ca_mutex_unlock(g_context.blockDataListMutex);
+ oc_mutex_unlock(g_context.blockDataListMutex);
OIC_LOG(DEBUG, TAG, "OUT-GetBlockOption");
if (COAP_OPTION_BLOCK2 == blockType)
{
}
}
}
- ca_mutex_unlock(g_context.blockDataListMutex);
+ oc_mutex_unlock(g_context.blockDataListMutex);
OIC_LOG(DEBUG, TAG, "OUT-GetBlockOption");
return NULL;
VERIFY_NON_NULL_RET(blockID, TAG, "blockID", NULL);
VERIFY_NON_NULL_RET(fullPayloadLen, TAG, "fullPayloadLen", NULL);
- ca_mutex_lock(g_context.blockDataListMutex);
+ oc_mutex_lock(g_context.blockDataListMutex);
size_t len = u_arraylist_length(g_context.dataList);
for (size_t i = 0; i < len; i++)
CABlockData_t *currData = (CABlockData_t *) u_arraylist_get(g_context.dataList, i);
if (CABlockidMatches(currData, blockID))
{
- ca_mutex_unlock(g_context.blockDataListMutex);
+ oc_mutex_unlock(g_context.blockDataListMutex);
*fullPayloadLen = currData->receivedPayloadLen;
OIC_LOG(DEBUG, TAG, "OUT-GetFullPayload");
return currData->payload;
}
}
- ca_mutex_unlock(g_context.blockDataListMutex);
+ oc_mutex_unlock(g_context.blockDataListMutex);
OIC_LOG(DEBUG, TAG, "OUT-GetFullPayload");
return NULL;
}
data->blockDataId = blockDataID;
- ca_mutex_lock(g_context.blockDataListMutex);
+ oc_mutex_lock(g_context.blockDataListMutex);
bool res = u_arraylist_add(g_context.dataList, (void *) data);
if (!res)
CADestroyBlockID(data->blockDataId);
CADestroyDataSet(data->sentData);
OICFree(data);
- ca_mutex_unlock(g_context.blockDataListMutex);
+ oc_mutex_unlock(g_context.blockDataListMutex);
return NULL;
}
- ca_mutex_unlock(g_context.blockDataListMutex);
+ oc_mutex_unlock(g_context.blockDataListMutex);
OIC_LOG(DEBUG, TAG, "OUT-CreateBlockData");
return data;
OIC_LOG(DEBUG, TAG, "CARemoveBlockData");
VERIFY_NON_NULL(blockID, TAG, "blockID");
- ca_mutex_lock(g_context.blockDataListMutex);
+ oc_mutex_lock(g_context.blockDataListMutex);
size_t len = u_arraylist_length(g_context.dataList);
for (size_t i = 0; i < len; i++)
if (!removedData)
{
OIC_LOG(ERROR, TAG, "data is NULL");
- ca_mutex_unlock(g_context.blockDataListMutex);
+ oc_mutex_unlock(g_context.blockDataListMutex);
return CA_STATUS_FAILED;
}
CADestroyBlockID(currData->blockDataId);
OICFree(currData->payload);
OICFree(currData);
- ca_mutex_unlock(g_context.blockDataListMutex);
+ oc_mutex_unlock(g_context.blockDataListMutex);
return CA_STATUS_OK;
}
}
- ca_mutex_unlock(g_context.blockDataListMutex);
+ oc_mutex_unlock(g_context.blockDataListMutex);
return CA_STATUS_OK;
}
{
OIC_LOG(DEBUG, TAG, "CARemoveAllBlockDataFromList");
- ca_mutex_lock(g_context.blockDataListMutex);
+ oc_mutex_lock(g_context.blockDataListMutex);
size_t len = u_arraylist_length(g_context.dataList);
for (size_t i = len; i > 0; i--)
OICFree(removedData);
}
}
- ca_mutex_unlock(g_context.blockDataListMutex);
+ oc_mutex_unlock(g_context.blockDataListMutex);
return CA_STATUS_OK;
}
// #1 parse the data
// #2 get endpoint
- ca_mutex_lock(g_receiveThread.threadMutex);
+ oc_mutex_lock(g_receiveThread.threadMutex);
u_queue_message_t *item = u_queue_get_element(g_receiveThread.dataQueue);
- ca_mutex_unlock(g_receiveThread.threadMutex);
+ oc_mutex_unlock(g_receiveThread.threadMutex);
if (NULL == item || NULL == item->msg)
{
while (!thread->isStop)
{
// mutex lock
- ca_mutex_lock(thread->threadMutex);
+ oc_mutex_lock(thread->threadMutex);
// if queue is empty, thread will wait
if (!thread->isStop && u_queue_get_size(thread->dataQueue) <= 0)
OIC_LOG(DEBUG, TAG, "wait..");
// wait
- ca_cond_wait(thread->threadCond, thread->threadMutex);
+ oc_cond_wait(thread->threadCond, thread->threadMutex);
OIC_LOG(DEBUG, TAG, "wake up..");
}
if (thread->isStop)
{
// mutex unlock
- ca_mutex_unlock(thread->threadMutex);
+ oc_mutex_unlock(thread->threadMutex);
continue;
}
// get data
u_queue_message_t *message = u_queue_get_element(thread->dataQueue);
// mutex unlock
- ca_mutex_unlock(thread->threadMutex);
+ oc_mutex_unlock(thread->threadMutex);
if (NULL == message)
{
continue;
OICFree(message);
}
- ca_mutex_lock(thread->threadMutex);
- ca_cond_signal(thread->threadCond);
- ca_mutex_unlock(thread->threadMutex);
+ oc_mutex_lock(thread->threadMutex);
+ oc_cond_signal(thread->threadCond);
+ oc_mutex_unlock(thread->threadMutex);
OIC_LOG(DEBUG, TAG, "message handler main thread end..");
}
// set send thread data
thread->threadPool = handle;
thread->dataQueue = u_queue_create();
- thread->threadMutex = ca_mutex_new();
- thread->threadCond = ca_cond_new();
+ thread->threadMutex = oc_mutex_new();
+ thread->threadCond = oc_cond_new();
thread->isStop = true;
thread->threadTask = task;
thread->destroy = destroy;
}
if (thread->threadMutex)
{
- ca_mutex_free(thread->threadMutex);
+ oc_mutex_free(thread->threadMutex);
thread->threadMutex = NULL;
}
if (thread->threadCond)
{
- ca_cond_free(thread->threadCond);
+ oc_cond_free(thread->threadCond);
thread->threadCond = NULL;
}
return CA_MEMORY_ALLOC_FAILED;
}
// mutex lock
- ca_mutex_lock(thread->threadMutex);
+ oc_mutex_lock(thread->threadMutex);
thread->isStop = false;
// mutex unlock
- ca_mutex_unlock(thread->threadMutex);
+ oc_mutex_unlock(thread->threadMutex);
CAResult_t res = ca_thread_pool_add_task(thread->threadPool, CAQueueingThreadBaseRoutine,
thread);
message->size = size;
// mutex lock
- ca_mutex_lock(thread->threadMutex);
+ oc_mutex_lock(thread->threadMutex);
// add thread data into list
u_queue_add_element(thread->dataQueue, message);
// notity the thread
- ca_cond_signal(thread->threadCond);
+ oc_cond_signal(thread->threadCond);
// mutex unlock
- ca_mutex_unlock(thread->threadMutex);
+ oc_mutex_unlock(thread->threadMutex);
return CA_STATUS_OK;
}
OIC_LOG(DEBUG, TAG, "thread destroy..");
- ca_mutex_free(thread->threadMutex);
+ oc_mutex_free(thread->threadMutex);
thread->threadMutex = NULL;
- ca_cond_free(thread->threadCond);
+ oc_cond_free(thread->threadCond);
// remove all remained list data.
while (u_queue_get_size(thread->dataQueue) > 0)
if (!thread->isStop)
{
// mutex lock
- ca_mutex_lock(thread->threadMutex);
+ oc_mutex_lock(thread->threadMutex);
// set stop flag
thread->isStop = true;
// notify the thread
- ca_cond_signal(thread->threadCond);
+ oc_cond_signal(thread->threadCond);
- ca_cond_wait(thread->threadCond, thread->threadMutex);
+ oc_cond_wait(thread->threadCond, thread->threadMutex);
// mutex unlock
- ca_mutex_unlock(thread->threadMutex);
+ oc_mutex_unlock(thread->threadMutex);
}
return CA_STATUS_OK;
}
// mutex lock
- ca_mutex_lock(context->threadMutex);
+ oc_mutex_lock(context->threadMutex);
uint32_t i = 0;
uint32_t len = u_arraylist_length(context->dataList);
{
OIC_LOG(ERROR, TAG, "Removed data is NULL");
// mutex unlock
- ca_mutex_unlock(context->threadMutex);
+ oc_mutex_unlock(context->threadMutex);
return;
}
OIC_LOG_V(DEBUG, TAG, "max trying count, remove RTCON data,"
}
// mutex unlock
- ca_mutex_unlock(context->threadMutex);
+ oc_mutex_unlock(context->threadMutex);
}
void CARetransmissionBaseRoutine(void *threadValue)
while (!context->isStop)
{
// mutex lock
- ca_mutex_lock(context->threadMutex);
+ oc_mutex_lock(context->threadMutex);
if (!context->isStop && u_arraylist_length(context->dataList) <= 0)
{
OIC_LOG(DEBUG, TAG, "wait..there is no retransmission data.");
// wait
- ca_cond_wait(context->threadCond, context->threadMutex);
+ oc_cond_wait(context->threadCond, context->threadMutex);
OIC_LOG(DEBUG, TAG, "wake up..");
}
// wait
uint64_t absTime = RETRANSMISSION_CHECK_PERIOD_SEC * (uint64_t) USECS_PER_SEC;
- ca_cond_wait_for(context->threadCond, context->threadMutex, absTime );
+ oc_cond_wait_for(context->threadCond, context->threadMutex, absTime );
}
else
{
}
// mutex unlock
- ca_mutex_unlock(context->threadMutex);
+ oc_mutex_unlock(context->threadMutex);
// check stop flag
if (context->isStop)
CACheckRetransmissionList(context);
}
- ca_mutex_lock(context->threadMutex);
- ca_cond_signal(context->threadCond);
- ca_mutex_unlock(context->threadMutex);
+ oc_mutex_lock(context->threadMutex);
+ oc_cond_signal(context->threadCond);
+ oc_mutex_unlock(context->threadMutex);
#endif
OIC_LOG(DEBUG, TAG, "retransmission main thread end");
// set send thread data
context->threadPool = handle;
- context->threadMutex = ca_mutex_new();
- context->threadCond = ca_cond_new();
+ context->threadMutex = oc_mutex_new();
+ context->threadCond = oc_cond_new();
context->dataSendMethod = retransmissionSendMethod;
context->timeoutCallback = timeoutCallback;
context->config = cfg;
retData->dataType = dataType;
#ifndef SINGLE_THREAD
// mutex lock
- ca_mutex_lock(context->threadMutex);
+ oc_mutex_lock(context->threadMutex);
uint32_t i = 0;
uint32_t len = u_arraylist_length(context->dataList);
OIC_LOG(ERROR, TAG, "Duplicate message ID");
// mutex unlock
- ca_mutex_unlock(context->threadMutex);
+ oc_mutex_unlock(context->threadMutex);
OICFree(retData);
OICFree(pduData);
u_arraylist_add(context->dataList, (void *) retData);
// notify the thread
- ca_cond_signal(context->threadCond);
+ oc_cond_signal(context->threadCond);
// mutex unlock
- ca_mutex_unlock(context->threadMutex);
+ oc_mutex_unlock(context->threadMutex);
#else
u_arraylist_add(context->dataList, (void *) retData);
}
// mutex lock
- ca_mutex_lock(context->threadMutex);
+ oc_mutex_lock(context->threadMutex);
uint32_t len = u_arraylist_length(context->dataList);
// find index
OIC_LOG(ERROR, TAG, "retData->pdu is null");
OICFree(retData);
// mutex unlock
- ca_mutex_unlock(context->threadMutex);
+ oc_mutex_unlock(context->threadMutex);
return CA_STATUS_FAILED;
}
OIC_LOG(ERROR, TAG, "memory error");
// mutex unlock
- ca_mutex_unlock(context->threadMutex);
+ oc_mutex_unlock(context->threadMutex);
return CA_MEMORY_ALLOC_FAILED;
}
OIC_LOG(ERROR, TAG, "Removed data is NULL");
// mutex unlock
- ca_mutex_unlock(context->threadMutex);
+ oc_mutex_unlock(context->threadMutex);
return CA_STATUS_FAILED;
}
}
// mutex unlock
- ca_mutex_unlock(context->threadMutex);
+ oc_mutex_unlock(context->threadMutex);
OIC_LOG(DEBUG, TAG, "OUT");
return CA_STATUS_OK;
OIC_LOG(DEBUG, TAG, "retransmission stop request!!");
// mutex lock
- ca_mutex_lock(context->threadMutex);
+ oc_mutex_lock(context->threadMutex);
// set stop flag
context->isStop = true;
// notify the thread
- ca_cond_signal(context->threadCond);
+ oc_cond_signal(context->threadCond);
- ca_cond_wait(context->threadCond, context->threadMutex);
+ oc_cond_wait(context->threadCond, context->threadMutex);
// mutex unlock
- ca_mutex_unlock(context->threadMutex);
+ oc_mutex_unlock(context->threadMutex);
return CA_STATUS_OK;
}
OIC_LOG(DEBUG, TAG, "retransmission context destroy..");
- ca_mutex_free(context->threadMutex);
+ oc_mutex_free(context->threadMutex);
context->threadMutex = NULL;
- ca_cond_free(context->threadCond);
+ oc_cond_free(context->threadCond);
u_arraylist_free(&context->dataList);
return CA_STATUS_OK;
/**
* Mutex for synchronizing access to cached interface and IP address information.
*/
-static ca_mutex g_networkMonitorContextMutex = NULL;
+static oc_mutex g_networkMonitorContextMutex = NULL;
/**
* Used to storing network interface.
{
if (!g_networkMonitorContextMutex)
{
- g_networkMonitorContextMutex = ca_mutex_new();
+ g_networkMonitorContextMutex = oc_mutex_new();
if (!g_networkMonitorContextMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new has failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new has failed");
return CA_STATUS_FAILED;
}
}
if (g_networkMonitorContextMutex)
{
- ca_mutex_free(g_networkMonitorContextMutex);
+ oc_mutex_free(g_networkMonitorContextMutex);
g_networkMonitorContextMutex = NULL;
}
}
return false;
}
- ca_mutex_lock(g_networkMonitorContextMutex);
+ oc_mutex_lock(g_networkMonitorContextMutex);
uint32_t list_length = u_arraylist_length(g_netInterfaceList);
for (uint32_t list_index = 0; list_index < list_length; list_index++)
CAInterface_t *currItem = (CAInterface_t *) u_arraylist_get(g_netInterfaceList, list_index);
if (currItem->index == ifiindex)
{
- ca_mutex_unlock(g_networkMonitorContextMutex);
+ oc_mutex_unlock(g_networkMonitorContextMutex);
return true;
}
}
- ca_mutex_unlock(g_networkMonitorContextMutex);
+ oc_mutex_unlock(g_networkMonitorContextMutex);
return false;
}
VERIFY_NON_NULL(g_netInterfaceList, TAG, "g_netInterfaceList is NULL");
VERIFY_NON_NULL(ifitem, TAG, "ifitem is NULL");
- ca_mutex_lock(g_networkMonitorContextMutex);
+ oc_mutex_lock(g_networkMonitorContextMutex);
bool result = u_arraylist_add(g_netInterfaceList, (void *) ifitem);
if (!result)
{
OIC_LOG(ERROR, TAG, "u_arraylist_add failed.");
- ca_mutex_unlock(g_networkMonitorContextMutex);
+ oc_mutex_unlock(g_networkMonitorContextMutex);
return CA_STATUS_FAILED;
}
- ca_mutex_unlock(g_networkMonitorContextMutex);
+ oc_mutex_unlock(g_networkMonitorContextMutex);
return CA_STATUS_OK;
}
{
VERIFY_NON_NULL_VOID(g_netInterfaceList, TAG, "g_netInterfaceList is NULL");
- ca_mutex_lock(g_networkMonitorContextMutex);
+ oc_mutex_lock(g_networkMonitorContextMutex);
uint32_t list_length = u_arraylist_length(g_netInterfaceList);
for (uint32_t list_index = 0; list_index < list_length; list_index++)
if (u_arraylist_remove(g_netInterfaceList, list_index))
{
OICFree(removedifitem);
- ca_mutex_unlock(g_networkMonitorContextMutex);
+ oc_mutex_unlock(g_networkMonitorContextMutex);
return;
}
continue;
}
}
- ca_mutex_unlock(g_networkMonitorContextMutex);
+ oc_mutex_unlock(g_networkMonitorContextMutex);
return;
}
CAJidBoundCallback jidBoundCallback;
} CARAXmppData_t;
-static ca_mutex g_raadapterMutex = NULL;
+static oc_mutex g_raadapterMutex = NULL;
static CARAXmppData_t g_xmppData = {.xmpp = NULL, .port = 5222, .hostName = {0},
.password = {0}, .jid = {0}, .connectionStatus = CA_INTERFACE_DOWN,
return CA_STATUS_FAILED;
}
- g_raadapterMutex = ca_mutex_new ();
+ g_raadapterMutex = oc_mutex_new ();
if (!g_raadapterMutex)
{
OIC_LOG (ERROR, RA_ADAPTER_TAG, PCF("Memory allocation for mutex failed."));
return CA_MEMORY_ALLOC_FAILED;
}
- ca_mutex_lock (g_raadapterMutex);
+ oc_mutex_lock (g_raadapterMutex);
xmpphelper_connect(g_xmppData.xmpp, g_xmppData.hostName, g_xmppData.port,
g_xmppData.jid, g_xmppData.password);
xmpphelper_run(g_xmppData.xmpp);
- ca_mutex_unlock (g_raadapterMutex);
+ oc_mutex_unlock (g_raadapterMutex);
OIC_LOG(DEBUG, RA_ADAPTER_TAG, "RA adapter started succesfully");
return CA_STATUS_OK;
xmpp_ibb_unregister(xmpphelper_get_conn(g_xmppData.xmpp));
if (!g_raadapterMutex)
{
- ca_mutex_free (g_raadapterMutex);
+ oc_mutex_free (g_raadapterMutex);
g_raadapterMutex = NULL;
}
OIC_LOG(DEBUG, RA_ADAPTER_TAG, PCF("Stopped RA adapter successfully"));
int obsopt = CARAGetReqObsOption(pdu, remoteEndpoint);
coap_delete_pdu(pdu);
- ca_mutex_lock (g_raadapterMutex);
+ oc_mutex_lock (g_raadapterMutex);
if (CA_INTERFACE_UP != g_xmppData.connectionStatus)
{
OIC_LOG(ERROR, RA_ADAPTER_TAG, "Unable to send XMPP message, RA not connected");
- ca_mutex_unlock (g_raadapterMutex);
+ oc_mutex_unlock (g_raadapterMutex);
return -1;
}
if (sess == NULL)
{
OIC_LOG(ERROR, RA_ADAPTER_TAG, "IBB session establish failed!");
- ca_mutex_unlock (g_raadapterMutex);
+ oc_mutex_unlock (g_raadapterMutex);
return -1;
}
}
}
xmppdata_t xdata = {.data = (char *) data, .size = dataLength};
int rc = xmpp_ibb_send_data(sess, &xdata);
- ca_mutex_unlock (g_raadapterMutex);
+ oc_mutex_unlock (g_raadapterMutex);
if (rc < 0)
{
OIC_LOG(ERROR, RA_ADAPTER_TAG, "IBB send data failed!");
char jabberID[CA_RAJABBERID_SIZE];
} CARAXmppData_t;
-static ca_mutex g_raadapterMutex = NULL;
+static oc_mutex g_raadapterMutex = NULL;
static CARAXmppData_t g_xmppData = {};
{
printf("\n\n\t\t===>your jid: %s\n\n", bound_jid);
- ca_mutex_lock (g_raadapterMutex);
+ oc_mutex_lock (g_raadapterMutex);
OICStrcpy (g_xmppData.jabberID, CA_RAJABBERID_SIZE, bound_jid);
g_xmppData.connection_status = CA_INTERFACE_UP;
OIC_LOG_V(ERROR, RA_ADAPTER_TAG, "XMPP connected callback status: %d", result);
}
- ca_mutex_unlock (g_raadapterMutex);
+ oc_mutex_unlock (g_raadapterMutex);
// Notify network change to CA
CARANotifyNetworkChange(bound_jid, connection_status);
{
OIC_LOG(DEBUG, RA_ADAPTER_TAG, "CARAXmppDisonnectedCB IN");
char jabberID[CA_RAJABBERID_SIZE];
- ca_mutex_lock (g_raadapterMutex);
+ oc_mutex_lock (g_raadapterMutex);
g_xmppData.connection_status = CA_INTERFACE_DOWN;
xmpp_message_context_destroy(g_xmppData.message_context);
OICStrcpy (jabberID, CA_RAJABBERID_SIZE, g_xmppData.jabberID);
- ca_mutex_unlock (g_raadapterMutex);
+ oc_mutex_unlock (g_raadapterMutex);
// Notify network change to CA
CARANotifyNetworkChange(jabberID, CA_INTERFACE_DOWN);
OIC_LOG(DEBUG, RA_ADAPTER_TAG, PCF("Starting RA adapter"));
- g_raadapterMutex = ca_mutex_new ();
+ g_raadapterMutex = oc_mutex_new ();
if (!g_raadapterMutex)
{
OIC_LOG (ERROR, RA_ADAPTER_TAG, PCF("Memory allocation for mutex failed."));
return CA_MEMORY_ALLOC_FAILED;
}
- ca_mutex_lock (g_raadapterMutex);
+ oc_mutex_lock (g_raadapterMutex);
xmpp_context_init(&g_xmppData.context);
g_xmppData.handle = xmpp_startup(&g_xmppData.context);
xmpp_identity_destroy(&g_xmppData.g_identity);
xmpp_host_destroy(&g_xmppData.g_host);
- ca_mutex_unlock (g_raadapterMutex);
+ oc_mutex_unlock (g_raadapterMutex);
if (XMPP_ERR_OK != ret)
{
xmpp_shutdown_xmpp(g_xmppData.handle);
xmpp_context_destroy(&g_xmppData.context);
- ca_mutex_free (g_raadapterMutex);
+ oc_mutex_free (g_raadapterMutex);
g_raadapterMutex = NULL;
OIC_LOG(DEBUG, RA_ADAPTER_TAG, PCF("Stopped RA adapter successfully"));
}
OIC_LOG_V(ERROR, RA_ADAPTER_TAG, "Sending unicast data to %s", remoteEndpoint->addr);
- ca_mutex_lock (g_raadapterMutex);
+ oc_mutex_lock (g_raadapterMutex);
if (CA_INTERFACE_UP != g_xmppData.connection_status)
{
OIC_LOG(ERROR, RA_ADAPTER_TAG, "Unable to send XMPP message, RA not connected");
- ca_mutex_unlock (g_raadapterMutex);
+ oc_mutex_unlock (g_raadapterMutex);
return -1;
}
if (XMPP_ERR_OK != res)
{
OIC_LOG_V(ERROR, RA_ADAPTER_TAG, "Unable to send XMPP message, status: %d", res);
- ca_mutex_unlock (g_raadapterMutex);
+ oc_mutex_unlock (g_raadapterMutex);
return -1;
}
- ca_mutex_unlock (g_raadapterMutex);
+ oc_mutex_unlock (g_raadapterMutex);
OIC_LOG_V(INFO, RA_ADAPTER_TAG, "Successfully dispatched bytes[%d] to addr[%s]",
dataLength, remoteEndpoint->addr);
VERIFY_NON_NULL(info, RA_ADAPTER_TAG, "info is NULL");
VERIFY_NON_NULL(size, RA_ADAPTER_TAG, "size is NULL");
- ca_mutex_lock (g_raadapterMutex);
+ oc_mutex_lock (g_raadapterMutex);
if (CA_INTERFACE_UP != g_xmppData.connection_status)
{
OIC_LOG(ERROR, RA_ADAPTER_TAG, "Failed to get interface info, RA not Connected");
- ca_mutex_unlock (g_raadapterMutex);
+ oc_mutex_unlock (g_raadapterMutex);
return CA_ADAPTER_NOT_ENABLED;
}
- ca_mutex_unlock (g_raadapterMutex);
+ oc_mutex_unlock (g_raadapterMutex);
CAEndpoint_t *localEndpoint = CACreateEndpointObject(CA_DEFAULT_FLAGS,
CA_ADAPTER_REMOTE_ACCESS,
/**
* Mutex to synchronize device object list.
*/
-static ca_mutex g_mutexObjectList = NULL;
+static oc_mutex g_mutexObjectList = NULL;
/**
* Conditional mutex to synchronize.
*/
-static ca_cond g_condObjectList = NULL;
+static oc_cond g_condObjectList = NULL;
/**
* Maintains the callback to be notified when data received from remote device.
{
if (g_mutexObjectList)
{
- ca_mutex_free(g_mutexObjectList);
+ oc_mutex_free(g_mutexObjectList);
g_mutexObjectList = NULL;
}
}
{
if (!g_mutexObjectList)
{
- g_mutexObjectList = ca_mutex_new();
+ g_mutexObjectList = oc_mutex_new();
if (!g_mutexObjectList)
{
OIC_LOG(ERROR, TAG, "Failed to created mutex!");
{
if (g_condObjectList)
{
- ca_cond_free(g_condObjectList);
+ oc_cond_free(g_condObjectList);
g_condObjectList = NULL;
}
}
{
if (!g_condObjectList)
{
- g_condObjectList = ca_cond_new();
+ g_condObjectList = oc_cond_new();
if (!g_condObjectList)
{
OIC_LOG(ERROR, TAG, "Failed to created cond!");
CAFindReadyMessage();
}
- ca_mutex_lock(g_mutexObjectList);
- ca_cond_signal(g_condObjectList);
- ca_mutex_unlock(g_mutexObjectList);
+ oc_mutex_lock(g_mutexObjectList);
+ oc_cond_signal(g_condObjectList);
+ oc_mutex_unlock(g_mutexObjectList);
OIC_LOG(DEBUG, TAG, "OUT - CAReceiveHandler");
}
CAConvertAddrToName((struct sockaddr_storage *)&clientaddr, clientlen,
svritem->sep.endpoint.addr, &svritem->sep.endpoint.port);
- ca_mutex_lock(g_mutexObjectList);
+ oc_mutex_lock(g_mutexObjectList);
bool result = u_arraylist_add(caglobals.tcp.svrlist, svritem);
if (!result)
{
OIC_LOG(ERROR, TAG, "u_arraylist_add failed.");
close(sockfd);
OICFree(svritem);
- ca_mutex_unlock(g_mutexObjectList);
+ oc_mutex_unlock(g_mutexObjectList);
return;
}
- ca_mutex_unlock(g_mutexObjectList);
+ oc_mutex_unlock(g_mutexObjectList);
CHECKFD(sockfd);
}
return res;
}
- ca_mutex_lock(g_mutexObjectList);
+ oc_mutex_lock(g_mutexObjectList);
if (!caglobals.tcp.svrlist)
{
caglobals.tcp.svrlist = u_arraylist_create();
}
- ca_mutex_unlock(g_mutexObjectList);
+ oc_mutex_unlock(g_mutexObjectList);
if (caglobals.server)
{
void CATCPStopServer()
{
// mutex lock
- ca_mutex_lock(g_mutexObjectList);
+ oc_mutex_lock(g_mutexObjectList);
// set terminate flag
caglobals.tcp.terminate = true;
if (caglobals.tcp.started)
{
- ca_cond_wait(g_condObjectList, g_mutexObjectList);
+ oc_cond_wait(g_condObjectList, g_mutexObjectList);
}
caglobals.tcp.started = false;
// mutex unlock
- ca_mutex_unlock(g_mutexObjectList);
+ oc_mutex_unlock(g_mutexObjectList);
if (-1 != caglobals.tcp.ipv4.fd)
{
// #3. add TCP connection info to list
svritem->fd = fd;
- ca_mutex_lock(g_mutexObjectList);
+ oc_mutex_lock(g_mutexObjectList);
if (caglobals.tcp.svrlist)
{
bool res = u_arraylist_add(caglobals.tcp.svrlist, svritem);
OIC_LOG(ERROR, TAG, "u_arraylist_add failed.");
close(svritem->fd);
OICFree(svritem);
- ca_mutex_unlock(g_mutexObjectList);
+ oc_mutex_unlock(g_mutexObjectList);
return NULL;
}
}
- ca_mutex_unlock(g_mutexObjectList);
+ oc_mutex_unlock(g_mutexObjectList);
CHECKFD(fd);
{
VERIFY_NON_NULL(svritem, TAG, "svritem is NULL");
- ca_mutex_lock(g_mutexObjectList);
+ oc_mutex_lock(g_mutexObjectList);
// close the socket and remove TCP connection info in list
if (svritem->fd >= 0)
}
OICFree(svritem);
- ca_mutex_unlock(g_mutexObjectList);
+ oc_mutex_unlock(g_mutexObjectList);
return CA_STATUS_OK;
}
void CATCPDisconnectAll()
{
- ca_mutex_lock(g_mutexObjectList);
+ oc_mutex_lock(g_mutexObjectList);
uint32_t length = u_arraylist_length(caglobals.tcp.svrlist);
CATCPSessionInfo_t *svritem = NULL;
}
}
u_arraylist_destroy(caglobals.tcp.svrlist);
- ca_mutex_unlock(g_mutexObjectList);
+ oc_mutex_unlock(g_mutexObjectList);
}
CATCPSessionInfo_t *CAGetTCPSessionInfoFromEndpoint(const CAEndpoint_t *endpoint, size_t *index)
CATCPSessionInfo_t *CAGetSessionInfoFromFD(int fd, size_t *index)
{
- ca_mutex_lock(g_mutexObjectList);
+ oc_mutex_lock(g_mutexObjectList);
// check from the last item.
CATCPSessionInfo_t *svritem = NULL;
if (svritem && svritem->fd == fd)
{
*index = i;
- ca_mutex_unlock(g_mutexObjectList);
+ oc_mutex_unlock(g_mutexObjectList);
return svritem;
}
}
- ca_mutex_unlock(g_mutexObjectList);
+ oc_mutex_unlock(g_mutexObjectList);
return NULL;
}
TEST(MutexTests, TC_01_CREATE)
{
- ca_mutex mymutex = ca_mutex_new();
+ oc_mutex mymutex = oc_mutex_new();
EXPECT_TRUE(mymutex != NULL);
if (mymutex != NULL)
{
- ca_mutex_free(mymutex);
+ oc_mutex_free(mymutex);
}
}
typedef struct _tagFunc1
{
- ca_mutex mutex;
+ oc_mutex mutex;
volatile bool thread_up;
volatile bool finished;
} _func1_struct;
// setting the flag must be done before lock attempt, as the test
// thread starts off with the mutex locked
pData->thread_up = true;
- ca_mutex_lock(pData->mutex);
+ oc_mutex_lock(pData->mutex);
DBG_printf("Thread: got lock\n");
usleep(MINIMAL_LOOP_SLEEP * USECS_PER_MSEC);
pData->finished = true; // assignment guarded by lock
- ca_mutex_unlock(pData->mutex);
+ oc_mutex_unlock(pData->mutex);
}
TEST(MutexTests, TC_03_THREAD_LOCKING)
_func1_struct pData = {0, false, false};
- pData.mutex = ca_mutex_new();
+ pData.mutex = oc_mutex_new();
EXPECT_TRUE(pData.mutex != NULL);
if (pData.mutex != NULL)
{
DBG_printf("test: Holding mutex in test\n");
- ca_mutex_lock(pData.mutex);
+ oc_mutex_lock(pData.mutex);
DBG_printf("test: starting thread\n");
//start thread
DBG_printf("test: unlocking\n");
- ca_mutex_unlock(pData.mutex);
+ oc_mutex_unlock(pData.mutex);
DBG_printf("test: waiting for thread to release\n");
while (!pData.finished)
usleep(MINIMAL_LOOP_SLEEP * USECS_PER_MSEC);
}
- ca_mutex_lock(pData.mutex);
+ oc_mutex_lock(pData.mutex);
// Cleanup Everything
- ca_mutex_unlock(pData.mutex);
- ca_mutex_free(pData.mutex);
+ oc_mutex_unlock(pData.mutex);
+ oc_mutex_free(pData.mutex);
}
ca_thread_pool_free(mythreadpool);
TEST(ConditionTests, TC_01_CREATE)
{
- ca_cond mycond = ca_cond_new();
+ oc_cond mycond = oc_cond_new();
EXPECT_TRUE(mycond != NULL);
if (mycond != NULL)
{
- ca_cond_free(mycond);
+ oc_cond_free(mycond);
}
}
// Normally we would use one pair of mutex/cond-var communicating to the
// worker threads and one pair back to the main thread. However since
-// testing the ca_cond itself is the point, only one pair is used here.
+// testing the oc_cond itself is the point, only one pair is used here.
typedef struct _tagFunc2
{
int id;
- ca_mutex mutex;
- ca_cond condition;
+ oc_mutex mutex;
+ oc_cond condition;
volatile bool thread_up;
volatile bool finished;
} _func2_struct;
DBG_printf("Thread_%d: waiting on condition\n", pData->id);
- ca_mutex_lock(pData->mutex);
+ oc_mutex_lock(pData->mutex);
pData->thread_up = true;
- ca_cond_wait(pData->condition, pData->mutex);
+ oc_cond_wait(pData->condition, pData->mutex);
pData->finished = true; // assignment guarded by lock
- ca_mutex_unlock(pData->mutex);
+ oc_mutex_unlock(pData->mutex);
DBG_printf("Thread_%d: completed.\n", pData->id);
}
EXPECT_EQ(CA_STATUS_OK, ca_thread_pool_init(3, &mythreadpool));
- ca_mutex sharedMutex = ca_mutex_new();
- ca_cond sharedCond = ca_cond_new();
+ oc_mutex sharedMutex = oc_mutex_new();
+ oc_cond sharedCond = oc_cond_new();
_func2_struct pData1 =
{ 1, sharedMutex, sharedCond, false, false };
// has already started waiting on the condition and the other is at
// least close.
- ca_mutex_lock(sharedMutex);
+ oc_mutex_lock(sharedMutex);
// once the lock is acquired it means both threads were waiting.
DBG_printf("test : signaling first thread\n");
- ca_cond_signal(sharedCond);
- ca_mutex_unlock(sharedMutex);
+ oc_cond_signal(sharedCond);
+ oc_mutex_unlock(sharedMutex);
// At this point either of the child threads might lock the mutex in
// their cond_wait call, or this test thread might lock it again if
usleep(MINIMAL_EXTRA_SLEEP);
// only one should be finished
- ca_mutex_lock(sharedMutex);
+ oc_mutex_lock(sharedMutex);
EXPECT_NE(pData1.finished, pData2.finished);
- ca_mutex_unlock(sharedMutex);
+ oc_mutex_unlock(sharedMutex);
DBG_printf("test : signaling another thread\n");
- ca_mutex_lock(sharedMutex);
- ca_cond_signal(sharedCond);
- ca_mutex_unlock(sharedMutex);
+ oc_mutex_lock(sharedMutex);
+ oc_cond_signal(sharedCond);
+ oc_mutex_unlock(sharedMutex);
waitCount = 0;
while ((!pData1.finished || !pData2.finished)
// Cleanup Everything
- ca_mutex_free(pData1.mutex);
+ oc_mutex_free(pData1.mutex);
}
- ca_cond_free(pData1.condition);
+ oc_cond_free(pData1.condition);
ca_thread_pool_free(mythreadpool);
}
EXPECT_EQ(CA_STATUS_OK, ca_thread_pool_init(3, &mythreadpool));
- ca_mutex sharedMutex = ca_mutex_new();
- ca_cond sharedCond = ca_cond_new();
+ oc_mutex sharedMutex = oc_mutex_new();
+ oc_cond sharedCond = oc_cond_new();
_func2_struct pData1 =
{ 1, sharedMutex, sharedCond, false, false };
DBG_printf("test : signaling all threads\n");
- ca_mutex_lock(sharedMutex);
+ oc_mutex_lock(sharedMutex);
// once the lock is acquired it means both threads were waiting.
- ca_cond_broadcast(sharedCond);
- ca_mutex_unlock(sharedMutex);
+ oc_cond_broadcast(sharedCond);
+ oc_mutex_unlock(sharedMutex);
int waitCount = 0;
while ((!pData1.finished || !pData2.finished)
// Cleanup Everything
- ca_mutex_free(sharedMutex);
+ oc_mutex_free(sharedMutex);
}
- ca_cond_free(sharedCond);
+ oc_cond_free(sharedCond);
ca_thread_pool_free(mythreadpool);
}
DBG_printf("Thread_%d: waiting for timeout \n", pData->id);
- ca_mutex_lock(pData->mutex);
+ oc_mutex_lock(pData->mutex);
uint64_t abs = USECS_PER_SEC / 2; // 1/2 seconds
// test UTIMEDOUT
- CAWaitResult_t ret = ca_cond_wait_for(pData->condition,
+ OCWaitResult_t ret = oc_cond_wait_for(pData->condition,
pData->mutex, abs);
- EXPECT_EQ(CA_WAIT_TIMEDOUT, ret);
+ EXPECT_EQ(OC_WAIT_TIMEDOUT, ret);
pData->thread_up = true;
abs = 5 * USECS_PER_SEC; // 5 seconds
// test signal
- ret = ca_cond_wait_for(pData->condition, pData->mutex, abs);
- EXPECT_EQ(CA_WAIT_SUCCESS, ret);
+ ret = oc_cond_wait_for(pData->condition, pData->mutex, abs);
+ EXPECT_EQ(OC_WAIT_SUCCESS, ret);
pData->finished = true; // assignment guarded by lock
- ca_mutex_unlock(pData->mutex);
+ oc_mutex_unlock(pData->mutex);
DBG_printf("Thread_%d: stopping\n", pData->id);
}
EXPECT_EQ(CA_STATUS_OK, ca_thread_pool_init(3, &mythreadpool));
- ca_mutex sharedMutex = ca_mutex_new();
- ca_cond sharedCond = ca_cond_new();
+ oc_mutex sharedMutex = oc_mutex_new();
+ oc_cond sharedCond = oc_cond_new();
_func2_struct pData1 =
{ 1, sharedMutex, sharedCond, false, false };
DBG_printf("test : signaling first thread\n");
- ca_mutex_lock(sharedMutex);
- ca_cond_signal(sharedCond);
- ca_mutex_unlock(sharedMutex);
+ oc_mutex_lock(sharedMutex);
+ oc_cond_signal(sharedCond);
+ oc_mutex_unlock(sharedMutex);
int waitCount = 0;
while (!pData1.finished
// Cleanup Everything
- ca_mutex_free(sharedMutex);
+ oc_mutex_free(sharedMutex);
}
- ca_cond_free(sharedCond);
+ oc_cond_free(sharedCond);
ca_thread_pool_free(mythreadpool);
}
TEST(ConditionTests, DISABLED_TC_06_INVALIDWAIT)
{
- ca_mutex sharedMutex = ca_mutex_new();
- ca_cond sharedCond = ca_cond_new();
+ oc_mutex sharedMutex = oc_mutex_new();
+ oc_cond sharedCond = oc_cond_new();
- ca_mutex_lock(sharedMutex);
+ oc_mutex_lock(sharedMutex);
- int ret = ca_cond_wait_for(NULL, sharedMutex, 5000);
- EXPECT_EQ(CA_WAIT_INVAL,ret);
+ int ret = oc_cond_wait_for(NULL, sharedMutex, 5000);
+ EXPECT_EQ(OC_WAIT_INVAL,ret);
- ret = ca_cond_wait_for(sharedCond, NULL, 5000);
- EXPECT_EQ(CA_WAIT_INVAL,ret);
+ ret = oc_cond_wait_for(sharedCond, NULL, 5000);
+ EXPECT_EQ(OC_WAIT_INVAL,ret);
- ret = ca_cond_wait_for(NULL, NULL, 5000);
- EXPECT_EQ(CA_WAIT_INVAL,ret);
+ ret = oc_cond_wait_for(NULL, NULL, 5000);
+ EXPECT_EQ(OC_WAIT_INVAL,ret);
- ca_mutex_unlock(sharedMutex);
+ oc_mutex_unlock(sharedMutex);
// Cleanup Everything
- ca_mutex_free(sharedMutex);
+ oc_mutex_free(sharedMutex);
- ca_cond_free(sharedCond);
+ oc_cond_free(sharedCond);
}
TEST(ConditionTests, TC_07_WAITDURATION)
{
const double TARGET_WAIT = 1.125;
- ca_mutex sharedMutex = ca_mutex_new();
- ca_cond sharedCond = ca_cond_new();
+ oc_mutex sharedMutex = oc_mutex_new();
+ oc_cond sharedCond = oc_cond_new();
- ca_mutex_lock(sharedMutex);
+ oc_mutex_lock(sharedMutex);
uint64_t beg = getAbsTime();
- CAWaitResult_t ret = ca_cond_wait_for(sharedCond, sharedMutex,
+ OCWaitResult_t ret = oc_cond_wait_for(sharedCond, sharedMutex,
TARGET_WAIT * USECS_PER_SEC);
- EXPECT_EQ(CA_WAIT_TIMEDOUT,ret);
+ EXPECT_EQ(OC_WAIT_TIMEDOUT,ret);
uint64_t end = getAbsTime();
EXPECT_NEAR(TARGET_WAIT, secondsDiff, 0.05);
#endif
- ca_mutex_unlock(sharedMutex);
+ oc_mutex_unlock(sharedMutex);
// Cleanup Everything
- ca_mutex_free(sharedMutex);
+ oc_mutex_free(sharedMutex);
- ca_cond_free(sharedCond);
+ oc_cond_free(sharedCond);
}
static const size_t TIMEOUT = 1000000;
static const size_t WAITING_TIME = 500000;
-static ca_mutex g_connectRetryMutex = NULL;
-static ca_cond g_connectRetryCond = NULL;
+static oc_mutex g_connectRetryMutex = NULL;
+static oc_cond g_connectRetryCond = NULL;
-static ca_mutex g_recoveryMutex = NULL;
-static ca_cond g_recoveryCond = NULL;
+static oc_mutex g_recoveryMutex = NULL;
+static oc_cond g_recoveryCond = NULL;
CAResult_t CAManagerInitLEAutoConnection()
{
if (NULL == g_connectRetryMutex)
{
- g_connectRetryMutex = ca_mutex_new();
+ g_connectRetryMutex = oc_mutex_new();
if (NULL == g_connectRetryMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new has failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new has failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_connectRetryCond)
{
- g_connectRetryCond = ca_cond_new();
+ g_connectRetryCond = oc_cond_new();
if (NULL == g_connectRetryCond)
{
- OIC_LOG(ERROR, TAG, "ca_cond_new has failed");
+ OIC_LOG(ERROR, TAG, "oc_cond_new has failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_recoveryMutex)
{
- g_recoveryMutex = ca_mutex_new();
+ g_recoveryMutex = oc_mutex_new();
if (NULL == g_recoveryMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new has failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new has failed");
return CA_STATUS_FAILED;
}
}
if (NULL == g_recoveryCond)
{
- g_recoveryCond = ca_cond_new();
+ g_recoveryCond = oc_cond_new();
if (NULL == g_recoveryCond)
{
- OIC_LOG(ERROR, TAG, "ca_cond_new has failed");
+ OIC_LOG(ERROR, TAG, "oc_cond_new has failed");
return CA_STATUS_FAILED;
}
}
{
if (g_connectRetryCond)
{
- ca_cond_signal(g_connectRetryCond);
- ca_cond_free(g_connectRetryCond);
+ oc_cond_signal(g_connectRetryCond);
+ oc_cond_free(g_connectRetryCond);
g_connectRetryCond = NULL;
}
if (g_connectRetryMutex)
{
- ca_mutex_free(g_connectRetryMutex);
+ oc_mutex_free(g_connectRetryMutex);
g_connectRetryMutex = NULL;
}
if (g_recoveryCond)
{
- ca_cond_signal(g_recoveryCond);
- ca_cond_free(g_recoveryCond);
+ oc_cond_signal(g_recoveryCond);
+ oc_cond_free(g_recoveryCond);
g_recoveryCond = NULL;
}
if (g_recoveryMutex)
{
- ca_mutex_free(g_recoveryMutex);
+ oc_mutex_free(g_recoveryMutex);
g_recoveryMutex = NULL;
}
}
VERIFY_NON_NULL(remote_le_address, TAG, "remote_le_address is null");
OIC_LOG(DEBUG, TAG, "IN - CAManagerStartAutoConnection");
- ca_mutex_lock(g_connectRetryMutex);
+ oc_mutex_lock(g_connectRetryMutex);
bool isAutoConnecting = false;
if (CA_STATUS_OK != CAManagerGetAutoConnectingFlag(env, remote_le_address, &isAutoConnecting))
{
OIC_LOG(DEBUG, TAG, "CAManagerIsAutoConnecting has failed");
- ca_mutex_unlock(g_connectRetryMutex);
+ oc_mutex_unlock(g_connectRetryMutex);
return CA_STATUS_FAILED;
}
if (isAutoConnecting)
{
OIC_LOG(INFO, TAG, "connection has been already in progress or completed");
- ca_mutex_unlock(g_connectRetryMutex);
+ oc_mutex_unlock(g_connectRetryMutex);
return CA_STATUS_FAILED;
}
{
OIC_LOG_V(INFO, TAG, "retry will be started at least %d times after delay 1sec",
MAX_RETRY_COUNT - retry_cnt - 1);
- if (ca_cond_wait_for(g_connectRetryCond, g_connectRetryMutex, TIMEOUT) == 0)
+ if (oc_cond_wait_for(g_connectRetryCond, g_connectRetryMutex, TIMEOUT) == 0)
{
- ca_mutex_unlock(g_connectRetryMutex);
+ oc_mutex_unlock(g_connectRetryMutex);
OIC_LOG(INFO, TAG, "request to connect gatt was canceled");
return CA_STATUS_OK;
}
break;
}
}
- ca_mutex_unlock(g_connectRetryMutex);
+ oc_mutex_unlock(g_connectRetryMutex);
OIC_LOG(DEBUG, TAG, "OUT - CAManagerStartAutoConnection");
return res;
}
VERIFY_NON_NULL(env, TAG, "env");
OIC_LOG(DEBUG, TAG, "IN - CAManagerProcessRecovery");
- ca_mutex_lock(g_recoveryMutex);
+ oc_mutex_lock(g_recoveryMutex);
CAResult_t res = CA_STATUS_OK;
switch(adapter_state)
{
case STATE_OFF:
// adapter will be enabled automatically after WAITING_TIME.
- if (ca_cond_wait_for(g_recoveryCond, g_recoveryMutex, WAITING_TIME) == 0)
+ if (oc_cond_wait_for(g_recoveryCond, g_recoveryMutex, WAITING_TIME) == 0)
{
OIC_LOG(INFO, TAG, "BT recovery was canceled");
}
break;
}
- ca_mutex_unlock(g_recoveryMutex);
+ oc_mutex_unlock(g_recoveryMutex);
OIC_LOG(DEBUG, TAG, "OUT - CAManagerProcessRecovery");
return res;
#define TAG "OIC_CA_MANAGER_DEVICE"
static u_arraylist_t *g_deviceACDataList = NULL;
-static ca_mutex g_deviceACDataListMutex = NULL;
+static oc_mutex g_deviceACDataListMutex = NULL;
static bool g_isBTRecovery = false;
jstring CAManagerGetLEAddressFromACData(JNIEnv *env, size_t idx)
{
OIC_LOG(DEBUG, TAG, "CAManagerCreateACDataList");
- ca_mutex_lock(g_deviceACDataListMutex);
+ oc_mutex_lock(g_deviceACDataListMutex);
if (NULL == g_deviceACDataList)
{
OIC_LOG(DEBUG, TAG, "Create AC Data list");
g_deviceACDataList = u_arraylist_create();
}
- ca_mutex_unlock(g_deviceACDataListMutex);
+ oc_mutex_unlock(g_deviceACDataListMutex);
}
void CAManagerDestroyACDataList()
{
if (NULL == g_deviceACDataListMutex)
{
- g_deviceACDataListMutex = ca_mutex_new();
+ g_deviceACDataListMutex = oc_mutex_new();
if (NULL == g_deviceACDataListMutex)
{
- OIC_LOG(ERROR, TAG, "ca_mutex_new has failed");
+ OIC_LOG(ERROR, TAG, "oc_mutex_new has failed");
return CA_STATUS_FAILED;
}
}
{
if (g_deviceACDataListMutex)
{
- ca_mutex_free(g_deviceACDataListMutex);
+ oc_mutex_free(g_deviceACDataListMutex);
g_deviceACDataListMutex = NULL;
}
}
VERIFY_NON_NULL_RET(env, TAG, "env", NULL);
VERIFY_NON_NULL_RET(jaddress, TAG, "jaddress", false);
- ca_mutex_lock(g_deviceACDataListMutex);
+ oc_mutex_lock(g_deviceACDataListMutex);
const char* address = (*env)->GetStringUTFChars(env, jaddress, NULL);
if (!address)
{
OIC_LOG(ERROR, TAG, "address is null");
- ca_mutex_unlock(g_deviceACDataListMutex);
+ oc_mutex_unlock(g_deviceACDataListMutex);
return false;
}
{
OIC_LOG(ERROR, TAG, "curData is null");
(*env)->ReleaseStringUTFChars(env, jaddress, address);
- ca_mutex_unlock(g_deviceACDataListMutex);
+ oc_mutex_unlock(g_deviceACDataListMutex);
return false;
}
{
OIC_LOG(ERROR, TAG, "address is null");
(*env)->ReleaseStringUTFChars(env, jaddress, address);
- ca_mutex_unlock(g_deviceACDataListMutex);
+ oc_mutex_unlock(g_deviceACDataListMutex);
return false;
}
{
(*env)->ReleaseStringUTFChars(env, curData->address, setAddress);
(*env)->ReleaseStringUTFChars(env, jaddress, address);
- ca_mutex_unlock(g_deviceACDataListMutex);
+ oc_mutex_unlock(g_deviceACDataListMutex);
return true;
}
(*env)->ReleaseStringUTFChars(env, curData->address, setAddress);
OIC_LOG_V(DEBUG, TAG, "[%s] doesn't exist in list", address);
(*env)->ReleaseStringUTFChars(env, jaddress, address);
- ca_mutex_unlock(g_deviceACDataListMutex);
+ oc_mutex_unlock(g_deviceACDataListMutex);
return false;
}
CAManagerACData_t *data = CAManagerCreateACData(gaddress);
- ca_mutex_lock(g_deviceACDataListMutex);
+ oc_mutex_lock(g_deviceACDataListMutex);
u_arraylist_add(g_deviceACDataList, data);
- ca_mutex_unlock(g_deviceACDataListMutex);
+ oc_mutex_unlock(g_deviceACDataListMutex);
}
else
{
VERIFY_NON_NULL(env, TAG, "env");
VERIFY_NON_NULL(jaddress, TAG, "jaddress");
- ca_mutex_lock(g_deviceACDataListMutex);
+ oc_mutex_lock(g_deviceACDataListMutex);
const char* address = (*env)->GetStringUTFChars(env, jaddress, NULL);
if (!address)
{
OIC_LOG(ERROR, TAG, "address is null");
- ca_mutex_unlock(g_deviceACDataListMutex);
+ oc_mutex_unlock(g_deviceACDataListMutex);
return CA_STATUS_FAILED;
}
{
OIC_LOG(ERROR, TAG, "curData is null");
(*env)->ReleaseStringUTFChars(env, jaddress, address);
- ca_mutex_unlock(g_deviceACDataListMutex);
+ oc_mutex_unlock(g_deviceACDataListMutex);
return CA_STATUS_FAILED;
}
{
OIC_LOG(ERROR, TAG, "address is null");
(*env)->ReleaseStringUTFChars(env, jaddress, address);
- ca_mutex_unlock(g_deviceACDataListMutex);
+ oc_mutex_unlock(g_deviceACDataListMutex);
return CA_STATUS_FAILED;
}
OIC_LOG(ERROR, TAG, "removal has failed.");
(*env)->ReleaseStringUTFChars(env, jaddress, address);
(*env)->ReleaseStringUTFChars(env, curData->address, setAddress);
- ca_mutex_unlock(g_deviceACDataListMutex);
+ oc_mutex_unlock(g_deviceACDataListMutex);
return CA_STATUS_FAILED;
}
OICFree(curData);
(*env)->ReleaseStringUTFChars(env, jaddress, address);
- ca_mutex_unlock(g_deviceACDataListMutex);
+ oc_mutex_unlock(g_deviceACDataListMutex);
OIC_LOG(DEBUG, TAG, "remove done");
return CA_STATUS_OK;
}
OIC_LOG_V(DEBUG, TAG, "[%s] doesn't exist in list", address);
(*env)->ReleaseStringUTFChars(env, jaddress, address);
- ca_mutex_unlock(g_deviceACDataListMutex);
+ oc_mutex_unlock(g_deviceACDataListMutex);
return CA_STATUS_OK;
}
OIC_LOG(DEBUG, TAG, "IN - CAManagerRemoveAllACData");
VERIFY_NON_NULL(env, TAG, "env");
- ca_mutex_lock(g_deviceACDataListMutex);
+ oc_mutex_lock(g_deviceACDataListMutex);
size_t length = u_arraylist_length(g_deviceACDataList);
for (size_t idx = 0; idx < length; idx++)
if (!curData)
{
OIC_LOG(ERROR, TAG, "curData is null");
- ca_mutex_unlock(g_deviceACDataListMutex);
+ oc_mutex_unlock(g_deviceACDataListMutex);
return CA_STATUS_FAILED;
}
if (NULL == u_arraylist_remove(g_deviceACDataList, idx))
{
OIC_LOG(ERROR, TAG, "removal has failed.");
- ca_mutex_unlock(g_deviceACDataListMutex);
+ oc_mutex_unlock(g_deviceACDataListMutex);
return CA_STATUS_FAILED;
}
OICFree(curData);
}
- ca_mutex_unlock(g_deviceACDataListMutex);
+ oc_mutex_unlock(g_deviceACDataListMutex);
OIC_LOG(DEBUG, TAG, "OUT - CAManagerRemoveAllACData");
return CA_STATUS_OK;
}
VERIFY_NON_NULL(env, TAG, "env");
VERIFY_NON_NULL(jaddress, TAG, "jaddress");
- ca_mutex_lock(g_deviceACDataListMutex);
+ oc_mutex_lock(g_deviceACDataListMutex);
const char* address = (*env)->GetStringUTFChars(env, jaddress, NULL);
if (!address)
{
OIC_LOG(ERROR, TAG, "address is null");
- ca_mutex_unlock(g_deviceACDataListMutex);
+ oc_mutex_unlock(g_deviceACDataListMutex);
return CA_STATUS_FAILED;
}
{
OIC_LOG(ERROR, TAG, "curData is null");
(*env)->ReleaseStringUTFChars(env, jaddress, address);
- ca_mutex_unlock(g_deviceACDataListMutex);
+ oc_mutex_unlock(g_deviceACDataListMutex);
return CA_STATUS_FAILED;
}
{
OIC_LOG(ERROR, TAG, "setAddress is null");
(*env)->ReleaseStringUTFChars(env, jaddress, address);
- ca_mutex_unlock(g_deviceACDataListMutex);
+ oc_mutex_unlock(g_deviceACDataListMutex);
return CA_STATUS_FAILED;
}
*flag = curData->isAutoConnecting;
(*env)->ReleaseStringUTFChars(env, curData->address, setAddress);
(*env)->ReleaseStringUTFChars(env, jaddress, address);
- ca_mutex_unlock(g_deviceACDataListMutex);
+ oc_mutex_unlock(g_deviceACDataListMutex);
return CA_STATUS_OK;
}
(*env)->ReleaseStringUTFChars(env, curData->address, setAddress);
OIC_LOG_V(DEBUG, TAG, "[%s] doesn't exist in list", address);
(*env)->ReleaseStringUTFChars(env, jaddress, address);
- ca_mutex_unlock(g_deviceACDataListMutex);
+ oc_mutex_unlock(g_deviceACDataListMutex);
return CA_STATUS_FAILED;
}
VERIFY_NON_NULL_RET(env, TAG, "env", false);
VERIFY_NON_NULL_RET(jaddress, TAG, "jaddress", false);
- ca_mutex_lock(g_deviceACDataListMutex);
+ oc_mutex_lock(g_deviceACDataListMutex);
const char* address = (*env)->GetStringUTFChars(env, jaddress, NULL);
if (!address)
{
OIC_LOG(ERROR, TAG, "address is null");
- ca_mutex_unlock(g_deviceACDataListMutex);
+ oc_mutex_unlock(g_deviceACDataListMutex);
return false;
}
{
OIC_LOG(ERROR, TAG, "curData is null");
(*env)->ReleaseStringUTFChars(env, jaddress, address);
- ca_mutex_unlock(g_deviceACDataListMutex);
+ oc_mutex_unlock(g_deviceACDataListMutex);
return false;
}
{
OIC_LOG(ERROR, TAG, "address is null");
(*env)->ReleaseStringUTFChars(env, jaddress, address);
- ca_mutex_unlock(g_deviceACDataListMutex);
+ oc_mutex_unlock(g_deviceACDataListMutex);
return false;
}
curData->isAutoConnecting = flag;
(*env)->ReleaseStringUTFChars(env, curData->address, setAddress);
(*env)->ReleaseStringUTFChars(env, jaddress, address);
- ca_mutex_unlock(g_deviceACDataListMutex);
+ oc_mutex_unlock(g_deviceACDataListMutex);
return true;
}
(*env)->ReleaseStringUTFChars(env, curData->address, setAddress);
OIC_LOG_V(DEBUG, TAG, "[%s] doesn't exist in list", address);
(*env)->ReleaseStringUTFChars(env, jaddress, address);
- ca_mutex_unlock(g_deviceACDataListMutex);
+ oc_mutex_unlock(g_deviceACDataListMutex);
return false;
}
static uint64_t timeout;
static uint16_t g_credId = 0;
-ca_cond cond;
-ca_mutex mutex;
+oc_cond cond;
+oc_mutex mutex;
typedef enum {
SIGN_UP = 1,
{
OICFree(data);
- ca_mutex_lock(mutex);
- ca_cond_signal(cond);
- ca_mutex_unlock(mutex);
+ oc_mutex_lock(mutex);
+ oc_cond_signal(cond);
+ oc_mutex_unlock(mutex);
}
/**
strncpy(endPoint.addr, DEFAULT_HOST, sizeof(endPoint.addr));
endPoint.port = DEFAULT_PORT;
- mutex = ca_mutex_new();
- cond = ca_cond_new();
+ mutex = oc_mutex_new();
+ cond = oc_cond_new();
while (false == fExit)
{
}
break;
case EXIT:
- ca_mutex_free(mutex);
- ca_cond_free(cond);
+ oc_mutex_free(mutex);
+ oc_cond_free(cond);
fExit = true;
break;
default:
//if requests were sent then wait response
if (res == OC_STACK_OK)
{
- ca_mutex_lock(mutex);
- ca_cond_wait_for(cond, mutex, timeout);
- ca_mutex_unlock(mutex);
+ oc_mutex_lock(mutex);
+ oc_cond_wait_for(cond, mutex, timeout);
+ oc_mutex_unlock(mutex);
}
}
}