projects
/
platform
/
upstream
/
iotivity.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git]
/
resource
/
csdk
/
connectivity
/
src
/
bt_le_adapter
/
linux
/
caleinterface.c
diff --git
a/resource/csdk/connectivity/src/bt_le_adapter/linux/caleinterface.c
b/resource/csdk/connectivity/src/bt_le_adapter/linux/caleinterface.c
index
57aa4eb
..
3647378
100644
(file)
--- a/
resource/csdk/connectivity/src/bt_le_adapter/linux/caleinterface.c
+++ b/
resource/csdk/connectivity/src/bt_le_adapter/linux/caleinterface.c
@@
-55,13
+55,13
@@
static bool CALESetUpBlueZObjects(CALEContext * context);
static bool CALECheckStarted()
{
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));
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
/**
* @todo Fix potential TOCTOU race condition. A LE transport
@@
-206,7
+206,7
@@
static void CALEHandleInterfaceAdded(GList ** proxy_list,
return;
}
return;
}
-
ca
_mutex_lock(g_context.lock);
+
oc
_mutex_lock(g_context.lock);
/*
Add the object information to the list.
/*
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);
*/
*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
/**
* 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)
{
*/
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);
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))
{
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);
}
g_variant_unref(child);
}
@@
-405,12
+405,12
@@
static void CALESubscribeToSignals(CALEContext * context,
G_CALLBACK(CALEOnInterfaceProxyPropertiesChanged),
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;
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)
}
static bool CALESetUpDBus(CALEContext * context)
@@
-471,10
+471,10
@@
static bool CALESetUpDBus(CALEContext * context)
CALESubscribeToSignals(context, connection, object_manager);
CALESubscribeToSignals(context, connection, object_manager);
-
ca
_mutex_lock(context->lock);
+
oc
_mutex_lock(context->lock);
context->connection = connection;
context->object_manager = object_manager;
context->connection = connection;
context->object_manager = object_manager;
-
ca
_mutex_unlock(context->lock);
+
oc
_mutex_unlock(context->lock);
success = CALESetUpBlueZObjects(context);
success = CALESetUpBlueZObjects(context);
@@
-490,7
+490,7
@@
static void CALETearDownDBus(CALEContext * context)
global state, and pushing resource finalization outside the global
lock.
*/
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;
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;
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);
// Destroy the device proxies list.
g_list_free_full(devices, g_object_unref);
@@
-599,9
+599,9
@@
static bool CALESetUpBlueZObjects(CALEContext * context)
return success;
}
return success;
}
-
ca
_mutex_lock(context->lock);
+
oc
_mutex_lock(context->lock);
context->objects = objects;
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
/*
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)
{
// An empty adapters list is NULL.
if (success && adapters != NULL)
{
-
ca
_mutex_lock(context->lock);
+
oc
_mutex_lock(context->lock);
context->adapters = adapters;
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)
{
// An empty device list is NULL.
if (success && devices != NULL)
{
-
ca
_mutex_lock(context->lock);
+
oc
_mutex_lock(context->lock);
context->devices = devices;
context->devices = devices;
-
ca
_mutex_unlock(context->lock);
+
oc
_mutex_unlock(context->lock);
}
return success;
}
return success;
@@
-677,12
+677,12
@@
static void CALEStartEventLoop(void * data)
*/
if (CALESetUpDBus(&g_context))
{
*/
if (CALESetUpDBus(&g_context))
{
-
ca
_mutex_lock(context->lock);
+
oc
_mutex_lock(context->lock);
assert(context->event_loop == NULL);
context->event_loop = event_loop;
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
/*
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)
{
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;
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)
{
if (event_loop != NULL)
{
@@
-749,13
+749,13
@@
static bool CALEWaitForNonEmptyList(GList * const * list,
{
bool success = false;
{
bool success = false;
-
ca
_mutex_lock(g_context.lock);
+
oc
_mutex_lock(g_context.lock);
for (int i = 0; *list == NULL && i < retries; ++i)
{
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,
g_context.lock,
- timeout) ==
CA
_WAIT_SUCCESS)
+ timeout) ==
OC
_WAIT_SUCCESS)
{
/*
Condition variable was signaled before the timeout was
{
/*
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;
}
return success;
}
@@
-822,7
+822,7
@@
CAResult_t CAStartLEAdapter()
*/
result = ca_thread_pool_add_task(g_context.client_thread_pool,
CALEStartEventLoop,
*/
result = ca_thread_pool_add_task(g_context.client_thread_pool,
CALEStartEventLoop,
- &g_context);
+ &g_context
, NULL
);
/*
Wait for the GLib event loop to actually run before returning.
/*
Wait for the GLib event loop to actually run before returning.
@@
-882,7
+882,7
@@
CAResult_t CAGetLEAdapterState()
{
CAResult_t result = CA_ADAPTER_NOT_ENABLED;
{
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)
{
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;
}
return result;
}
@@
-928,8
+928,8
@@
CAResult_t CAInitializeLENetworkMonitor()
* @see @c CAStartLEAdapter() for further details.
*/
* @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
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);
(void) sem_destroy(&g_context.le_started);
-
ca
_mutex_lock(g_context.lock);
+
oc
_mutex_lock(g_context.lock);
g_context.on_device_state_changed = NULL;
g_context.on_server_received_data = NULL;
g_context.on_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;
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;
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)
{
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;
g_context.on_device_state_changed = callback;
-
ca
_mutex_unlock(g_context.lock);
+
oc
_mutex_unlock(g_context.lock);
return CA_STATUS_OK;
}
return CA_STATUS_OK;
}
@@
-1003,6
+1003,11
@@
CAResult_t CASetLENWConnectionStateChangedCb(CALEConnectionStateChangedCallback
return CA_NOT_SUPPORTED;
}
return CA_NOT_SUPPORTED;
}
+CAResult_t CAUnSetLENWConnectionStateChangedCb()
+{
+ return CA_NOT_SUPPORTED;
+}
+
CAResult_t CAGetLEAddress(char **local_address)
{
OIC_LOG(DEBUG, TAG, "Get Linux BLE local device information.");
CAResult_t CAGetLEAddress(char **local_address)
{
OIC_LOG(DEBUG, TAG, "Get Linux BLE local device information.");
@@
-1054,7
+1059,7
@@
CAResult_t CAGetLEAddress(char **local_address)
*local_address = NULL;
*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)
{
for (GList * l = g_context.adapters; l != NULL; l = l->next)
{
@@
-1098,7
+1103,7
@@
CAResult_t CAGetLEAddress(char **local_address)
break;
}
break;
}
-
ca
_mutex_unlock(g_context.lock);
+
oc
_mutex_unlock(g_context.lock);
return *local_address != NULL ? CA_STATUS_OK : CA_STATUS_FAILED;
}
return *local_address != NULL ? CA_STATUS_OK : CA_STATUS_FAILED;
}
@@
-1128,9
+1133,9
@@
void CATerminateLEGattServer()
void CASetLEReqRespServerCallback(CABLEDataReceivedCallback callback)
{
void CASetLEReqRespServerCallback(CABLEDataReceivedCallback callback)
{
-
ca
_mutex_lock(g_context.lock);
+
oc
_mutex_lock(g_context.lock);
g_context.on_server_received_data = callback;
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,
}
CAResult_t CAUpdateCharacteristicsToGattClient(char const * address,
@@
-1157,9
+1162,9
@@
CAResult_t CAStartLEGattClient()
return result;
}
return result;
}
-
ca
_mutex_lock(g_context.lock);
+
oc
_mutex_lock(g_context.lock);
bool found_peripherals = (g_context.devices != NULL);
bool found_peripherals = (g_context.devices != NULL);
-
ca
_mutex_unlock(g_context.lock);
+
oc
_mutex_unlock(g_context.lock);
if (!found_peripherals)
{
if (!found_peripherals)
{
@@
-1265,44
+1270,44
@@
CAResult_t CAUpdateCharacteristicsToAllGattServers(uint8_t const * data,
void CASetLEReqRespClientCallback(CABLEDataReceivedCallback callback)
{
void CASetLEReqRespClientCallback(CABLEDataReceivedCallback callback)
{
-
ca
_mutex_lock(g_context.lock);
+
oc
_mutex_lock(g_context.lock);
g_context.on_client_received_data = callback;
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)
{
}
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;
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)
{
}
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;
g_context.client_thread_pool = handle;
-
ca
_mutex_unlock(g_context.lock);
+
oc
_mutex_unlock(g_context.lock);
}
CAResult_t CAUnSetLEAdapterStateChangedCb()
{
}
CAResult_t CAUnSetLEAdapterStateChangedCb()
{
-
ca
_mutex_lock(g_context.lock);
+
oc
_mutex_lock(g_context.lock);
g_context.on_device_state_changed = NULL;
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)
{
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;
g_context.on_client_error = callback;
-
ca
_mutex_unlock(g_context.lock);
+
oc
_mutex_unlock(g_context.lock);
}
void CASetBLEServerErrorHandleCallback(CABLEErrorHandleCallback callback)
{
}
void CASetBLEServerErrorHandleCallback(CABLEErrorHandleCallback callback)
{
-
ca
_mutex_lock(g_context.lock);
+
oc
_mutex_lock(g_context.lock);
g_context.on_server_error = callback;
g_context.on_server_error = callback;
-
ca
_mutex_unlock(g_context.lock);
+
oc
_mutex_unlock(g_context.lock);
}
}