Rename all threading and synchronization to oc_*
authorDaniel Ferguson <daniel.j.ferguson@intel.com>
Fri, 16 Sep 2016 07:00:15 +0000 (00:00 -0700)
committerDave Thaler <dthaler@microsoft.com>
Sat, 17 Sep 2016 01:18:43 +0000 (01:18 +0000)
* The threading and synchronization facilities were prefixed with
  ca_* when they lived in connectivity_abstraction. Now that the
  facilities have been moved to c_common, ca_* was renamed to oc_*

Change-Id: I0acc00680c42ebecd376ac238958875d9f1032e4
Signed-off-by: Daniel Ferguson <daniel.j.ferguson@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/11227
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Dave Thaler <dthaler@microsoft.com>
40 files changed:
resource/c_common/octhread/include/octhread.h
resource/c_common/octhread/src/noop/octhread.c
resource/c_common/octhread/src/posix/octhread.c
resource/c_common/octhread/src/windows/octhread.c
resource/csdk/connectivity/common/src/cathreadpool_pthreads.c
resource/csdk/connectivity/inc/cablockwisetransfer.h
resource/csdk/connectivity/inc/caqueueingthread.h
resource/csdk/connectivity/inc/caretransmission.h
resource/csdk/connectivity/src/adapter_util/ca_adapter_net_tls.c
resource/csdk/connectivity/src/adapter_util/caadapternetdtls.c
resource/csdk/connectivity/src/bt_edr_adapter/android/caedrclient.c
resource/csdk/connectivity/src/bt_edr_adapter/android/caedrserver.c
resource/csdk/connectivity/src/bt_edr_adapter/tizen/caedrclient.c
resource/csdk/connectivity/src/bt_le_adapter/android/caleclient.c
resource/csdk/connectivity/src/bt_le_adapter/android/calenwmonitor.c
resource/csdk/connectivity/src/bt_le_adapter/android/caleserver.c
resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c
resource/csdk/connectivity/src/bt_le_adapter/linux/caleinterface.c
resource/csdk/connectivity/src/bt_le_adapter/linux/central.c
resource/csdk/connectivity/src/bt_le_adapter/linux/characteristic.c
resource/csdk/connectivity/src/bt_le_adapter/linux/client.c
resource/csdk/connectivity/src/bt_le_adapter/linux/context.h
resource/csdk/connectivity/src/bt_le_adapter/linux/peripheral.c
resource/csdk/connectivity/src/bt_le_adapter/linux/peripheral.h
resource/csdk/connectivity/src/bt_le_adapter/linux/recv.c
resource/csdk/connectivity/src/bt_le_adapter/linux/utils.c
resource/csdk/connectivity/src/bt_le_adapter/tizen/caleclient.c
resource/csdk/connectivity/src/bt_le_adapter/tizen/calenwmonitor.c
resource/csdk/connectivity/src/bt_le_adapter/tizen/caleserver.c
resource/csdk/connectivity/src/cablockwisetransfer.c
resource/csdk/connectivity/src/camessagehandler.c
resource/csdk/connectivity/src/caqueueingthread.c
resource/csdk/connectivity/src/caretransmission.c
resource/csdk/connectivity/src/ip_adapter/linux/caipnwmonitor.c
resource/csdk/connectivity/src/ra_adapter/caraadapter.c
resource/csdk/connectivity/src/tcp_adapter/catcpserver.c
resource/csdk/connectivity/test/octhread_tests.cpp
resource/csdk/connectivity/util/src/camanager/android/caleautoconnector.c
resource/csdk/connectivity/util/src/camanager/android/camanagerdevice.c
resource/csdk/security/provisioning/sample/cloudClient.c

index 94f3ac6..c9a6062 100644 (file)
@@ -37,29 +37,29 @@ extern "C"
 {
 #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
@@ -67,35 +67,35 @@ typedef enum
  * @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.
@@ -103,7 +103,7 @@ CAThreadResult_t ca_thread_wait(ca_thread t);
  * @return  Reference to newly created mutex, otherwise NULL.
  *
  */
-ca_mutex ca_mutex_new(void);
+oc_mutex oc_mutex_new(void);
 
 /**
  * Lock the mutex.
@@ -111,7 +111,7 @@ ca_mutex ca_mutex_new(void);
  * @param  mutex  The mutex to be locked.
  *
  */
-void ca_mutex_lock(ca_mutex mutex);
+void oc_mutex_lock(oc_mutex mutex);
 
 /**
  * Unlock the mutex.
@@ -119,7 +119,7 @@ void ca_mutex_lock(ca_mutex 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.
@@ -130,15 +130,15 @@ void ca_mutex_unlock(ca_mutex 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.
@@ -146,7 +146,7 @@ ca_cond ca_cond_new(void);
  * @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.
@@ -154,7 +154,7 @@ void ca_cond_signal(ca_cond 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.
@@ -163,24 +163,24 @@ void ca_cond_broadcast(ca_cond 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.
@@ -188,10 +188,10 @@ CAWaitResult_t ca_cond_wait_for(ca_cond cond, ca_mutex mutex, uint64_t microseco
  * @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_ */
index 2923545..43e2bb6 100644 (file)
 
 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;
 }
 
index 9cadcb5..c635993 100644 (file)
@@ -88,52 +88,52 @@ static const uint64_t NANOSECS_PER_SEC      = 1000000000L;
 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);
@@ -141,36 +141,36 @@ CAThreadResult_t ca_thread_free(ca_thread t)
     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
         {
@@ -186,10 +186,10 @@ ca_mutex ca_mutex_new(void)
     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);
@@ -211,9 +211,9 @@ bool ca_mutex_free(ca_mutex 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);
@@ -229,9 +229,9 @@ void ca_mutex_lock(ca_mutex 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);
@@ -248,10 +248,10 @@ void ca_mutex_unlock(ca_mutex 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));
@@ -285,7 +285,7 @@ ca_cond ca_cond_new(void)
         ret = pthread_cond_init(&(eventInfo->cond), &(eventInfo->condattr));
         if (0 == ret)
         {
-            retVal = (ca_cond) eventInfo;
+            retVal = (oc_cond) eventInfo;
         }
         else
         {
@@ -302,9 +302,9 @@ ca_cond ca_cond_new(void)
     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));
@@ -325,9 +325,9 @@ void ca_cond_free(ca_cond 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));
@@ -342,9 +342,9 @@ void ca_cond_signal(ca_cond 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));
@@ -359,9 +359,9 @@ void ca_cond_broadcast(ca_cond 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
@@ -371,7 +371,7 @@ void ca_cond_wait(ca_cond cond, ca_mutex mutex)
 }
 #endif
 
-struct timespec ca_get_current_time()
+struct timespec oc_get_current_time()
 {
 #if defined(__ANDROID__) || _POSIX_TIMERS > 0
     struct timespec ts;
@@ -386,7 +386,7 @@ struct timespec ca_get_current_time()
 #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;
@@ -397,23 +397,23 @@ void ca_add_microseconds_to_timespec(struct timespec* ts, uint64_t microseconds)
     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)
@@ -431,8 +431,8 @@ CAWaitResult_t ca_cond_wait_for(ca_cond cond, ca_mutex mutex, uint64_t microseco
         } 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);
@@ -442,18 +442,18 @@ CAWaitResult_t ca_cond_wait_for(ca_cond cond, ca_mutex mutex, uint64_t microseco
         {
             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;
         }
     }
@@ -461,7 +461,7 @@ CAWaitResult_t ca_cond_wait_for(ca_cond cond, ca_mutex mutex, uint64_t microseco
     {
         // 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;
 }
index 6069586..2613883 100644 (file)
@@ -20,7 +20,7 @@
 
 /**
  * @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"
@@ -38,56 +38,56 @@ static const uint64_t USECS_PER_MSEC = 1000;
 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
     {
@@ -96,15 +96,15 @@ CAThreadResult_t ca_thread_free(ca_thread t)
     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
     {
@@ -113,14 +113,14 @@ CAThreadResult_t ca_thread_wait(ca_thread t)
     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
     {
@@ -130,10 +130,10 @@ ca_mutex ca_mutex_new(void)
     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);
@@ -148,9 +148,9 @@ bool ca_mutex_free(ca_mutex 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);
@@ -161,9 +161,9 @@ void ca_mutex_lock(ca_mutex 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);
@@ -174,14 +174,14 @@ void ca_mutex_unlock(ca_mutex 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
     {
@@ -191,9 +191,9 @@ ca_cond ca_cond_new(void)
     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);
@@ -204,9 +204,9 @@ void ca_cond_free(ca_cond 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);
@@ -217,9 +217,9 @@ void ca_cond_signal(ca_cond 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);
@@ -230,28 +230,28 @@ void ca_cond_broadcast(ca_cond 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;
@@ -269,17 +269,17 @@ CAWaitResult_t ca_cond_wait_for(ca_cond cond, ca_mutex mutex, uint64_t microseco
     {
         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;
index 03d054f..2b1939f 100644 (file)
@@ -48,7 +48,7 @@
 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;
 
 /**
@@ -108,7 +108,7 @@ CAResult_t ca_thread_pool_init(int32_t num_of_threads, ca_thread_pool_t *thread_
         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)
     {
@@ -121,7 +121,7 @@ CAResult_t ca_thread_pool_init(int32_t num_of_threads, ca_thread_pool_t *thread_
     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");
         }
@@ -159,8 +159,8 @@ CAResult_t ca_thread_pool_add_task(ca_thread_pool_t thread_pool, ca_thread_func
     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);
@@ -168,14 +168,14 @@ CAResult_t ca_thread_pool_add_task(ca_thread_pool_t thread_pool, ca_thread_func
         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;
     }
 
@@ -193,19 +193,19 @@ void ca_thread_pool_free(ca_thread_pool_t thread_pool)
         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);
index c41ffa7..3a7f948 100644 (file)
@@ -68,10 +68,10 @@ typedef struct
     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;
 
 /**
index 6f649ca..40bd532 100644 (file)
@@ -49,9 +49,9 @@ typedef struct
     /** 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. **/
index 42d57e3..904b5da 100644 (file)
@@ -74,10 +74,10 @@ typedef struct
     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;
index 66a5f97..53c8fe8 100644 (file)
@@ -160,7 +160,7 @@ if (0 != ret && MBEDTLS_ERR_SSL_WANT_READ != ret &&  MBEDTLS_ERR_SSL_WANT_WRITE
     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;                                                                                  \
@@ -326,7 +326,7 @@ static CAgetPkixInfoHandler g_getPkixInfoCallback = NULL;
  * @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
@@ -733,18 +733,18 @@ CAResult_t CAcloseTlsConnection(const CAEndpoint_t *endpoint)
     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 */
@@ -756,7 +756,7 @@ CAResult_t CAcloseTlsConnection(const CAEndpoint_t *endpoint)
     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;
@@ -938,7 +938,7 @@ void CAdeinitTlsAdapter()
     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();
@@ -956,8 +956,8 @@ void CAdeinitTlsAdapter()
     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__);
@@ -970,7 +970,7 @@ CAResult_t CAinitTlsAdapter()
     // 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);
     }
@@ -981,14 +981,14 @@ CAResult_t CAinitTlsAdapter()
     }
 
     // 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;
     }
@@ -1001,8 +1001,8 @@ CAResult_t CAinitTlsAdapter()
         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;
     }
@@ -1027,7 +1027,7 @@ CAResult_t CAinitTlsAdapter()
     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;
     }
@@ -1035,7 +1035,7 @@ CAResult_t CAinitTlsAdapter()
     {
         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;
     }
@@ -1048,7 +1048,7 @@ CAResult_t CAinitTlsAdapter()
                                   &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;
     }
@@ -1061,7 +1061,7 @@ CAResult_t CAinitTlsAdapter()
                                     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;
     }
@@ -1088,7 +1088,7 @@ CAResult_t CAinitTlsAdapter()
                                     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;
     }
@@ -1116,7 +1116,7 @@ CAResult_t CAinitTlsAdapter()
     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;
@@ -1181,11 +1181,11 @@ CAResult_t CAencryptTls(const CAEndpoint_t *endpoint,
 
     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;
     }
 
@@ -1197,7 +1197,7 @@ CAResult_t CAencryptTls(const CAEndpoint_t *endpoint,
     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;
     }
 
@@ -1214,7 +1214,7 @@ CAResult_t CAencryptTls(const CAEndpoint_t *endpoint,
                 g_tlsHandshakeCallback(&tep->sep.endpoint, &errorInfo);
             }
             removePeerFromList(&tep->sep.endpoint);
-            ca_mutex_unlock(g_tlsContextMutex);
+            oc_mutex_unlock(g_tlsContextMutex);
             return CA_STATUS_FAILED;
         }
     }
@@ -1224,12 +1224,12 @@ CAResult_t CAencryptTls(const CAEndpoint_t *endpoint,
         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;
@@ -1349,11 +1349,11 @@ CAResult_t CAdecryptTls(const CASecureEndpoint_t *sep, uint8_t *data, uint32_t d
     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;
     }
 
@@ -1365,7 +1365,7 @@ CAResult_t CAdecryptTls(const CASecureEndpoint_t *sep, uint8_t *data, uint32_t d
         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
@@ -1376,7 +1376,7 @@ CAResult_t CAdecryptTls(const CASecureEndpoint_t *sep, uint8_t *data, uint32_t d
         {
             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;
         }
     }
@@ -1457,7 +1457,7 @@ CAResult_t CAdecryptTls(const CASecureEndpoint_t *sep, uint8_t *data, uint32_t d
                     }
                 }
             }
-            ca_mutex_unlock(g_tlsContextMutex);
+            oc_mutex_unlock(g_tlsContextMutex);
             OIC_LOG_V(DEBUG, NET_TLS_TAG, "Out %s", __func__);
             return CA_STATUS_OK;
         }
@@ -1474,7 +1474,7 @@ CAResult_t CAdecryptTls(const CASecureEndpoint_t *sep, uint8_t *data, uint32_t d
         {
             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;
         }
 
@@ -1487,14 +1487,14 @@ CAResult_t CAdecryptTls(const CASecureEndpoint_t *sep, uint8_t *data, uint32_t d
                 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;
 }
@@ -1506,11 +1506,11 @@ void CAsetTlsAdapterCallbacks(CAPacketReceivedCallback recvCallback,
     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;
     }
 
@@ -1521,7 +1521,7 @@ void CAsetTlsAdapterCallbacks(CAPacketReceivedCallback recvCallback,
         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__);
 }
 
@@ -1597,13 +1597,13 @@ CAResult_t CAinitiateTlsHandshake(const CAEndpoint_t *endpoint)
     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;
 }
@@ -1617,11 +1617,11 @@ CAResult_t CAtlsGenerateOwnerPSK(const CAEndpoint_t *endpoint,
     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;
     }
@@ -1629,7 +1629,7 @@ CAResult_t CAtlsGenerateOwnerPSK(const CAEndpoint_t *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;
     }
 
@@ -1639,13 +1639,13 @@ CAResult_t CAtlsGenerateOwnerPSK(const CAEndpoint_t *endpoint,
                                        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;
index 571878e..1a2070c 100644 (file)
@@ -69,7 +69,7 @@ static stCADtlsContext_t *g_caDtlsContext = NULL;
  * @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
@@ -628,11 +628,11 @@ void CADTLSSetAdapterCallbacks(CAPacketReceivedCallback recvCallback,
                                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;
     }
 
@@ -643,7 +643,7 @@ void CADTLSSetAdapterCallbacks(CAPacketReceivedCallback recvCallback,
         g_caDtlsContext->adapterCallbacks[0].sendCallback = sendCallback;
     }
 
-    ca_mutex_unlock(g_dtlsContextMutex);
+    oc_mutex_unlock(g_dtlsContextMutex);
 
     OIC_LOG(DEBUG, NET_DTLS_TAG, "OUT");
 }
@@ -683,15 +683,15 @@ CAResult_t CADtlsSelectCipherSuite(const dtls_cipher_t cipher)
 {
     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]);
@@ -704,16 +704,16 @@ CAResult_t CADtlsEnableAnonECDHCipherSuite(const bool enable)
 {
     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");
 
@@ -737,22 +737,22 @@ CAResult_t CADtlsInitiateHandshake(const CAEndpoint_t *endpoint)
     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");
 
@@ -774,22 +774,22 @@ CAResult_t CADtlsClose(const CAEndpoint_t *endpoint)
     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");
 
@@ -815,11 +815,11 @@ CAResult_t CADtlsGenerateOwnerPSK(const CAEndpoint_t *endpoint,
     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;
     }
 
@@ -828,10 +828,10 @@ CAResult_t CADtlsGenerateOwnerPSK(const CAEndpoint_t *endpoint,
                  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");
 
@@ -1031,17 +1031,17 @@ static void CAStartRetransmit()
         //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);
@@ -1054,7 +1054,7 @@ CAResult_t CAAdapterNetDtlsInit()
     // 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);
     }
@@ -1065,14 +1065,14 @@ CAResult_t CAAdapterNetDtlsInit()
     }
 
     // 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;
     }
 
@@ -1089,8 +1089,8 @@ CAResult_t CAAdapterNetDtlsInit()
         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;
     }
 
@@ -1103,7 +1103,7 @@ CAResult_t CAAdapterNetDtlsInit()
     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;
     }
@@ -1120,7 +1120,7 @@ CAResult_t CAAdapterNetDtlsInit()
     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();
 
@@ -1136,7 +1136,7 @@ void CAAdapterNetDtlsDeInit()
     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();
@@ -1151,8 +1151,8 @@ void CAAdapterNetDtlsDeInit()
     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");
@@ -1183,11 +1183,11 @@ CAResult_t CAAdapterNetDtlsEncrypt(const CAEndpoint_t *endpoint,
     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;
     }
 
@@ -1198,7 +1198,7 @@ CAResult_t CAAdapterNetDtlsEncrypt(const CAEndpoint_t *endpoint,
         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;
         }
 
@@ -1207,7 +1207,7 @@ CAResult_t CAAdapterNetDtlsEncrypt(const CAEndpoint_t *endpoint,
         {
             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);
@@ -1221,11 +1221,11 @@ CAResult_t CAAdapterNetDtlsEncrypt(const CAEndpoint_t *endpoint,
             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)
     {
@@ -1249,16 +1249,16 @@ CAResult_t CAAdapterNetDtlsDecrypt(const CASecureEndpoint_t *sep,
     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)
     {
index f507f6e..cc7a58b 100644 (file)
@@ -57,13 +57,13 @@ static jobject g_context;
  * @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
@@ -281,20 +281,20 @@ static void CAEDRDestroyMutex()
 {
     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!");
@@ -303,7 +303,7 @@ static CAResult_t CAEDRCreateMutex()
         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!");
@@ -355,13 +355,13 @@ CAResult_t CAEDRInitialize()
     }
     (*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)
     {
@@ -1043,16 +1043,16 @@ CAResult_t CAEDRNativeConnect(JNIEnv *env, const char *address)
         (*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");
 
@@ -1098,9 +1098,9 @@ void CAEDRNativeSocketClose(JNIEnv *env, const char *address)
     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);
 }
index 9edcdb5..ff7c8e4 100644 (file)
@@ -54,7 +54,7 @@ static JavaVM *g_jvm;
 /**
  * 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.
@@ -64,7 +64,7 @@ static bool g_stopUnicast = false;
 /**
  * Mutex to synchronize accept server.
  */
-static ca_mutex g_mutexAcceptServer = NULL;
+static oc_mutex g_mutexAcceptServer = NULL;
 
 /**
  * Flag to control the Accept Thread.
@@ -74,7 +74,7 @@ static bool g_stopAccept = false;
 /**
  * Mutex to synchronize server socket.
  */
-static ca_mutex g_mutexServerSocket = NULL;
+static oc_mutex g_mutexServerSocket = NULL;
 
 /**
  * Flag to control the server socket.
@@ -84,12 +84,12 @@ static jobject g_serverSocket = NULL;
 /**
  * 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.
@@ -200,16 +200,16 @@ static void CAAcceptHandler(void *data)
         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))
     {
@@ -217,12 +217,12 @@ static void CAAcceptHandler(void *data)
         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
         {
@@ -271,9 +271,9 @@ CAResult_t CAEDRServerStop()
 {
     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)
     {
@@ -316,45 +316,45 @@ static void CAEDRServerDestroyMutex()
 {
     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!");
@@ -363,7 +363,7 @@ static CAResult_t CAEDRServerCreateMutex()
         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!");
@@ -372,7 +372,7 @@ static CAResult_t CAEDRServerCreateMutex()
         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!");
@@ -381,7 +381,7 @@ static CAResult_t CAEDRServerCreateMutex()
         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!");
@@ -436,13 +436,13 @@ CAResult_t CAEDRServerStartAcceptThread()
         (*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)
     {
@@ -510,7 +510,7 @@ CAResult_t CAEDRStartReceiveThread(bool isSecured)
 {
     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.
@@ -524,7 +524,7 @@ CAResult_t CAEDRStartReceiveThread(bool isSecured)
     if (!ctx)
     {
         OIC_LOG(ERROR, TAG, "Out of memory!");
-        ca_mutex_unlock(g_mutexReceiveServer);
+        oc_mutex_unlock(g_mutexReceiveServer);
         return CA_MEMORY_ALLOC_FAILED;
     }
 
@@ -534,11 +534,11 @@ CAResult_t CAEDRStartReceiveThread(bool isSecured)
     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;
@@ -548,9 +548,9 @@ CAResult_t CAEDRStopReceiveThread()
 {
     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;
 }
@@ -718,9 +718,9 @@ CAResult_t CAEDRNativeReadData(JNIEnv *env, uint32_t idx)
 
                 // 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);
@@ -759,9 +759,9 @@ void CANativeStartListenTask(JNIEnv *env)
         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)
@@ -904,9 +904,9 @@ void CAEDRNativeAccept(JNIEnv *env, jobject serverSocketObject)
         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);
@@ -920,9 +920,9 @@ void CAEDRNativeAccept(JNIEnv *env, jobject serverSocketObject)
             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);
index 3743f13..3e276bf 100644 (file)
@@ -49,7 +49,7 @@
 /**
  * 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.
@@ -75,7 +75,7 @@ static u_arraylist_t *g_multicastDataList = NULL;
 /**
  * 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
@@ -174,7 +174,7 @@ void CAEDRSocketConnectionStateCallback(int result, bt_socket_connection_state_e
     {
         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)
@@ -185,26 +185,26 @@ void CAEDRSocketConnectionStateCallback(int result, bt_socket_connection_state_e
                     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;
@@ -226,15 +226,15 @@ void CAEDRSocketConnectionStateCallback(int result, bt_socket_connection_state_e
                     // 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;
 
@@ -271,10 +271,10 @@ void CAEDRDeviceDiscoveryCallback(int result, bt_adapter_device_discovery_state_
         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;
 
@@ -287,18 +287,18 @@ void CAEDRDeviceDiscoveryCallback(int result, bt_adapter_device_discovery_state_
                                                         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;
                     }
 
@@ -308,14 +308,14 @@ void CAEDRDeviceDiscoveryCallback(int result, bt_adapter_device_discovery_state_
                     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;
                     }
 
@@ -352,7 +352,7 @@ void CAEDRDeviceDiscoveryCallback(int result, bt_adapter_device_discovery_state_
                         }
                     }
                     device->serviceSearched = true;
-                    ca_mutex_unlock(g_edrDeviceListMutex);
+                    oc_mutex_unlock(g_edrDeviceListMutex);
                 }
                 else
                 {
@@ -379,7 +379,7 @@ void CAEDRServiceSearchedCallback(int32_t result,
         return;
     }
 
-    ca_mutex_lock(g_edrDeviceListMutex);
+    oc_mutex_lock(g_edrDeviceListMutex);
 
     EDRDevice *device = NULL;
     CAResult_t res = CAGetEDRDevice(g_edrDeviceList, sdpInfo->remote_address, &device);
@@ -388,7 +388,7 @@ void CAEDRServiceSearchedCallback(int32_t result,
         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;
         }
 
@@ -414,7 +414,7 @@ void CAEDRServiceSearchedCallback(int32_t result,
         }
     }
 
-    ca_mutex_unlock(g_edrDeviceListMutex);
+    oc_mutex_unlock(g_edrDeviceListMutex);
 
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
 }
@@ -565,12 +565,12 @@ CAResult_t CAEDRManagerInitializeMutex(void)
 
     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)
@@ -589,13 +589,13 @@ void CAEDRManagerTerminateMutex(void)
 
     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;
     }
 
@@ -617,17 +617,17 @@ void CAEDRClientTerminate()
     // 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
@@ -639,7 +639,7 @@ void CAEDRClientDisconnectAll(void)
 {
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
 
-    ca_mutex_lock(g_edrDeviceListMutex);
+    oc_mutex_lock(g_edrDeviceListMutex);
 
     EDRDeviceList *cur = g_edrDeviceList;
     while (cur != NULL)
@@ -660,7 +660,7 @@ void CAEDRClientDisconnectAll(void)
         }
     }
 
-    ca_mutex_unlock(g_edrDeviceListMutex);
+    oc_mutex_unlock(g_edrDeviceListMutex);
 
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
 }
@@ -685,7 +685,7 @@ CAResult_t CAEDRClientSendUnicastData(const char *remoteAddress,
     }
 
     // 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)
     {
@@ -696,7 +696,7 @@ CAResult_t CAEDRClientSendUnicastData(const char *remoteAddress,
         {
             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;
         }
 
@@ -709,7 +709,7 @@ CAResult_t CAEDRClientSendUnicastData(const char *remoteAddress,
             // Remove device from list
             CARemoveEDRDeviceFromList(&g_edrDeviceList, remoteAddress);
 
-            ca_mutex_unlock(g_edrDeviceListMutex);
+            oc_mutex_unlock(g_edrDeviceListMutex);
             return CA_STATUS_FAILED;
         }
     }
@@ -720,11 +720,11 @@ CAResult_t CAEDRClientSendUnicastData(const char *remoteAddress,
         // 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)
     {
@@ -780,7 +780,7 @@ CAResult_t CAEDRClientSendMulticastData(const uint8_t *data,
     }
 
     // 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;
@@ -835,7 +835,7 @@ CAResult_t CAEDRClientSendMulticastData(const uint8_t *data,
         }
     }
 
-    ca_mutex_unlock(g_edrDeviceListMutex);
+    oc_mutex_unlock(g_edrDeviceListMutex);
 
     if(g_isDiscoveryServer)
     {
@@ -861,13 +861,13 @@ CAResult_t CAEDRClientSendMulticastData(const uint8_t *data,
             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);
         }
     }
 
@@ -945,16 +945,16 @@ void CAEDRDataRecvCallback(bt_socket_received_data_s *data, void *userData)
     }
 
     // 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)
index c6858f9..3e7fd41 100644 (file)
@@ -75,30 +75,30 @@ static jbyteArray g_sendBuffer = NULL;
 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;
@@ -153,7 +153,7 @@ void CALERestartScanWithInterval(int32_t intervalTime, int32_t workingCount)
 {
     // restart scan with interval
     CALEClientSetScanInterval(intervalTime, workingCount);
-    ca_cond_signal(g_threadScanIntervalCond);
+    oc_cond_signal(g_threadScanIntervalCond);
 }
 
 static void CALEScanThread(void* object)
@@ -176,7 +176,7 @@ 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");
@@ -200,7 +200,7 @@ static void CALEScanThread(void* object)
         }
 
         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))
         {
@@ -230,7 +230,7 @@ static void CALEScanThread(void* object)
            }
         }
     }
-    ca_mutex_unlock(g_threadScanIntervalMutex);
+    oc_mutex_unlock(g_threadScanIntervalMutex);
 
     if (isAttached)
     {
@@ -269,7 +269,7 @@ CAResult_t CALEClientStartScanWithInterval()
 void CALEClientStopScanWithInterval()
 {
     g_isWorkingScanThread = false;
-    ca_cond_signal(g_threadScanIntervalCond);
+    oc_cond_signal(g_threadScanIntervalCond);
 }
 
 //getting jvm
@@ -425,13 +425,13 @@ CAResult_t CALEClientInitialize()
         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();
@@ -544,11 +544,11 @@ void CALEClientTerminate()
     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;
@@ -771,13 +771,13 @@ CAResult_t CALEClientIsThereScannedDevices(JNIEnv *env, const char* address)
         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)
                 {
@@ -793,16 +793,16 @@ CAResult_t CALEClientIsThereScannedDevices(JNIEnv *env, const char* address)
                         {
                             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.
@@ -860,7 +860,7 @@ CAResult_t CALEClientSendUnicastMessageImpl(const char* address, const uint8_t*
         isAttached = true;
     }
 
-    ca_mutex_lock(g_threadSendMutex);
+    oc_mutex_lock(g_threadSendMutex);
 
     CALEClientSetSendFinishFlag(false);
 
@@ -938,14 +938,14 @@ CAResult_t CALEClientSendUnicastMessageImpl(const char* address, const uint8_t*
 
     // 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)
     {
@@ -957,11 +957,11 @@ CAResult_t CALEClientSendUnicastMessageImpl(const char* address, const uint8_t*
     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))
@@ -992,7 +992,7 @@ error_exit:
     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);
@@ -1005,7 +1005,7 @@ error_exit:
         (*g_jvm)->DetachCurrentThread(g_jvm);
     }
 
-    ca_mutex_unlock(g_threadSendMutex);
+    oc_mutex_unlock(g_threadSendMutex);
     return CA_SEND_FAILED;
 }
 
@@ -1022,7 +1022,7 @@ CAResult_t CALEClientSendMulticastMessageImpl(JNIEnv *env, const uint8_t* data,
         return CA_STATUS_FAILED;
     }
 
-    ca_mutex_lock(g_threadSendMutex);
+    oc_mutex_lock(g_threadSendMutex);
 
     CALEClientSetSendFinishFlag(false);
 
@@ -1069,25 +1069,25 @@ CAResult_t CALEClientSendMulticastMessageImpl(JNIEnv *env, const uint8_t* data,
     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;
 
@@ -1096,11 +1096,11 @@ error_exit:
     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;
 }
@@ -1124,9 +1124,9 @@ CAResult_t CALEClientSendData(JNIEnv *env, jobject device)
             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)
@@ -1642,7 +1642,7 @@ CAResult_t CALEClientSetFlagToState(JNIEnv *env, jstring jni_address, jint 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)
@@ -1658,7 +1658,7 @@ CAResult_t CALEClientSetFlagToState(JNIEnv *env, jstring jni_address, jint state
         {
             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);
@@ -1677,7 +1677,7 @@ CAResult_t CALEClientSetFlagToState(JNIEnv *env, jstring jni_address, jint state
     }
 
     (*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;
 }
@@ -1688,13 +1688,13 @@ jboolean CALEClientGetFlagFromState(JNIEnv *env, jstring jni_address, jint state
     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;
     }
 
@@ -1703,7 +1703,7 @@ jboolean CALEClientGetFlagFromState(JNIEnv *env, jstring jni_address, jint state
     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;
     }
 
@@ -1719,7 +1719,7 @@ jboolean CALEClientGetFlagFromState(JNIEnv *env, jstring jni_address, jint state
         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");
@@ -1732,13 +1732,13 @@ CAResult_t CALEClientDirectConnect(JNIEnv *env, jobject bluetoothDevice, jboolea
     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;
     }
 
@@ -1746,7 +1746,7 @@ CAResult_t CALEClientDirectConnect(JNIEnv *env, jobject bluetoothDevice, jboolea
     if (!address)
     {
         OIC_LOG(ERROR, TAG, "address is not available");
-        ca_mutex_unlock(g_threadSendMutex);
+        oc_mutex_unlock(g_threadSendMutex);
         return CA_STATUS_FAILED;
     }
 
@@ -1761,7 +1761,7 @@ CAResult_t CALEClientDirectConnect(JNIEnv *env, jobject bluetoothDevice, jboolea
             res = CA_STATUS_FAILED;
         }
     }
-    ca_mutex_unlock(g_threadSendMutex);
+    oc_mutex_unlock(g_threadSendMutex);
 
     return res;
 }
@@ -2178,13 +2178,13 @@ CAResult_t CALESetValueAndWriteCharacteristic(JNIEnv* env, jobject gatt)
         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;
     }
 
@@ -2194,13 +2194,13 @@ CAResult_t CALESetValueAndWriteCharacteristic(JNIEnv* env, jobject gatt)
         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);
@@ -2219,23 +2219,23 @@ CAResult_t CALESetValueAndWriteCharacteristic(JNIEnv* env, jobject gatt)
 
     // 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);
 
@@ -2762,7 +2762,7 @@ void CALEClientCreateScanDeviceList(JNIEnv *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)
     {
@@ -2770,7 +2770,7 @@ void CALEClientCreateScanDeviceList(JNIEnv *env)
 
         g_deviceList = u_arraylist_create();
     }
-    ca_mutex_unlock(g_deviceListMutex);
+    oc_mutex_unlock(g_deviceListMutex);
 }
 
 CAResult_t CALEClientAddScanDeviceToList(JNIEnv *env, jobject device)
@@ -2778,14 +2778,14 @@ 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;
     }
 
@@ -2793,7 +2793,7 @@ CAResult_t CALEClientAddScanDeviceToList(JNIEnv *env, jobject device)
     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;
     }
 
@@ -2802,7 +2802,7 @@ CAResult_t CALEClientAddScanDeviceToList(JNIEnv *env, jobject device)
     {
         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;
     }
 
@@ -2810,13 +2810,13 @@ CAResult_t CALEClientAddScanDeviceToList(JNIEnv *env, jobject device)
     {
         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;
 }
@@ -2878,12 +2878,12 @@ CAResult_t CALEClientRemoveAllScanDevices(JNIEnv *env)
     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;
     }
 
@@ -2903,7 +2903,7 @@ CAResult_t CALEClientRemoveAllScanDevices(JNIEnv *env)
     OICFree(g_deviceList);
     g_deviceList = NULL;
 
-    ca_mutex_unlock(g_deviceListMutex);
+    oc_mutex_unlock(g_deviceListMutex);
     return CA_STATUS_OK;
 }
 
@@ -2913,12 +2913,12 @@ CAResult_t CALEClientRemoveDeviceInScanDeviceList(JNIEnv *env, jstring address)
     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;
     }
 
@@ -2929,7 +2929,7 @@ CAResult_t CALEClientRemoveDeviceInScanDeviceList(JNIEnv *env, jstring address)
         if (!jarrayObj)
         {
             OIC_LOG(ERROR, TAG, "jarrayObj is null");
-            ca_mutex_unlock(g_deviceListMutex);
+            oc_mutex_unlock(g_deviceListMutex);
             return CA_STATUS_FAILED;
         }
 
@@ -2937,7 +2937,7 @@ CAResult_t CALEClientRemoveDeviceInScanDeviceList(JNIEnv *env, jstring address)
         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;
         }
 
@@ -2945,7 +2945,7 @@ CAResult_t CALEClientRemoveDeviceInScanDeviceList(JNIEnv *env, jstring address)
         if (!setAddress)
         {
             OIC_LOG(ERROR, TAG, "setAddress is null");
-            ca_mutex_unlock(g_deviceListMutex);
+            oc_mutex_unlock(g_deviceListMutex);
             return CA_STATUS_FAILED;
         }
 
@@ -2954,7 +2954,7 @@ CAResult_t CALEClientRemoveDeviceInScanDeviceList(JNIEnv *env, jstring address)
         {
             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;
         }
 
@@ -2969,17 +2969,17 @@ CAResult_t CALEClientRemoveDeviceInScanDeviceList(JNIEnv *env, jstring address)
             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;
@@ -2995,12 +2995,12 @@ CAResult_t CALEClientAddGattobjToList(JNIEnv *env, jobject gatt)
     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;
     }
 
@@ -3008,7 +3008,7 @@ CAResult_t CALEClientAddGattobjToList(JNIEnv *env, jobject gatt)
     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;
     }
 
@@ -3016,7 +3016,7 @@ CAResult_t CALEClientAddGattobjToList(JNIEnv *env, jobject gatt)
     if (!remoteAddress)
     {
         OIC_LOG(ERROR, TAG, "remoteAddress is null");
-        ca_mutex_unlock(g_gattObjectMutex);
+        oc_mutex_unlock(g_gattObjectMutex);
         return CA_STATUS_FAILED;
     }
 
@@ -3029,7 +3029,7 @@ CAResult_t CALEClientAddGattobjToList(JNIEnv *env, jobject gatt)
     }
 
     (*env)->ReleaseStringUTFChars(env, jni_remoteAddress, remoteAddress);
-    ca_mutex_unlock(g_gattObjectMutex);
+    oc_mutex_unlock(g_gattObjectMutex);
     return CA_STATUS_OK;
 }
 
@@ -3087,7 +3087,7 @@ jobject CALEClientGetGattObjInList(JNIEnv *env, const char* remoteAddress)
     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++)
     {
@@ -3095,7 +3095,7 @@ jobject CALEClientGetGattObjInList(JNIEnv *env, const char* remoteAddress)
         if (!jarrayObj)
         {
             OIC_LOG(ERROR, TAG, "jarrayObj is null");
-            ca_mutex_unlock(g_gattObjectMutex);
+            oc_mutex_unlock(g_gattObjectMutex);
             return NULL;
         }
 
@@ -3103,7 +3103,7 @@ jobject CALEClientGetGattObjInList(JNIEnv *env, const char* remoteAddress)
         if (!jni_setAddress)
         {
             OIC_LOG(ERROR, TAG, "jni_setAddress is null");
-            ca_mutex_unlock(g_gattObjectMutex);
+            oc_mutex_unlock(g_gattObjectMutex);
             return NULL;
         }
 
@@ -3111,7 +3111,7 @@ jobject CALEClientGetGattObjInList(JNIEnv *env, const char* remoteAddress)
         if (!setAddress)
         {
             OIC_LOG(ERROR, TAG, "setAddress is null");
-            ca_mutex_unlock(g_gattObjectMutex);
+            oc_mutex_unlock(g_gattObjectMutex);
             return NULL;
         }
 
@@ -3119,13 +3119,13 @@ jobject CALEClientGetGattObjInList(JNIEnv *env, const char* remoteAddress)
         {
             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;
 }
@@ -3135,11 +3135,11 @@ CAResult_t CALEClientRemoveAllGattObjs(JNIEnv *env)
     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;
     }
 
@@ -3159,7 +3159,7 @@ CAResult_t CALEClientRemoveAllGattObjs(JNIEnv *env)
     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;
 }
 
@@ -3169,11 +3169,11 @@ CAResult_t CALEClientRemoveGattObj(JNIEnv *env, jobject gatt)
     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;
     }
 
@@ -3184,7 +3184,7 @@ CAResult_t CALEClientRemoveGattObj(JNIEnv *env, jobject gatt)
         if (!jarrayObj)
         {
             OIC_LOG(ERROR, TAG, "jarrayObj is null");
-            ca_mutex_unlock(g_gattObjectMutex);
+            oc_mutex_unlock(g_gattObjectMutex);
             return CA_STATUS_FAILED;
         }
 
@@ -3192,7 +3192,7 @@ CAResult_t CALEClientRemoveGattObj(JNIEnv *env, jobject gatt)
         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;
         }
 
@@ -3200,7 +3200,7 @@ CAResult_t CALEClientRemoveGattObj(JNIEnv *env, jobject gatt)
         if (!setAddress)
         {
             OIC_LOG(ERROR, TAG, "setAddress is null");
-            ca_mutex_unlock(g_gattObjectMutex);
+            oc_mutex_unlock(g_gattObjectMutex);
             return CA_STATUS_FAILED;
         }
 
@@ -3209,7 +3209,7 @@ CAResult_t CALEClientRemoveGattObj(JNIEnv *env, jobject gatt)
         {
             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;
         }
 
@@ -3218,7 +3218,7 @@ CAResult_t CALEClientRemoveGattObj(JNIEnv *env, jobject gatt)
         {
             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;
         }
 
@@ -3233,17 +3233,17 @@ CAResult_t CALEClientRemoveGattObj(JNIEnv *env, jobject gatt)
             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;
 }
@@ -3254,11 +3254,11 @@ CAResult_t CALEClientRemoveGattObjForAddr(JNIEnv *env, jstring addr)
     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;
     }
 
@@ -3269,7 +3269,7 @@ CAResult_t CALEClientRemoveGattObjForAddr(JNIEnv *env, jstring addr)
         if (!jarrayObj)
         {
             OIC_LOG(ERROR, TAG, "jarrayObj is null");
-            ca_mutex_unlock(g_gattObjectMutex);
+            oc_mutex_unlock(g_gattObjectMutex);
             return CA_STATUS_FAILED;
         }
 
@@ -3277,7 +3277,7 @@ CAResult_t CALEClientRemoveGattObjForAddr(JNIEnv *env, jstring addr)
         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;
         }
 
@@ -3285,7 +3285,7 @@ CAResult_t CALEClientRemoveGattObjForAddr(JNIEnv *env, jstring addr)
         if (!setAddress)
         {
             OIC_LOG(ERROR, TAG, "setAddress is null");
-            ca_mutex_unlock(g_gattObjectMutex);
+            oc_mutex_unlock(g_gattObjectMutex);
             return CA_STATUS_FAILED;
         }
 
@@ -3294,7 +3294,7 @@ CAResult_t CALEClientRemoveGattObjForAddr(JNIEnv *env, jstring addr)
         {
             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;
         }
 
@@ -3308,17 +3308,17 @@ CAResult_t CALEClientRemoveGattObjForAddr(JNIEnv *env, jstring addr)
             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;
 }
@@ -3355,7 +3355,7 @@ jstring CALEClientGetLEAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice)
         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);
@@ -3366,7 +3366,7 @@ jstring CALEClientGetLEAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice)
         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;
@@ -3375,7 +3375,7 @@ jstring CALEClientGetLEAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice)
         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;
@@ -3384,7 +3384,7 @@ jstring CALEClientGetLEAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice)
         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;
@@ -3393,7 +3393,7 @@ jstring CALEClientGetLEAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice)
         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;
@@ -3410,7 +3410,7 @@ jstring CALEClientGetLEAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice)
             {
                 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);
@@ -3421,7 +3421,7 @@ jstring CALEClientGetLEAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice)
         (*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);
@@ -3445,7 +3445,7 @@ CAResult_t CALEClientUpdateDeviceState(const char* address, uint16_t state_type,
         return CA_STATUS_FAILED;
     }
 
-    ca_mutex_lock(g_deviceStateListMutex);
+    oc_mutex_lock(g_deviceStateListMutex);
 
     if (CALEClientIsDeviceInList(address))
     {
@@ -3453,7 +3453,7 @@ CAResult_t CALEClientUpdateDeviceState(const char* address, uint16_t state_type,
         if(!curState)
         {
             OIC_LOG(ERROR, TAG, "curState is null");
-            ca_mutex_unlock(g_deviceStateListMutex);
+            oc_mutex_unlock(g_deviceStateListMutex);
             return CA_STATUS_FAILED;
         }
 
@@ -3477,7 +3477,7 @@ CAResult_t CALEClientUpdateDeviceState(const char* address, uint16_t state_type,
         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;
         }
 
@@ -3485,7 +3485,7 @@ CAResult_t CALEClientUpdateDeviceState(const char* address, uint16_t state_type,
         if (!newstate)
         {
             OIC_LOG(ERROR, TAG, "out of memory");
-            ca_mutex_unlock(g_deviceStateListMutex);
+            oc_mutex_unlock(g_deviceStateListMutex);
             return CA_MEMORY_ALLOC_FAILED;
         }
 
@@ -3510,7 +3510,7 @@ CAResult_t CALEClientUpdateDeviceState(const char* address, uint16_t state_type,
                   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;
 }
@@ -3554,11 +3554,11 @@ CAResult_t CALEClientRemoveAllDeviceState()
 {
     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;
     }
 
@@ -3576,7 +3576,7 @@ CAResult_t CALEClientRemoveAllDeviceState()
 
     OICFree(g_deviceStateList);
     g_deviceStateList = NULL;
-    ca_mutex_unlock(g_deviceStateListMutex);
+    oc_mutex_unlock(g_deviceStateListMutex);
 
     return CA_STATUS_OK;
 }
@@ -3585,11 +3585,11 @@ CAResult_t CALEClientResetDeviceStateForAll()
 {
     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;
     }
 
@@ -3608,7 +3608,7 @@ CAResult_t CALEClientResetDeviceStateForAll()
         state->connectedState = STATE_DISCONNECTED;
         state->sendState = STATE_SEND_NONE;
     }
-    ca_mutex_unlock(g_deviceStateListMutex);
+    oc_mutex_unlock(g_deviceStateListMutex);
 
     return CA_STATUS_OK;
 }
@@ -3697,11 +3697,11 @@ bool CALEClientIsValidState(const char* remoteAddress, uint16_t state_type,
               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;
     }
 
@@ -3709,7 +3709,7 @@ bool CALEClientIsValidState(const char* remoteAddress, uint16_t state_type,
     if (NULL == state)
     {
         OIC_LOG(ERROR, TAG, "state is null");
-        ca_mutex_unlock(g_deviceStateListMutex);
+        oc_mutex_unlock(g_deviceStateListMutex);
         return false;
     }
 
@@ -3728,16 +3728,16 @@ bool CALEClientIsValidState(const char* remoteAddress, uint16_t state_type,
 
     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;
 }
 
@@ -3777,7 +3777,7 @@ void CALEClientUpdateSendCnt(JNIEnv *env)
 
     VERIFY_NON_NULL_VOID(env, TAG, "env is null");
     // mutex lock
-    ca_mutex_lock(g_threadMutex);
+    oc_mutex_lock(g_threadMutex);
 
     g_currentSentCnt++;
 
@@ -3792,133 +3792,133 @@ void CALEClientUpdateSendCnt(JNIEnv *env)
             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;
         }
     }
@@ -3928,34 +3928,34 @@ CAResult_t CALEClientInitGattMutexVaraibles()
 
 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;
 }
 
@@ -3963,9 +3963,9 @@ void CALEClientSetSendFinishFlag(bool flag)
 {
     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);
 }
 
 /**
@@ -3977,22 +3977,22 @@ CAResult_t CAStartLEGattClient()
     // 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();
@@ -4040,32 +4040,32 @@ void CAStopLEGattClient()
 
     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;
@@ -4121,9 +4121,9 @@ CAResult_t CAUpdateCharacteristicsToAllGattServers(const uint8_t *data, uint32_t
 
 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)
@@ -4443,10 +4443,10 @@ Java_org_iotivity_ca_CaLeClientInterface_caLeGattCharacteristicWriteCallback(
         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);
@@ -4475,11 +4475,11 @@ Java_org_iotivity_ca_CaLeClientInterface_caLeGattCharacteristicWriteCallback(
             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);
@@ -4546,9 +4546,9 @@ Java_org_iotivity_ca_CaLeClientInterface_caLeGattCharacteristicChangedCallback(
               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);
 }
index f4e7f1e..694e651 100644 (file)
@@ -57,14 +57,14 @@ static CALEConnectionStateChangedCallback g_bleConnectionStateChangedCallback =
  * @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()
@@ -111,21 +111,21 @@ CAResult_t CAInitLENwkMonitorMutexVaraibles()
     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;
         }
     }
@@ -138,10 +138,10 @@ void CATerminateLENwkMonitorMutexVaraibles()
 {
     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");
@@ -227,9 +227,9 @@ CAResult_t CASetLEAdapterStateChangedCb(CALEDeviceStateChangedCallback callback)
 
     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;
@@ -244,9 +244,9 @@ CAResult_t CAUnSetLEAdapterStateChangedCb()
 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;
 }
@@ -254,9 +254,9 @@ CAResult_t CASetLENWConnectionStateChangedCb(CALEConnectionStateChangedCallback
 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;
 }
index c4d7fce..4f0cafc 100644 (file)
@@ -59,13 +59,13 @@ static jbyteArray g_sendBuffer = NULL;
 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;
@@ -333,21 +333,21 @@ CAResult_t CALEServerSendResponseData(JNIEnv *env, jobject device, jobject respo
     }
 
     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;
 }
@@ -1309,11 +1309,11 @@ CAResult_t CALEServerDisconnectAllDevices(JNIEnv *env)
     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;
     }
 
@@ -1336,7 +1336,7 @@ CAResult_t CALEServerDisconnectAllDevices(JNIEnv *env)
         }
     }
 
-    ca_mutex_unlock(g_connectedDeviceListMutex);
+    oc_mutex_unlock(g_connectedDeviceListMutex);
     OIC_LOG(DEBUG, TAG, "OUT - CALEServerDisconnectAllDevices");
     return CA_STATUS_OK;
 }
@@ -1480,7 +1480,7 @@ CAResult_t CALEServerInitialize()
         return ret;
     }
 
-    g_threadSendNotifyCond = ca_cond_new();
+    g_threadSendNotifyCond = oc_cond_new();
 
     ret = CALEServerInitMutexVaraibles();
     if (CA_STATUS_OK != ret)
@@ -1557,7 +1557,7 @@ void CALEServerTerminate()
         g_bluetoothManager = NULL;
     }
 
-    ca_cond_free(g_threadSendNotifyCond);
+    oc_cond_free(g_threadSendNotifyCond);
     g_threadSendNotifyCond = NULL;
 
     CALEServerTerminateMutexVaraibles();
@@ -1794,7 +1794,7 @@ CAResult_t CALEServerSendUnicastMessageImpl(JNIEnv *env, const char* address, co
         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++)
@@ -1868,7 +1868,7 @@ CAResult_t CALEServerSendUnicastMessageImpl(JNIEnv *env, const char* address, co
         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;
 
@@ -1885,7 +1885,7 @@ error_exit:
         g_obj_bluetoothDevice = NULL;
     }
 
-    ca_mutex_unlock(g_threadSendMutex);
+    oc_mutex_unlock(g_threadSendMutex);
     return CA_SEND_FAILED;
 }
 
@@ -1901,7 +1901,7 @@ CAResult_t CALEServerSendMulticastMessageImpl(JNIEnv *env, const uint8_t *data,
         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)
@@ -1975,20 +1975,20 @@ CAResult_t CALEServerSendMulticastMessageImpl(JNIEnv *env, const uint8_t *data,
         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)
@@ -2050,12 +2050,12 @@ CAResult_t CALEServerAddDeviceToList(JNIEnv *env, jobject device)
     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;
     }
 
@@ -2063,7 +2063,7 @@ CAResult_t CALEServerAddDeviceToList(JNIEnv *env, jobject device)
     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;
     }
 
@@ -2071,7 +2071,7 @@ CAResult_t CALEServerAddDeviceToList(JNIEnv *env, jobject device)
     if (!remoteAddress)
     {
         OIC_LOG(ERROR, TAG, "remoteAddress is null");
-        ca_mutex_unlock(g_connectedDeviceListMutex);
+        oc_mutex_unlock(g_connectedDeviceListMutex);
         return CA_STATUS_FAILED;
     }
 
@@ -2083,7 +2083,7 @@ CAResult_t CALEServerAddDeviceToList(JNIEnv *env, jobject device)
     }
 
     (*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;
 }
@@ -2093,11 +2093,11 @@ CAResult_t CALEServerRemoveAllDevices(JNIEnv *env)
     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;
     }
 
@@ -2113,7 +2113,7 @@ CAResult_t CALEServerRemoveAllDevices(JNIEnv *env)
 
     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;
@@ -2125,11 +2125,11 @@ CAResult_t CALEServerRemoveDevice(JNIEnv *env, jstring address)
     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;
     }
 
@@ -2173,10 +2173,10 @@ CAResult_t CALEServerRemoveDevice(JNIEnv *env, jstring address)
                 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);
@@ -2184,7 +2184,7 @@ CAResult_t CALEServerRemoveDevice(JNIEnv *env, jstring address)
         }
     }
 
-    ca_mutex_unlock(g_connectedDeviceListMutex);
+    oc_mutex_unlock(g_connectedDeviceListMutex);
 
     OIC_LOG(DEBUG, TAG, "there are no device in the device list");
 
@@ -2353,11 +2353,11 @@ Java_org_iotivity_ca_CaLeServerInterface_caLeGattServerCharacteristicWriteReques
 
     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);
 }
@@ -2391,10 +2391,10 @@ Java_org_iotivity_ca_CaLeServerInterface_caLeGattServerNotificationSentCallback(
                 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;
         }
     }
@@ -2409,11 +2409,11 @@ Java_org_iotivity_ca_CaLeServerInterface_caLeGattServerNotificationSentCallback(
         }
 
         // 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);
     }
 
 }
@@ -2542,9 +2542,9 @@ CAResult_t CAStopLEGattServer()
         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;
 
@@ -2570,9 +2570,9 @@ void CATerminateLEGattServer()
 
 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)
@@ -2616,50 +2616,50 @@ CAResult_t CALEServerInitMutexVaraibles()
 {
     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;
         }
     }
@@ -2669,19 +2669,19 @@ CAResult_t CALEServerInitMutexVaraibles()
 
 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;
 }
 
index bb78b74..abce764 100644 (file)
@@ -97,19 +97,19 @@ static CABLEAdapter_t g_adapterType = ADAPTER_EMPTY;
  * 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.
@@ -119,28 +119,28 @@ static ca_thread_pool_t g_bleAdapterThreadPool = NULL;
 /**
  * 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
@@ -449,7 +449,7 @@ static void CALEDataDestroyer(void *data, uint32_t size);
  * @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);
 
 /**
@@ -497,13 +497,13 @@ static CAResult_t CAInitLEServerQueues()
 {
     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;
     }
 
@@ -511,7 +511,7 @@ static CAResult_t CAInitLEServerQueues()
     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;
     }
 
@@ -520,13 +520,13 @@ static CAResult_t CAInitLEServerQueues()
     {
         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;
@@ -536,13 +536,13 @@ static CAResult_t CAInitLEClientQueues()
 {
     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;
     }
 
@@ -550,7 +550,7 @@ static CAResult_t CAInitLEClientQueues()
     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;
     }
 
@@ -559,13 +559,13 @@ static CAResult_t CAInitLEClientQueues()
     {
         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;
@@ -704,12 +704,12 @@ static void CAStopLEQueues()
 {
     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");
 }
@@ -781,7 +781,7 @@ static void CALEDataReceiverHandler(void *threadData)
 {
     OIC_LOG(DEBUG, CALEADAPTER_TAG, "IN - CALEDataReceiverHandler");
 
-    ca_mutex_lock(g_bleReceiveDataMutex);
+    oc_mutex_lock(g_bleReceiveDataMutex);
 
     if (g_dataBleReceiverHandlerState)
     {
@@ -791,21 +791,21 @@ static void CALEDataReceiverHandler(void *threadData)
         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;
         }
 
@@ -828,7 +828,7 @@ static void CALEDataReceiverHandler(void *threadData)
             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;
         }
 
@@ -866,7 +866,7 @@ static void CALEDataReceiverHandler(void *threadData)
             else
             {
                 OIC_LOG(ERROR, CALEADAPTER_TAG, "This packet is wrong packet! ignore.");
-                ca_mutex_unlock(g_bleReceiveDataMutex);
+                oc_mutex_unlock(g_bleReceiveDataMutex);
                 return;
             }
 
@@ -874,7 +874,7 @@ static void CALEDataReceiverHandler(void *threadData)
             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;
@@ -890,7 +890,7 @@ static void CALEDataReceiverHandler(void *threadData)
             {
                 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;
             }
 
@@ -908,7 +908,7 @@ static void CALEDataReceiverHandler(void *threadData)
             {
                 OIC_LOG(ERROR, CALEADAPTER_TAG, "defragData is NULL!");
                 OICFree(newSender);
-                ca_mutex_unlock(g_bleReceiveDataMutex);
+                oc_mutex_unlock(g_bleReceiveDataMutex);
                 return;
             }
 
@@ -923,7 +923,7 @@ static void CALEDataReceiverHandler(void *threadData)
                 OIC_LOG(ERROR, CALEADAPTER_TAG, "remoteEndpoint is NULL!");
                 OICFree(newSender->defragData);
                 OICFree(newSender);
-                ca_mutex_unlock(g_bleReceiveDataMutex);
+                oc_mutex_unlock(g_bleReceiveDataMutex);
                 return;
             }
 
@@ -933,7 +933,7 @@ static void CALEDataReceiverHandler(void *threadData)
                 OICFree(newSender->defragData);
                 CAFreeEndpoint(newSender->remoteEndpoint);
                 OICFree(newSender);
-                ca_mutex_unlock(g_bleReceiveDataMutex);
+                oc_mutex_unlock(g_bleReceiveDataMutex);
                 return;
             }
             memcpy(newSender->defragData,
@@ -954,7 +954,7 @@ static void CALEDataReceiverHandler(void *threadData)
                 OICFree(newSender->defragData);
                 CAFreeEndpoint(newSender->remoteEndpoint);
                 OICFree(newSender);
-                ca_mutex_unlock(g_bleReceiveDataMutex);
+                oc_mutex_unlock(g_bleReceiveDataMutex);
                 return;
             }
             senderInfo = newSender;
@@ -970,7 +970,7 @@ static void CALEDataReceiverHandler(void *threadData)
                 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]",
@@ -985,7 +985,7 @@ static void CALEDataReceiverHandler(void *threadData)
 
         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!");
@@ -993,8 +993,8 @@ static void CALEDataReceiverHandler(void *threadData)
                 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;
             }
 
@@ -1008,14 +1008,14 @@ static void CALEDataReceiverHandler(void *threadData)
             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");
 }
 
@@ -2025,20 +2025,20 @@ static CAResult_t CAInitLEAdapterMutex()
 
     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;
         }
@@ -2046,10 +2046,10 @@ static CAResult_t CAInitLEAdapterMutex()
 
     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;
         }
@@ -2057,10 +2057,10 @@ static CAResult_t CAInitLEAdapterMutex()
 
     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;
         }
@@ -2068,10 +2068,10 @@ static CAResult_t CAInitLEAdapterMutex()
 
     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;
         }
@@ -2079,10 +2079,10 @@ static CAResult_t CAInitLEAdapterMutex()
 
     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;
         }
@@ -2090,10 +2090,10 @@ static CAResult_t CAInitLEAdapterMutex()
 
     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;
         }
@@ -2101,10 +2101,10 @@ static CAResult_t CAInitLEAdapterMutex()
 
     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;
         }
     }
@@ -2117,28 +2117,28 @@ static void CATerminateLEAdapterMutex()
 {
     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");
@@ -2356,9 +2356,9 @@ static CAResult_t CALEAdapterGattServerStart()
     */
     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)
         {
@@ -2379,12 +2379,12 @@ static CAResult_t CALEAdapterGattServerStop()
     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
@@ -2405,9 +2405,9 @@ static CAResult_t CALEAdapterGattClientStart()
     */
     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)
         {
@@ -2427,9 +2427,9 @@ static CAResult_t CALEAdapterGattClientStop()
     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
@@ -2534,7 +2534,7 @@ static CAResult_t CAStopLE()
     CAStopLEQueues();
 #endif
 
-    ca_mutex_lock(g_bleIsServerMutex);
+    oc_mutex_lock(g_bleIsServerMutex);
     switch (g_adapterType)
     {
         case ADAPTER_SERVER:
@@ -2550,7 +2550,7 @@ static CAResult_t CAStopLE()
         default:
             break;
     }
-    ca_mutex_unlock(g_bleIsServerMutex);
+    oc_mutex_unlock(g_bleIsServerMutex);
 
     OIC_LOG(DEBUG, CALEADAPTER_TAG, "OUT");
 
@@ -2567,7 +2567,7 @@ static void CATerminateLE()
     CASetLEReqRespAdapterCallback(NULL);
     CATerminateLENetworkMonitor();
 
-    ca_mutex_lock(g_bleIsServerMutex);
+    oc_mutex_lock(g_bleIsServerMutex);
     switch (g_adapterType)
     {
         case ADAPTER_SERVER:
@@ -2584,7 +2584,7 @@ static void CATerminateLE()
             break;
     }
     g_adapterType = ADAPTER_EMPTY;
-    ca_mutex_unlock(g_bleIsServerMutex);
+    oc_mutex_unlock(g_bleIsServerMutex);
 
 #ifndef SINGLE_THREAD
     CATerminateLEQueues();
@@ -2608,7 +2608,7 @@ static CAResult_t CAStartLEListeningServer()
     }
 #endif
 
-    ca_mutex_lock(g_bleIsServerMutex);
+    oc_mutex_lock(g_bleIsServerMutex);
     switch (g_adapterType)
     {
         case ADAPTER_CLIENT:
@@ -2619,7 +2619,7 @@ static CAResult_t CAStartLEListeningServer()
         default:
             g_adapterType = ADAPTER_SERVER;
     }
-    ca_mutex_unlock(g_bleIsServerMutex);
+    oc_mutex_unlock(g_bleIsServerMutex);
 
     result = CAGetLEAdapterState();
     if (CA_STATUS_OK != result)
@@ -2665,7 +2665,7 @@ static CAResult_t CAStartLEDiscoveryServer()
     }
 #endif
 
-    ca_mutex_lock(g_bleIsServerMutex);
+    oc_mutex_lock(g_bleIsServerMutex);
     switch (g_adapterType)
     {
         case ADAPTER_SERVER:
@@ -2676,7 +2676,7 @@ static CAResult_t CAStartLEDiscoveryServer()
         default:
             g_adapterType = ADAPTER_CLIENT;
     }
-    ca_mutex_unlock(g_bleIsServerMutex);
+    oc_mutex_unlock(g_bleIsServerMutex);
 
     result = CAGetLEAdapterState();
     if (CA_STATUS_OK != result)
@@ -2727,14 +2727,14 @@ static int32_t CASendLEUnicastData(const CAEndpoint_t *endpoint,
         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)
             {
@@ -2752,7 +2752,7 @@ static int32_t CASendLEUnicastData(const CAEndpoint_t *endpoint,
         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)
@@ -2762,7 +2762,7 @@ static int32_t CASendLEUnicastData(const CAEndpoint_t *endpoint,
             return -1;
         }
     }
-    ca_mutex_unlock(g_bleIsServerMutex);
+    oc_mutex_unlock(g_bleIsServerMutex);
 
     OIC_LOG(DEBUG, CALEADAPTER_TAG, "OUT");
     return dataLen;
@@ -2792,14 +2792,14 @@ static int32_t CASendLEMulticastData(const CAEndpoint_t *endpoint,
         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" );
 
@@ -2818,7 +2818,7 @@ static int32_t CASendLEMulticastData(const CAEndpoint_t *endpoint,
         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" );
 
@@ -2829,7 +2829,7 @@ static int32_t CASendLEMulticastData(const CAEndpoint_t *endpoint,
             return -1;
         }
     }
-    ca_mutex_unlock(g_bleIsServerMutex);
+    oc_mutex_unlock(g_bleIsServerMutex);
 
     OIC_LOG(DEBUG, CALEADAPTER_TAG, "OUT - CASendLEMulticastData");
     return dataLen;
@@ -2877,9 +2877,9 @@ static CAResult_t CAGetLEInterfaceInformation(CAEndpoint_t **info, uint32_t *siz
     }
 
     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;
@@ -2894,10 +2894,10 @@ static CAResult_t CALERegisterNetworkNotifications(CAAdapterChangeCallback netCa
 {
     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)
     {
@@ -2938,7 +2938,7 @@ static void CALEConnectionStateChangedCb(CATransportAdapter_t adapter, const cha
     (void)adapter;
 
 #ifdef __TIZEN__
-    ca_mutex_lock(g_bleIsServerMutex);
+    oc_mutex_lock(g_bleIsServerMutex);
     switch (g_adapterType)
     {
         case ADAPTER_SERVER:
@@ -2954,7 +2954,7 @@ static void CALEConnectionStateChangedCb(CATransportAdapter_t adapter, const cha
         default:
             break;
     }
-    ca_mutex_unlock(g_bleIsServerMutex);
+    oc_mutex_unlock(g_bleIsServerMutex);
 #endif
 
     if(!isConnected)
@@ -2990,12 +2990,12 @@ static void CALEConnectionStateChangedCb(CATransportAdapter_t adapter, const cha
     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");
 }
@@ -3006,7 +3006,7 @@ static void CALEDeviceStateChangedCb(CAAdapterState_t adapter_state)
 
     if (CA_ADAPTER_ENABLED == adapter_state)
     {
-        ca_mutex_lock(g_bleIsServerMutex);
+        oc_mutex_lock(g_bleIsServerMutex);
         switch (g_adapterType)
         {
             case ADAPTER_SERVER:
@@ -3022,11 +3022,11 @@ static void CALEDeviceStateChangedCb(CAAdapterState_t adapter_state)
             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:
@@ -3042,10 +3042,10 @@ static void CALEDeviceStateChangedCb(CAAdapterState_t adapter_state)
             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);
@@ -3054,7 +3054,7 @@ static void CALEDeviceStateChangedCb(CAAdapterState_t 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");
 }
@@ -3087,9 +3087,9 @@ static CAResult_t CALEAdapterClientSendData(const CAEndpoint_t *remoteEndpoint,
         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;
@@ -3139,11 +3139,11 @@ static CAResult_t CALEAdapterServerSendData(const CAEndpoint_t *remoteEndpoint,
     }
 
     // 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;
@@ -3277,9 +3277,9 @@ static void CASetLEAdapterThreadPoolHandle(ca_thread_pool_t handle)
 {
     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");
 }
@@ -3288,11 +3288,11 @@ static void CASetLEReqRespAdapterCallback(CANetworkPacketReceivedCallback callba
 {
     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");
 }
@@ -3320,7 +3320,7 @@ static void CALEErrorHandler(const char *remoteAddress,
 }
 
 #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");
@@ -3328,7 +3328,7 @@ static void CALERemoveSendQueueData(CAQueueingThread_t *queueHandle, ca_mutex mu
     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");
@@ -3355,7 +3355,7 @@ static void CALERemoveSendQueueData(CAQueueingThread_t *queueHandle, ca_mutex mu
             }
         }
     }
-    ca_mutex_unlock(mutex);
+    oc_mutex_unlock(mutex);
 }
 
 static void CALERemoveReceiveQueueData(u_arraylist_t *dataInfoList, const char* address)
index 57aa4eb..ce3417f 100644 (file)
@@ -55,13 +55,13 @@ static bool CALESetUpBlueZObjects(CALEContext * context);
 
 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
@@ -206,7 +206,7 @@ static void CALEHandleInterfaceAdded(GList ** proxy_list,
         return;
     }
 
-    ca_mutex_lock(g_context.lock);
+    oc_mutex_lock(g_context.lock);
 
     /*
       Add the object information to the list.
@@ -217,7 +217,7 @@ static void CALEHandleInterfaceAdded(GList ** proxy_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
@@ -230,7 +230,7 @@ static void CALEHandleInterfaceAdded(GList ** proxy_list,
      */
     if (strcmp(interface, BLUEZ_DEVICE_INTERFACE) == 0)
     {
-        ca_cond_signal(g_context.condition);
+        oc_cond_signal(g_context.condition);
     }
 }
 
@@ -329,7 +329,7 @@ static void CALEOnInterfacesRemoved(GDBusConnection * connection,
         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))
         {
@@ -352,7 +352,7 @@ static void CALEOnInterfacesRemoved(GDBusConnection * connection,
             }
         }
 
-        ca_mutex_unlock(g_context.lock);
+        oc_mutex_unlock(g_context.lock);
 
         g_variant_unref(child);
     }
@@ -405,12 +405,12 @@ static void CALESubscribeToSignals(CALEContext * context,
                      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)
@@ -471,10 +471,10 @@ 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);
 
@@ -490,7 +490,7 @@ static void CALETearDownDBus(CALEContext * 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;
@@ -513,7 +513,7 @@ static void CALETearDownDBus(CALEContext * context)
     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);
@@ -599,9 +599,9 @@ static bool CALESetUpBlueZObjects(CALEContext * context)
         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
@@ -617,9 +617,9 @@ static bool CALESetUpBlueZObjects(CALEContext * context)
     // 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);
     }
 
     /*
@@ -635,9 +635,9 @@ static bool CALESetUpBlueZObjects(CALEContext * context)
     // 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;
@@ -677,12 +677,12 @@ static void CALEStartEventLoop(void * data)
     */
     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
@@ -714,12 +714,12 @@ static void CALEStartEventLoop(void * data)
 
 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)
     {
@@ -749,13 +749,13 @@ static bool CALEWaitForNonEmptyList(GList * const * list,
 {
     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
@@ -765,7 +765,7 @@ static bool CALEWaitForNonEmptyList(GList * const * list,
         }
     }
 
-    ca_mutex_unlock(g_context.lock);
+    oc_mutex_unlock(g_context.lock);
 
     return success;
 }
@@ -882,7 +882,7 @@ CAResult_t CAGetLEAdapterState()
 {
     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)
     {
@@ -912,7 +912,7 @@ CAResult_t CAGetLEAdapterState()
         }
     }
 
-    ca_mutex_unlock(g_context.lock);
+    oc_mutex_unlock(g_context.lock);
 
     return result;
 }
@@ -928,8 +928,8 @@ CAResult_t CAInitializeLENetworkMonitor()
      * @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
@@ -968,7 +968,7 @@ void CATerminateLENetworkMonitor()
 
     (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;
@@ -978,21 +978,21 @@ void CATerminateLENetworkMonitor()
     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;
 }
@@ -1054,7 +1054,7 @@ CAResult_t CAGetLEAddress(char **local_address)
 
     *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)
     {
@@ -1098,7 +1098,7 @@ CAResult_t CAGetLEAddress(char **local_address)
         break;
     }
 
-    ca_mutex_unlock(g_context.lock);
+    oc_mutex_unlock(g_context.lock);
 
     return *local_address != NULL ? CA_STATUS_OK : CA_STATUS_FAILED;
 }
@@ -1128,9 +1128,9 @@ void CATerminateLEGattServer()
 
 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,
@@ -1157,9 +1157,9 @@ CAResult_t CAStartLEGattClient()
         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)
     {
@@ -1265,44 +1265,44 @@ CAResult_t CAUpdateCharacteristicsToAllGattServers(uint8_t const * data,
 
 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);
 }
index 874e3a2..39daf5e 100644 (file)
@@ -254,7 +254,7 @@ static void CACentralDisconnect(CALEContext * context)
 {
     assert(context != NULL);
 
-    ca_mutex_lock(context->lock);
+    oc_mutex_lock(context->lock);
 
     for (GList * l = context->devices; l != NULL; l = l->next)
     {
@@ -280,7 +280,7 @@ static void CACentralDisconnect(CALEContext * context)
         }
     }
 
-    ca_mutex_unlock(context->lock);
+    oc_mutex_unlock(context->lock);
 }
 
 // -----------------------------------------------------------------------
@@ -295,7 +295,7 @@ CAResult_t CACentralStart(CALEContext * context)
       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.
@@ -309,7 +309,7 @@ CAResult_t CACentralStart(CALEContext * context)
                    CACentralStartDiscoveryImpl,
                    &result);
 
-    ca_mutex_unlock(context->lock);
+    oc_mutex_unlock(context->lock);
 
     return result;
 }
@@ -343,14 +343,14 @@ CAResult_t CACentralStartDiscovery(CALEContext * context)
       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;
 }
@@ -365,7 +365,7 @@ CAResult_t CACentralStopDiscovery(CALEContext * context)
       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,
@@ -376,7 +376,7 @@ CAResult_t CACentralStopDiscovery(CALEContext * context)
      * @todo Stop notifications on all response characteristics.
      */
 
-    ca_mutex_unlock(context->lock);
+    oc_mutex_unlock(context->lock);
 
     return result;
 }
@@ -431,14 +431,14 @@ bool CACentralConnectToAll(CALEContext * context)
 {
     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;
 }
index 5972837..ea30505 100644 (file)
@@ -336,9 +336,9 @@ bool CAGattRequestCharacteristicInitialize(struct CAGattService * s,
         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;
index 2888c7b..299f54e 100644 (file)
@@ -70,7 +70,7 @@ typedef struct _CAGattClientContext
     GHashTable * address_map;
 
     /// Mutex used to synchronize access to context fields.
-    ca_mutex lock;
+    oc_mutex lock;
 
 } CAGattClientContext;
 
@@ -108,7 +108,7 @@ static void CAGattClientOnCharacteristicPropertiesChanged(
     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);
@@ -145,7 +145,7 @@ static void CAGattClientOnCharacteristicPropertiesChanged(
         }
     }
 
-    ca_mutex_unlock(g_context.lock);
+    oc_mutex_unlock(g_context.lock);
 }
 
 // ---------------------------------------------------------------------
@@ -483,7 +483,7 @@ static void CAGattClientOnDevicePropertiesChanged(
     {
         CALEContext * const context = user_data;
 
-        ca_mutex_lock(g_context.lock);
+        oc_mutex_lock(g_context.lock);
 
         CAGattClientSetupService(device,
                                  g_context.characteristic_map,
@@ -491,7 +491,7 @@ static void CAGattClientOnDevicePropertiesChanged(
                                  services_prop,
                                  context);
 
-        ca_mutex_unlock(g_context.lock);
+        oc_mutex_unlock(g_context.lock);
 
         g_variant_unref(services_prop);
     }
@@ -499,7 +499,7 @@ static void CAGattClientOnDevicePropertiesChanged(
 
 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
@@ -521,7 +521,7 @@ CAResult_t CAGattClientInitialize(CALEContext * context)
                               OICFree,
                               OICFree);
 
-    ca_mutex_lock(context->lock);
+    oc_mutex_lock(context->lock);
 
     for (GList * l = context->devices; l != NULL; l = l->next)
     {
@@ -545,14 +545,14 @@ CAResult_t CAGattClientInitialize(CALEContext * context)
                                  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;
 }
@@ -564,7 +564,7 @@ void CAGattClientDestroy()
         return;  // Initialization did not complete.
     }
 
-    ca_mutex_lock(g_context.lock);
+    oc_mutex_lock(g_context.lock);
 
     if (g_context.characteristic_map != NULL)
     {
@@ -578,9 +578,9 @@ void CAGattClientDestroy()
         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;
 
     /*
@@ -636,7 +636,7 @@ static CAResult_t CAGattClientSendDataImpl(GDBusProxy * characteristic,
 
         g_error_free(error);
 
-        ca_mutex_lock(context->lock);
+        oc_mutex_lock(context->lock);
 
         if (context->on_client_error != NULL)
         {
@@ -650,7 +650,7 @@ static CAResult_t CAGattClientSendDataImpl(GDBusProxy * characteristic,
                                      CA_STATUS_FAILED);
         }
 
-        ca_mutex_unlock(context->lock);
+        oc_mutex_unlock(context->lock);
 
         return CA_STATUS_FAILED;
     }
@@ -669,7 +669,7 @@ CAResult_t CAGattClientSendData(char const * address,
 
     CAResult_t result = CA_STATUS_FAILED;
 
-    ca_mutex_lock(g_context.lock);
+    oc_mutex_lock(g_context.lock);
 
     GDBusProxy * const characteristic =
         G_DBUS_PROXY(
@@ -691,7 +691,7 @@ CAResult_t CAGattClientSendData(char const * address,
                                       length,
                                       context);
 
-    ca_mutex_unlock(g_context.lock);
+    oc_mutex_unlock(g_context.lock);
 
     return result;
 }
@@ -704,12 +704,12 @@ CAResult_t CAGattClientSendDataToAll(uint8_t const * data,
 
     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;
     }
 
@@ -737,7 +737,7 @@ CAResult_t CAGattClientSendDataToAll(uint8_t const * data,
         }
     }
 
-    ca_mutex_unlock(g_context.lock);
+    oc_mutex_unlock(g_context.lock);
 
     return result;
 }
index 64f6b0e..2e734af 100644 (file)
@@ -149,7 +149,7 @@ typedef struct _CALEContext
     CABLEErrorHandleCallback on_server_error;
 
     /// Mutex used to synchronize access to context fields.
-    ca_mutex lock;
+    oc_mutex lock;
 
     /**
      * BlueZ adapter list initialization condition variable.
@@ -163,7 +163,7 @@ typedef struct _CALEContext
      *
      * @see @c GMainLoop documentation for further details.
      */
-    ca_cond condition;
+    oc_cond condition;
 
     /**
      * Semaphore that indicates completed start of the LE transport.
index 9966198..cd29611 100644 (file)
@@ -39,13 +39,13 @@ static CAPeripheralContext g_context = {
 
 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
@@ -59,11 +59,11 @@ static bool CAPeripheralCheckStarted()
 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)
     {
@@ -162,7 +162,7 @@ static bool CAPeripheralRegisterGattServices(
 
     bool success = true;
 
-    ca_mutex_lock(context->lock);
+    oc_mutex_lock(context->lock);
 
     for (GList * l = context->gatt_services; l != NULL; l = l->next)
     {
@@ -209,7 +209,7 @@ static bool CAPeripheralRegisterGattServices(
         g_variant_unref(ret);
     }
 
-    ca_mutex_unlock(context->lock);
+    oc_mutex_unlock(context->lock);
 
     return success;
 }
@@ -224,7 +224,7 @@ static bool CAPeripheralRegisterAdvertisements(
       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(
@@ -310,7 +310,7 @@ static bool CAPeripheralRegisterAdvertisements(
         success = true;
     }
 
-    ca_mutex_unlock(context->lock);
+    oc_mutex_unlock(context->lock);
 
     return success;
 }
@@ -383,14 +383,14 @@ static CAResult_t CAPeripheralSetDiscoverability(
       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;
 }
@@ -447,9 +447,9 @@ static void CAPeripheralOnNameLost(GDBusConnection * connection,
  */
 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;
 }
@@ -515,7 +515,7 @@ static void CAPeripheralStartEventLoop(void * data)
                 "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;
@@ -542,7 +542,7 @@ static void CAPeripheralStartEventLoop(void * data)
                                 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
@@ -571,12 +571,12 @@ static void CAPeripheralStartEventLoop(void * data)
 
 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)
     {
@@ -596,14 +596,14 @@ static void CAPeripheralStopEventLoop(CAPeripheralContext * context)
 
 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)
@@ -653,21 +653,21 @@ 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)
     {
@@ -718,7 +718,7 @@ CAResult_t CAPeripheralStop()
 
     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;
@@ -728,7 +728,7 @@ CAResult_t CAPeripheralStop()
 
     g_context.base = NULL;
 
-    ca_mutex_unlock(g_context.lock);
+    oc_mutex_unlock(g_context.lock);
 
     CALEAdvertisementDestroy(&g_context.advertisement);
 
@@ -741,9 +741,9 @@ CAResult_t CAPeripheralStop()
 
 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);
 }
index 419edb4..2333cb9 100644 (file)
@@ -78,7 +78,7 @@ typedef struct _CAPeripheralContext
     GMainLoop * event_loop;
 
     /// Mutex used to synchronize access to context fields.
-    ca_mutex lock;
+    oc_mutex lock;
 
     /**
      * Service registration condition variable.
@@ -90,7 +90,7 @@ typedef struct _CAPeripheralContext
      *
      * @see @c GMainLoop documentation for further details.
      */
-    ca_cond condition;
+    oc_cond condition;
 
 } CAPeripheralContext;
 
index c50ba1b..921fbd6 100644 (file)
@@ -51,7 +51,7 @@ bool CAGattRecv(CAGattRecvInfo * info,
 {
     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,
@@ -59,7 +59,7 @@ bool CAGattRecv(CAGattRecvInfo * info,
                                  length,
                                  &sent_length) == CA_STATUS_OK;
 
-    ca_mutex_unlock(info->context->lock);
+    oc_mutex_unlock(info->context->lock);
 
     return success && length == sent_length;
 }
index ac0f8f3..50148bd 100644 (file)
@@ -44,11 +44,11 @@ bool CAGetBlueZManagedObjectProxies(GList ** proxies,
     */
     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;
     }
 
@@ -84,7 +84,7 @@ bool CAGetBlueZManagedObjectProxies(GList ** proxies,
         }
     }
 
-    ca_mutex_unlock(context->lock);
+    oc_mutex_unlock(context->lock);
 
     return success;
 }
index 1bd32c6..dc33e14 100644 (file)
@@ -61,7 +61,7 @@ static u_arraylist_t *g_multicastDataList = NULL;
 /**
  * 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.
@@ -71,17 +71,17 @@ static u_arraylist_t *g_deviceDiscoveredList = NULL;
 /**
  * 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.
@@ -91,7 +91,7 @@ static LEServerInfoList *g_LEServerList = NULL;
 /**
  * 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.
@@ -102,34 +102,34 @@ static bool g_isLEGattClientStarted = false;
  * 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.
@@ -164,7 +164,7 @@ bool CALEIsDeviceDiscovered(const char * address)
     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++)
         {
@@ -172,12 +172,12 @@ bool CALEIsDeviceDiscovered(const char * address)
             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;
@@ -190,11 +190,11 @@ void CALEGattCharacteristicChangedCb(bt_gatt_h characteristic,
     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;
     }
 
@@ -203,7 +203,7 @@ void CALEGattCharacteristicChangedCb(bt_gatt_h characteristic,
 
     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");
 }
@@ -219,11 +219,11 @@ void CALEGattCharacteristicWriteCb(int result, bt_gatt_h reqHandle, void *userDa
     }
     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 ");
@@ -242,14 +242,14 @@ void CALEGattConnectionStateChanged(bool connected, const char *remoteAddress)
         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
     {
@@ -262,12 +262,12 @@ void CALEGattConnectionStateChanged(bool connected, const char *remoteAddress)
             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;
         }
 
@@ -278,7 +278,7 @@ void CALEGattConnectionStateChanged(bool connected, const char *remoteAddress)
             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");
 }
@@ -308,7 +308,7 @@ void CALEAdapterScanResultCb(int result, bt_adapter_le_device_scan_result_info_s
     // 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)
     {
@@ -319,12 +319,12 @@ void CALEAdapterScanResultCb(int result, bt_adapter_le_device_scan_result_info_s
     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);
 
@@ -336,12 +336,12 @@ void CALEAdapterScanResultCb(int result, bt_adapter_le_device_scan_result_info_s
     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;
     }
 
@@ -352,7 +352,7 @@ void CALEAdapterScanResultCb(int result, bt_adapter_le_device_scan_result_info_s
                   "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");
 }
 
@@ -360,9 +360,9 @@ void CASetLEClientThreadPoolHandle(ca_thread_pool_t handle)
 {
     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");
 }
@@ -371,11 +371,11 @@ void CASetLEReqRespClientCallback(CABLEDataReceivedCallback callback)
 {
     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");
 }
@@ -389,11 +389,11 @@ CAResult_t CAStartLEGattClient()
 {
     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;
     }
 
@@ -401,20 +401,20 @@ CAResult_t CAStartLEGattClient()
     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;
     }
 
@@ -424,10 +424,10 @@ CAResult_t CAStartLEGattClient()
     {
         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;
@@ -438,19 +438,19 @@ void CAStartTimerThread(void *data)
     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.
@@ -460,14 +460,14 @@ void CAStartTimerThread(void *data)
             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");
@@ -477,12 +477,12 @@ void CAStopLEGattClient()
 {
     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;
     }
 
@@ -493,34 +493,34 @@ void CAStopLEGattClient()
     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();
 
@@ -543,7 +543,7 @@ void CAStopLEGattClient()
         OIC_LOG(ERROR, TAG, "g_eventLoop context is NULL");
     }
 
-    ca_mutex_unlock(g_LEClientStateMutex);
+    oc_mutex_unlock(g_LEClientStateMutex);
 
     OIC_LOG(DEBUG,  TAG, "OUT");
 }
@@ -575,110 +575,110 @@ CAResult_t CAInitGattClientMutexVariables()
     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;
         }
     }
@@ -691,37 +691,37 @@ void CATerminateGattClientMutexVariables()
 {
     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;
 
@@ -812,14 +812,14 @@ CAResult_t CALEGattConnect(const char *remoteAddress)
     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;
     }
 
@@ -832,7 +832,7 @@ CAResult_t CALEGattConnect(const char *remoteAddress)
         {
             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;
         }
     }
@@ -844,17 +844,17 @@ CAResult_t CALEGattConnect(const char *remoteAddress)
         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;
         }
 
@@ -865,9 +865,9 @@ CAResult_t CALEGattConnect(const char *remoteAddress)
             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;
@@ -1004,7 +1004,7 @@ CAResult_t CALEGattDiscoverServices(const char *remoteAddress)
     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)
     {
@@ -1013,12 +1013,12 @@ CAResult_t CALEGattDiscoverServices(const char *remoteAddress)
         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++)
         {
@@ -1031,7 +1031,7 @@ CAResult_t CALEGattDiscoverServices(const char *remoteAddress)
             CAUpdateCharacteristicsToGattServer(remoteAddress, multicastData->data,
                                                 multicastData->dataLen, LE_UNICAST, 0);
         }
-        ca_mutex_unlock(g_multicastDataListMutex);
+        oc_mutex_unlock(g_multicastDataListMutex);
     }
 
     OIC_LOG(DEBUG, TAG, "OUT");
@@ -1055,7 +1055,7 @@ CAResult_t  CAUpdateCharacteristicsToGattServer(const char *remoteAddress,
     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);
@@ -1064,7 +1064,7 @@ CAResult_t  CAUpdateCharacteristicsToGattServer(const char *remoteAddress,
     {
         ret = CAGetLEServerInfoByPosition(g_LEServerList, position, &leServerInfo);
     }
-    ca_mutex_unlock(g_LEServerListMutex);
+    oc_mutex_unlock(g_LEServerListMutex);
 
     if (CA_STATUS_OK != ret)
     {
@@ -1099,23 +1099,23 @@ CAResult_t  CAUpdateCharacteristicsToGattServer(const char *remoteAddress,
 
     // 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;
@@ -1167,13 +1167,13 @@ CAResult_t CAUpdateCharacteristicsToAllGattServers(const uint8_t *data, uint32_t
     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();
@@ -1184,7 +1184,7 @@ CAResult_t CAUpdateCharacteristicsToAllGattServers(const uint8_t *data, uint32_t
     }
 
     // Start the timer by signalling it.
-    ca_cond_signal(g_startTimerCond);
+    oc_cond_signal(g_startTimerCond);
 
 exit:
     OIC_LOG(DEBUG, TAG, "OUT ");
index 3cd83c1..9fde840 100644 (file)
@@ -57,13 +57,13 @@ static CALEConnectionStateChangedCallback g_bleConnectionStateChangedCallback =
  * 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.
@@ -96,21 +96,21 @@ CAResult_t CAInitializeLENetworkMonitor()
 
     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;
         }
     }
@@ -124,10 +124,10 @@ void CATerminateLENetworkMonitor()
 {
     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");
@@ -243,9 +243,9 @@ CAResult_t CAGetLEAddress(char **local_address)
 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;
 }
@@ -253,9 +253,9 @@ CAResult_t CASetLEAdapterStateChangedCb(CALEDeviceStateChangedCallback callback)
 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;
 }
@@ -263,9 +263,9 @@ CAResult_t CAUnSetLEAdapterStateChangedCb()
 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;
 }
@@ -273,9 +273,9 @@ CAResult_t CASetLENWConnectionStateChangedCb(CALEConnectionStateChangedCallback
 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;
 }
@@ -285,12 +285,12 @@ void CALEAdapterStateChangedCb(int result, bt_adapter_state_e adapter_state,
 {
     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;
     }
 
@@ -298,7 +298,7 @@ void CALEAdapterStateChangedCb(int result, bt_adapter_state_e adapter_state,
     {
         OIC_LOG(DEBUG, TAG, "Adapter is disabled");
         g_bleDeviceStateChangedCallback(CA_ADAPTER_DISABLED);
-        ca_mutex_unlock(g_bleDeviceStateChangedCbMutex);
+        oc_mutex_unlock(g_bleDeviceStateChangedCbMutex);
         return;
     }
 
@@ -312,7 +312,7 @@ void CALEAdapterStateChangedCb(int result, bt_adapter_state_e adapter_state,
     }
 
     g_bleDeviceStateChangedCallback(CA_ADAPTER_ENABLED);
-    ca_mutex_unlock(g_bleDeviceStateChangedCbMutex);
+    oc_mutex_unlock(g_bleDeviceStateChangedCbMutex);
 
     OIC_LOG(DEBUG, TAG, "OUT");
 }
@@ -324,17 +324,17 @@ void CALENWConnectionStateChangedCb(int result, bool connected,
 
     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");
 }
index 2da8660..fdf2e0a 100644 (file)
@@ -82,28 +82,28 @@ static bool g_isLEGattServerStarted = false;
 /**
  * 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.
@@ -123,7 +123,7 @@ static LEClientInfoList *g_LEClientList = NULL;
 /**
  * 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)
 {
@@ -133,23 +133,23 @@ void CALEGattServerConnectionStateChanged(bool connected, const char *remoteAddr
     {
         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);
     }
 }
 
@@ -163,11 +163,11 @@ CAResult_t CAStartLEGattServer()
 {
     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;
     }
 
@@ -175,7 +175,7 @@ CAResult_t CAStartLEGattServer()
     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;
     }
@@ -186,7 +186,7 @@ CAResult_t CAStartLEGattServer()
     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;
     }
@@ -200,7 +200,7 @@ CAResult_t CAStartLEGattServer()
     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;
     }
@@ -214,7 +214,7 @@ CAResult_t CAStartLEGattServer()
     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;
     }
@@ -223,7 +223,7 @@ CAResult_t CAStartLEGattServer()
     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;
     }
@@ -232,14 +232,14 @@ CAResult_t CAStartLEGattServer()
     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;
@@ -332,21 +332,21 @@ CAResult_t CAStopLEGattServer()
 {
     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();
     {
@@ -380,7 +380,7 @@ CAResult_t CAStopLEGattServer()
         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;
@@ -406,18 +406,18 @@ void CATerminateLEGattServer()
     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();
@@ -429,60 +429,60 @@ CAResult_t CAInitGattServerMutexVariables()
     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;
         }
     }
@@ -494,22 +494,22 @@ CAResult_t CAInitGattServerMutexVariables()
 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");
@@ -579,9 +579,9 @@ CAResult_t CADeInitLEGattServer()
 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");
 }
 
@@ -595,16 +595,16 @@ CAResult_t CAAddNewLEServiceInGattServer(const char *serviceUUID)
 
     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)
     {
@@ -639,11 +639,11 @@ void CALEGattRemoteCharacteristicWriteCb(char *remoteAddress, bt_gatt_server_h s
 
     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;
     }
@@ -652,7 +652,7 @@ void CALEGattRemoteCharacteristicWriteCb(char *remoteAddress, bt_gatt_server_h s
     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");
 }
@@ -740,7 +740,7 @@ CAResult_t CAAddNewCharacteristicsToGattServer(const bt_gatt_h svcPath, const ch
         return CA_STATUS_FAILED;
     }
 
-    ca_mutex_lock(g_leCharacteristicMutex);
+    oc_mutex_lock(g_leCharacteristicMutex);
 
     if (read)
     {
@@ -752,7 +752,7 @@ CAResult_t CAAddNewCharacteristicsToGattServer(const bt_gatt_h svcPath, const ch
                                         &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));
@@ -762,7 +762,7 @@ CAResult_t CAAddNewCharacteristicsToGattServer(const bt_gatt_h svcPath, const ch
         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));
@@ -776,7 +776,7 @@ CAResult_t CAAddNewCharacteristicsToGattServer(const bt_gatt_h svcPath, const ch
         g_gattWriteCharPath = charPath;
     }
 
-    ca_mutex_unlock(g_leCharacteristicMutex);
+    oc_mutex_unlock(g_leCharacteristicMutex);
 
     OIC_LOG(DEBUG, TAG, "OUT");
     return CA_STATUS_OK;
@@ -792,12 +792,12 @@ CAResult_t CAUpdateCharacteristicsToGattClient(const char *address, const uint8_
 
     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;
     }
 
@@ -806,7 +806,7 @@ CAResult_t CAUpdateCharacteristicsToGattClient(const char *address, const uint8_
     {
         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;
     }
 
@@ -816,11 +816,11 @@ CAResult_t CAUpdateCharacteristicsToGattClient(const char *address, const uint8_
     {
         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;
@@ -832,12 +832,12 @@ CAResult_t CAUpdateCharacteristicsToAllGattClients(const uint8_t *charValue, uin
 
     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;
     }
 
@@ -845,7 +845,7 @@ CAResult_t CAUpdateCharacteristicsToAllGattClients(const uint8_t *charValue, uin
     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;
     }
 
@@ -855,11 +855,11 @@ CAResult_t CAUpdateCharacteristicsToAllGattClients(const uint8_t *charValue, uin
     {
         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;
@@ -869,9 +869,9 @@ void CASetLEReqRespServerCallback(CABLEDataReceivedCallback callback)
 {
     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");
 }
index 05dac1f..76f8ca4 100644 (file)
@@ -126,20 +126,20 @@ CAResult_t CAInitBlockWiseMutexVariables()
 {
     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;
         }
@@ -152,13 +152,13 @@ void CATerminateBlockWiseMutexVariables()
 {
     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;
     }
 }
@@ -266,9 +266,9 @@ CAResult_t CAAddSendThreadQueue(const CAData_t *sendData, const CABlockDataID_t
 
     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
     {
@@ -754,9 +754,9 @@ CAResult_t CASendErrorMessage(const coap_pdu_t *pdu, uint8_t status,
     // 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
     {
@@ -2230,7 +2230,7 @@ CAResult_t CAUpdateBlockOptionType(const CABlockDataID_t *blockID, uint8_t block
     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++)
@@ -2239,12 +2239,12 @@ CAResult_t CAUpdateBlockOptionType(const CABlockDataID_t *blockID, uint8_t block
         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;
@@ -2255,7 +2255,7 @@ uint8_t CAGetBlockOptionType(const CABlockDataID_t *blockID)
     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++)
@@ -2263,12 +2263,12 @@ uint8_t CAGetBlockOptionType(const CABlockDataID_t *blockID)
         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;
@@ -2278,7 +2278,7 @@ CAData_t *CAGetDataSetFromBlockDataList(const CABlockDataID_t *blockID)
 {
     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++)
@@ -2286,11 +2286,11 @@ CAData_t *CAGetDataSetFromBlockDataList(const CABlockDataID_t *blockID)
         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;
 }
@@ -2303,7 +2303,7 @@ CAResult_t CAGetTokenFromBlockDataList(const coap_pdu_t *pdu, const CAEndpoint_t
     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++)
@@ -2327,13 +2327,13 @@ CAResult_t CAGetTokenFromBlockDataList(const coap_pdu_t *pdu, const CAEndpoint_t
                     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;
                 }
@@ -2341,7 +2341,7 @@ CAResult_t CAGetTokenFromBlockDataList(const coap_pdu_t *pdu, const CAEndpoint_t
         }
     }
 
-    ca_mutex_unlock(g_context.blockDataListMutex);
+    oc_mutex_unlock(g_context.blockDataListMutex);
 
     OIC_LOG(DEBUG, TAG, "OUT-CAGetTokenFromBlockDataList");
     return CA_STATUS_FAILED;
@@ -2389,7 +2389,7 @@ CABlockData_t *CAGetBlockDataFromBlockDataList(const CABlockDataID_t *blockID)
 {
     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++)
@@ -2397,11 +2397,11 @@ CABlockData_t *CAGetBlockDataFromBlockDataList(const CABlockDataID_t *blockID)
         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;
 }
@@ -2411,7 +2411,7 @@ coap_block_t *CAGetBlockOption(const CABlockDataID_t *blockID, uint16_t blockTyp
     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++)
@@ -2419,7 +2419,7 @@ coap_block_t *CAGetBlockOption(const CABlockDataID_t *blockID, uint16_t blockTyp
         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)
             {
@@ -2431,7 +2431,7 @@ coap_block_t *CAGetBlockOption(const CABlockDataID_t *blockID, uint16_t blockTyp
             }
         }
     }
-    ca_mutex_unlock(g_context.blockDataListMutex);
+    oc_mutex_unlock(g_context.blockDataListMutex);
 
     OIC_LOG(DEBUG, TAG, "OUT-GetBlockOption");
     return NULL;
@@ -2444,7 +2444,7 @@ CAPayload_t CAGetPayloadFromBlockDataList(const CABlockDataID_t *blockID,
     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++)
@@ -2452,13 +2452,13 @@ CAPayload_t CAGetPayloadFromBlockDataList(const CABlockDataID_t *blockID,
         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;
@@ -2521,7 +2521,7 @@ CABlockData_t *CACreateNewBlockData(const CAData_t *sendData)
     }
     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)
@@ -2530,10 +2530,10 @@ CABlockData_t *CACreateNewBlockData(const CAData_t *sendData)
         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;
@@ -2544,7 +2544,7 @@ CAResult_t CARemoveBlockDataFromList(const CABlockDataID_t *blockID)
     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++)
@@ -2556,7 +2556,7 @@ CAResult_t CARemoveBlockDataFromList(const CABlockDataID_t *blockID)
             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;
             }
 
@@ -2565,11 +2565,11 @@ CAResult_t CARemoveBlockDataFromList(const CABlockDataID_t *blockID)
             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;
 }
@@ -2578,7 +2578,7 @@ CAResult_t CARemoveAllBlockDataFromList()
 {
     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--)
@@ -2596,7 +2596,7 @@ CAResult_t CARemoveAllBlockDataFromList()
             OICFree(removedData);
         }
     }
-    ca_mutex_unlock(g_context.blockDataListMutex);
+    oc_mutex_unlock(g_context.blockDataListMutex);
 
     return CA_STATUS_OK;
 }
index 18f8039..8d86b1d 100644 (file)
@@ -840,11 +840,11 @@ void CAHandleRequestResponseCallbacks()
     // #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)
     {
index e034161..1b4089d 100644 (file)
@@ -50,7 +50,7 @@ static void CAQueueingThreadBaseRoutine(void *threadValue)
     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)
@@ -58,7 +58,7 @@ static void CAQueueingThreadBaseRoutine(void *threadValue)
             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..");
         }
@@ -67,14 +67,14 @@ static void CAQueueingThreadBaseRoutine(void *threadValue)
         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;
@@ -96,9 +96,9 @@ static void CAQueueingThreadBaseRoutine(void *threadValue)
         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..");
 }
@@ -123,8 +123,8 @@ CAResult_t CAQueueingThreadInitialize(CAQueueingThread_t *thread, ca_thread_pool
     // 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;
@@ -143,12 +143,12 @@ ERROR_MEM_FAILURE:
     }
     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;
@@ -175,10 +175,10 @@ CAResult_t CAQueueingThreadStart(CAQueueingThread_t *thread)
     }
 
     // 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);
@@ -218,16 +218,16 @@ CAResult_t CAQueueingThreadAddData(CAQueueingThread_t *thread, void *data, uint3
     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;
 }
@@ -242,9 +242,9 @@ CAResult_t CAQueueingThreadDestroy(CAQueueingThread_t *thread)
 
     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)
@@ -286,18 +286,18 @@ CAResult_t CAQueueingThreadStop(CAQueueingThread_t *thread)
     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;
index 7101b4c..0d58a0d 100644 (file)
@@ -178,7 +178,7 @@ static void CACheckRetransmissionList(CARetransmission_t *context)
     }
 
     // mutex lock
-    ca_mutex_lock(context->threadMutex);
+    oc_mutex_lock(context->threadMutex);
 
     uint32_t i = 0;
     uint32_t len = u_arraylist_length(context->dataList);
@@ -218,7 +218,7 @@ static void CACheckRetransmissionList(CARetransmission_t *context)
             {
                 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,"
@@ -243,7 +243,7 @@ static void CACheckRetransmissionList(CARetransmission_t *context)
     }
 
     // mutex unlock
-    ca_mutex_unlock(context->threadMutex);
+    oc_mutex_unlock(context->threadMutex);
 }
 
 void CARetransmissionBaseRoutine(void *threadValue)
@@ -271,7 +271,7 @@ 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)
         {
@@ -279,7 +279,7 @@ void CARetransmissionBaseRoutine(void *threadValue)
             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..");
         }
@@ -291,7 +291,7 @@ void CARetransmissionBaseRoutine(void *threadValue)
 
             // 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
         {
@@ -299,7 +299,7 @@ void CARetransmissionBaseRoutine(void *threadValue)
         }
 
         // mutex unlock
-        ca_mutex_unlock(context->threadMutex);
+        oc_mutex_unlock(context->threadMutex);
 
         // check stop flag
         if (context->isStop)
@@ -310,9 +310,9 @@ void CARetransmissionBaseRoutine(void *threadValue)
         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");
@@ -351,8 +351,8 @@ CAResult_t CARetransmissionInitialize(CARetransmission_t *context,
 
     // 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;
@@ -435,7 +435,7 @@ CAResult_t CARetransmissionSentData(CARetransmission_t *context,
     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);
@@ -457,7 +457,7 @@ CAResult_t CARetransmissionSentData(CARetransmission_t *context,
             OIC_LOG(ERROR, TAG, "Duplicate message ID");
 
             // mutex unlock
-            ca_mutex_unlock(context->threadMutex);
+            oc_mutex_unlock(context->threadMutex);
 
             OICFree(retData);
             OICFree(pduData);
@@ -469,10 +469,10 @@ CAResult_t CARetransmissionSentData(CARetransmission_t *context,
     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);
@@ -516,7 +516,7 @@ CAResult_t CARetransmissionReceivedData(CARetransmission_t *context,
     }
 
     // mutex lock
-    ca_mutex_lock(context->threadMutex);
+    oc_mutex_lock(context->threadMutex);
     uint32_t len = u_arraylist_length(context->dataList);
 
     // find index
@@ -546,7 +546,7 @@ CAResult_t CARetransmissionReceivedData(CARetransmission_t *context,
                     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;
                 }
@@ -559,7 +559,7 @@ CAResult_t CARetransmissionReceivedData(CARetransmission_t *context,
                     OIC_LOG(ERROR, TAG, "memory error");
 
                     // mutex unlock
-                    ca_mutex_unlock(context->threadMutex);
+                    oc_mutex_unlock(context->threadMutex);
 
                     return CA_MEMORY_ALLOC_FAILED;
                 }
@@ -573,7 +573,7 @@ CAResult_t CARetransmissionReceivedData(CARetransmission_t *context,
                 OIC_LOG(ERROR, TAG, "Removed data is NULL");
 
                 // mutex unlock
-                ca_mutex_unlock(context->threadMutex);
+                oc_mutex_unlock(context->threadMutex);
 
                 return CA_STATUS_FAILED;
             }
@@ -589,7 +589,7 @@ CAResult_t CARetransmissionReceivedData(CARetransmission_t *context,
     }
 
     // mutex unlock
-    ca_mutex_unlock(context->threadMutex);
+    oc_mutex_unlock(context->threadMutex);
 
     OIC_LOG(DEBUG, TAG, "OUT");
     return CA_STATUS_OK;
@@ -606,18 +606,18 @@ CAResult_t CARetransmissionStop(CARetransmission_t *context)
     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;
 }
@@ -632,9 +632,9 @@ CAResult_t CARetransmissionDestroy(CARetransmission_t *context)
 
     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;
index d88659d..a839ab9 100644 (file)
@@ -50,7 +50,7 @@
 /**
  * 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.
@@ -68,10 +68,10 @@ static CAResult_t CAIPInitializeNetworkMonitorList()
 {
     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;
         }
     }
@@ -99,7 +99,7 @@ static void CAIPDestroyNetworkMonitorList()
 
     if (g_networkMonitorContextMutex)
     {
-        ca_mutex_free(g_networkMonitorContextMutex);
+        oc_mutex_free(g_networkMonitorContextMutex);
         g_networkMonitorContextMutex = NULL;
     }
 }
@@ -112,7 +112,7 @@ static bool CACmpNetworkList(uint32_t ifiindex)
         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++)
@@ -120,11 +120,11 @@ static bool CACmpNetworkList(uint32_t ifiindex)
         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;
 }
 
@@ -133,15 +133,15 @@ static CAResult_t CAAddNetworkMonitorList(CAInterface_t *ifitem)
     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;
 }
 
@@ -149,7 +149,7 @@ static void CARemoveNetworkMonitorList(int ifiindex)
 {
     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++)
@@ -161,13 +161,13 @@ static void CARemoveNetworkMonitorList(int ifiindex)
             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;
 }
 
index f521b51..11f56cb 100644 (file)
@@ -77,7 +77,7 @@ typedef struct
     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,
@@ -451,14 +451,14 @@ CAResult_t CAStartRA()
         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);
@@ -471,7 +471,7 @@ CAResult_t CAStartRA()
 
     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;
@@ -485,7 +485,7 @@ CAResult_t CAStopRA()
     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"));
@@ -516,11 +516,11 @@ int32_t CASendRAUnicastData(const CAEndpoint_t *remoteEndpoint, const void *data
     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;
     }
 
@@ -531,7 +531,7 @@ int32_t CASendRAUnicastData(const CAEndpoint_t *remoteEndpoint, const void *data
         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;
         }
     }
@@ -544,7 +544,7 @@ int32_t CASendRAUnicastData(const CAEndpoint_t *remoteEndpoint, const void *data
     }
     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!");
@@ -628,7 +628,7 @@ typedef struct
     char jabberID[CA_RAJABBERID_SIZE];
 } CARAXmppData_t;
 
-static ca_mutex g_raadapterMutex = NULL;
+static oc_mutex g_raadapterMutex = NULL;
 
 static CARAXmppData_t g_xmppData = {};
 
@@ -674,7 +674,7 @@ void CARAXmppConnectedCB(void * const param, xmpp_error_code_t result,
     {
         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;
@@ -692,7 +692,7 @@ void CARAXmppConnectedCB(void * const param, xmpp_error_code_t result,
         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);
 
@@ -704,13 +704,13 @@ void CARAXmppDisonnectedCB(void * const param, xmpp_error_code_t result,
 {
     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);
@@ -824,14 +824,14 @@ CAResult_t CAStartRA()
 
     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);
@@ -848,7 +848,7 @@ CAResult_t CAStartRA()
     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)
     {
@@ -875,7 +875,7 @@ CAResult_t CAStopRA()
 
     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"));
@@ -899,12 +899,12 @@ int32_t CASendRAUnicastData(const CAEndpoint_t *remoteEndpoint, const void *data
     }
 
     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;
     }
 
@@ -914,10 +914,10 @@ int32_t CASendRAUnicastData(const CAEndpoint_t *remoteEndpoint, const void *data
     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);
@@ -930,16 +930,16 @@ CAResult_t CAGetRAInterfaceInformation(CAEndpoint_t **info, uint32_t *size)
     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,
index 744bc18..3337ef0 100644 (file)
 /**
  * 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.
@@ -154,7 +154,7 @@ static void CATCPDestroyMutex()
 {
     if (g_mutexObjectList)
     {
-        ca_mutex_free(g_mutexObjectList);
+        oc_mutex_free(g_mutexObjectList);
         g_mutexObjectList = NULL;
     }
 }
@@ -163,7 +163,7 @@ static CAResult_t CATCPCreateMutex()
 {
     if (!g_mutexObjectList)
     {
-        g_mutexObjectList = ca_mutex_new();
+        g_mutexObjectList = oc_mutex_new();
         if (!g_mutexObjectList)
         {
             OIC_LOG(ERROR, TAG, "Failed to created mutex!");
@@ -178,7 +178,7 @@ static void CATCPDestroyCond()
 {
     if (g_condObjectList)
     {
-        ca_cond_free(g_condObjectList);
+        oc_cond_free(g_condObjectList);
         g_condObjectList = NULL;
     }
 }
@@ -187,7 +187,7 @@ static CAResult_t CATCPCreateCond()
 {
     if (!g_condObjectList)
     {
-        g_condObjectList = ca_cond_new();
+        g_condObjectList = oc_cond_new();
         if (!g_condObjectList)
         {
             OIC_LOG(ERROR, TAG, "Failed to created cond!");
@@ -207,9 +207,9 @@ static void CAReceiveHandler(void *data)
         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");
 }
@@ -345,17 +345,17 @@ static void CAAcceptConnection(CATransportFlags_t flag, CASocket_t *sock)
         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);
     }
@@ -850,12 +850,12 @@ CAResult_t CATCPStartServer(const ca_thread_pool_t threadPool)
         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)
     {
@@ -893,7 +893,7 @@ CAResult_t CATCPStartServer(const ca_thread_pool_t threadPool)
 void CATCPStopServer()
 {
     // mutex lock
-    ca_mutex_lock(g_mutexObjectList);
+    oc_mutex_lock(g_mutexObjectList);
 
     // set terminate flag
     caglobals.tcp.terminate = true;
@@ -911,12 +911,12 @@ void CATCPStopServer()
 
     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)
     {
@@ -1113,7 +1113,7 @@ CATCPSessionInfo_t *CAConnectTCPSession(const CAEndpoint_t *endpoint)
 
     // #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);
@@ -1122,11 +1122,11 @@ CATCPSessionInfo_t *CAConnectTCPSession(const CAEndpoint_t *endpoint)
             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);
 
@@ -1143,7 +1143,7 @@ CAResult_t CADisconnectTCPSession(CATCPSessionInfo_t *svritem, size_t index)
 {
     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)
@@ -1161,14 +1161,14 @@ CAResult_t CADisconnectTCPSession(CATCPSessionInfo_t *svritem, size_t index)
     }
 
     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;
@@ -1185,7 +1185,7 @@ void CATCPDisconnectAll()
         }
     }
     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)
@@ -1219,7 +1219,7 @@ CATCPSessionInfo_t *CAGetTCPSessionInfoFromEndpoint(const CAEndpoint_t *endpoint
 
 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;
@@ -1231,12 +1231,12 @@ CATCPSessionInfo_t *CAGetSessionInfoFromFD(int fd, size_t *index)
         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;
 }
index 9326586..d624af6 100644 (file)
@@ -102,18 +102,18 @@ uint64_t getAbsTime()
 
 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;
@@ -127,7 +127,7 @@ void mutexFunc(void *context)
     // 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);
@@ -135,7 +135,7 @@ void mutexFunc(void *context)
 
     pData->finished = true; // assignment guarded by lock
 
-    ca_mutex_unlock(pData->mutex);
+    oc_mutex_unlock(pData->mutex);
 }
 
 TEST(MutexTests, TC_03_THREAD_LOCKING)
@@ -146,13 +146,13 @@ 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
@@ -172,7 +172,7 @@ TEST(MutexTests, TC_03_THREAD_LOCKING)
 
         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)
@@ -180,12 +180,12 @@ TEST(MutexTests, TC_03_THREAD_LOCKING)
             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);
@@ -193,23 +193,23 @@ TEST(MutexTests, TC_03_THREAD_LOCKING)
 
 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;
@@ -220,15 +220,15 @@ void condFunc(void *context)
 
     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);
 }
@@ -245,8 +245,8 @@ TEST(ConditionTests, TC_02_SIGNAL)
 
     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 };
@@ -275,11 +275,11 @@ TEST(ConditionTests, TC_02_SIGNAL)
         // 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
@@ -303,15 +303,15 @@ TEST(ConditionTests, TC_02_SIGNAL)
         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)
@@ -327,10 +327,10 @@ TEST(ConditionTests, TC_02_SIGNAL)
 
         // 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);
 }
@@ -342,8 +342,8 @@ TEST(ConditionTests, TC_03_BROADCAST)
 
     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 };
@@ -374,10 +374,10 @@ TEST(ConditionTests, TC_03_BROADCAST)
 
         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)
@@ -393,10 +393,10 @@ TEST(ConditionTests, TC_03_BROADCAST)
 
         // Cleanup Everything
 
-        ca_mutex_free(sharedMutex);
+        oc_mutex_free(sharedMutex);
     }
 
-    ca_cond_free(sharedCond);
+    oc_cond_free(sharedCond);
 
     ca_thread_pool_free(mythreadpool);
 }
@@ -423,14 +423,14 @@ void timedFunc(void *context)
 
     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;
 
@@ -439,12 +439,12 @@ void timedFunc(void *context)
     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);
 }
@@ -456,8 +456,8 @@ TEST(ConditionTests, TC_05_WAIT)
 
     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 };
@@ -482,9 +482,9 @@ TEST(ConditionTests, TC_05_WAIT)
 
         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
@@ -498,10 +498,10 @@ TEST(ConditionTests, TC_05_WAIT)
 
         // Cleanup Everything
 
-        ca_mutex_free(sharedMutex);
+        oc_mutex_free(sharedMutex);
     }
 
-    ca_cond_free(sharedCond);
+    oc_cond_free(sharedCond);
 
     ca_thread_pool_free(mythreadpool);
 }
@@ -510,43 +510,43 @@ TEST(ConditionTests, TC_05_WAIT)
 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();
 
@@ -561,11 +561,11 @@ TEST(ConditionTests, TC_07_WAITDURATION)
     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);
 }
index 57a7e2f..161022e 100644 (file)
@@ -34,50 +34,50 @@ static const size_t MAX_RETRY_COUNT = 5;
 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;
         }
     }
@@ -89,27 +89,27 @@ void CAManagerTerminateLEAutoConnection()
 {
     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;
     }
 }
@@ -120,20 +120,20 @@ CAResult_t CAManagerStartAutoConnection(JNIEnv *env, jstring remote_le_address)
     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;
     }
 
@@ -147,9 +147,9 @@ CAResult_t CAManagerStartAutoConnection(JNIEnv *env, jstring remote_le_address)
         {
             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;
             }
@@ -161,7 +161,7 @@ CAResult_t CAManagerStartAutoConnection(JNIEnv *env, jstring remote_le_address)
             break;
         }
     }
-    ca_mutex_unlock(g_connectRetryMutex);
+    oc_mutex_unlock(g_connectRetryMutex);
     OIC_LOG(DEBUG, TAG, "OUT - CAManagerStartAutoConnection");
     return res;
 }
@@ -206,14 +206,14 @@ CAResult_t CAManagerProcessRecovery(JNIEnv *env, uint16_t adapter_state)
     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");
             }
@@ -240,7 +240,7 @@ CAResult_t CAManagerProcessRecovery(JNIEnv *env, uint16_t adapter_state)
             break;
     }
 
-    ca_mutex_unlock(g_recoveryMutex);
+    oc_mutex_unlock(g_recoveryMutex);
     OIC_LOG(DEBUG, TAG, "OUT - CAManagerProcessRecovery");
 
     return res;
index 44e41cd..cbdde51 100644 (file)
@@ -31,7 +31,7 @@
 #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)
@@ -66,13 +66,13 @@ void CAManagerCreateACDataList()
 {
     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()
@@ -90,10 +90,10 @@ CAResult_t CAManagerInitMutexVaraibles()
 {
     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;
         }
     }
@@ -104,7 +104,7 @@ void CAManagerTerminateMutexVariables()
 {
     if (g_deviceACDataListMutex)
     {
-        ca_mutex_free(g_deviceACDataListMutex);
+        oc_mutex_free(g_deviceACDataListMutex);
         g_deviceACDataListMutex = NULL;
     }
 }
@@ -134,13 +134,13 @@ bool CAManagerIsInACDataList(JNIEnv *env, jstring jaddress)
     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;
     }
 
@@ -153,7 +153,7 @@ bool CAManagerIsInACDataList(JNIEnv *env, jstring jaddress)
         {
             OIC_LOG(ERROR, TAG, "curData is null");
             (*env)->ReleaseStringUTFChars(env, jaddress, address);
-            ca_mutex_unlock(g_deviceACDataListMutex);
+            oc_mutex_unlock(g_deviceACDataListMutex);
             return false;
         }
 
@@ -162,7 +162,7 @@ bool CAManagerIsInACDataList(JNIEnv *env, jstring jaddress)
         {
             OIC_LOG(ERROR, TAG, "address is null");
             (*env)->ReleaseStringUTFChars(env, jaddress, address);
-            ca_mutex_unlock(g_deviceACDataListMutex);
+            oc_mutex_unlock(g_deviceACDataListMutex);
             return false;
         }
 
@@ -170,7 +170,7 @@ bool CAManagerIsInACDataList(JNIEnv *env, jstring jaddress)
         {
             (*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);
@@ -178,7 +178,7 @@ bool CAManagerIsInACDataList(JNIEnv *env, jstring jaddress)
 
     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;
 }
@@ -198,9 +198,9 @@ void CAManagerAddACData(JNIEnv *env, jstring jaddress)
 
         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
     {
@@ -216,13 +216,13 @@ CAResult_t CAManagerRemoveACData(JNIEnv *env, jstring jaddress)
     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;
     }
 
@@ -237,7 +237,7 @@ CAResult_t CAManagerRemoveACData(JNIEnv *env, jstring jaddress)
         {
             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;
         }
 
@@ -246,7 +246,7 @@ CAResult_t CAManagerRemoveACData(JNIEnv *env, jstring jaddress)
         {
             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;
         }
 
@@ -257,7 +257,7 @@ CAResult_t CAManagerRemoveACData(JNIEnv *env, jstring jaddress)
                 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;
             }
 
@@ -270,7 +270,7 @@ CAResult_t CAManagerRemoveACData(JNIEnv *env, jstring jaddress)
 
             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;
         }
@@ -279,7 +279,7 @@ CAResult_t CAManagerRemoveACData(JNIEnv *env, jstring jaddress)
 
     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;
 }
@@ -289,7 +289,7 @@ CAResult_t CAManagerRemoveAllACData(JNIEnv *env)
     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++)
@@ -299,14 +299,14 @@ CAResult_t CAManagerRemoveAllACData(JNIEnv *env)
         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;
         }
 
@@ -317,7 +317,7 @@ CAResult_t CAManagerRemoveAllACData(JNIEnv *env)
 
         OICFree(curData);
     }
-    ca_mutex_unlock(g_deviceACDataListMutex);
+    oc_mutex_unlock(g_deviceACDataListMutex);
     OIC_LOG(DEBUG, TAG, "OUT - CAManagerRemoveAllACData");
     return CA_STATUS_OK;
 }
@@ -328,13 +328,13 @@ CAResult_t CAManagerGetAutoConnectingFlag(JNIEnv *env, jstring jaddress, bool *f
     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;
     }
 
@@ -347,7 +347,7 @@ CAResult_t CAManagerGetAutoConnectingFlag(JNIEnv *env, jstring jaddress, bool *f
         {
             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;
         }
 
@@ -356,7 +356,7 @@ CAResult_t CAManagerGetAutoConnectingFlag(JNIEnv *env, jstring jaddress, bool *f
         {
             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;
         }
 
@@ -367,7 +367,7 @@ CAResult_t CAManagerGetAutoConnectingFlag(JNIEnv *env, jstring jaddress, bool *f
             *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);
@@ -375,7 +375,7 @@ CAResult_t CAManagerGetAutoConnectingFlag(JNIEnv *env, jstring jaddress, bool *f
 
     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;
 }
@@ -386,13 +386,13 @@ bool CAManagerSetAutoConnectingFlag(JNIEnv *env, jstring jaddress, bool flag)
     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;
     }
 
@@ -405,7 +405,7 @@ bool CAManagerSetAutoConnectingFlag(JNIEnv *env, jstring jaddress, bool flag)
         {
             OIC_LOG(ERROR, TAG, "curData is null");
             (*env)->ReleaseStringUTFChars(env, jaddress, address);
-            ca_mutex_unlock(g_deviceACDataListMutex);
+            oc_mutex_unlock(g_deviceACDataListMutex);
             return false;
         }
 
@@ -414,7 +414,7 @@ bool CAManagerSetAutoConnectingFlag(JNIEnv *env, jstring jaddress, bool flag)
         {
             OIC_LOG(ERROR, TAG, "address is null");
             (*env)->ReleaseStringUTFChars(env, jaddress, address);
-            ca_mutex_unlock(g_deviceACDataListMutex);
+            oc_mutex_unlock(g_deviceACDataListMutex);
             return false;
         }
 
@@ -425,7 +425,7 @@ bool CAManagerSetAutoConnectingFlag(JNIEnv *env, jstring jaddress, bool flag)
             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);
@@ -433,7 +433,7 @@ bool CAManagerSetAutoConnectingFlag(JNIEnv *env, jstring jaddress, bool flag)
 
     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;
 }
index d3a1aa0..78a5ea0 100644 (file)
@@ -59,8 +59,8 @@ static char *fname = DEFAULT_DB_FILE;
 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,
@@ -187,9 +187,9 @@ void unlockMenu(void *data)
 {
     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);
 }
 
 /**
@@ -261,8 +261,8 @@ static void userRequests()
     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)
     {
@@ -401,8 +401,8 @@ static void userRequests()
         }
             break;
         case EXIT:
-            ca_mutex_free(mutex);
-            ca_cond_free(cond);
+            oc_mutex_free(mutex);
+            oc_cond_free(cond);
             fExit = true;
             break;
         default:
@@ -413,9 +413,9 @@ static void userRequests()
         //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);
         }
     }
 }