X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Fcsdk%2Fconnectivity%2Fsrc%2Fbt_edr_adapter%2Ftizen%2Fcaedrutils.c;h=72df325fcfa2729e90e7ebc706cd72b3ff012c43;hb=390866079e285d2c74918432c0d597d5da52f8a0;hp=70073ae56be2e90d07352d8647d924bceceb9acf;hpb=3e9402ad71cb3e93266a77796f44d17bab9853fd;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/csdk/connectivity/src/bt_edr_adapter/tizen/caedrutils.c b/resource/csdk/connectivity/src/bt_edr_adapter/tizen/caedrutils.c index 70073ae..72df325 100644 --- a/resource/csdk/connectivity/src/bt_edr_adapter/tizen/caedrutils.c +++ b/resource/csdk/connectivity/src/bt_edr_adapter/tizen/caedrutils.c @@ -29,6 +29,12 @@ #include #include "logger.h" +#include "uarraylist.h" + +/** + * Pending devices list for data transfer. + */ +static u_arraylist_t *g_deviceStateList = NULL; bool CAEDRIsServiceSupported(const char **serviceUUID, int32_t serviceCount, const char *matchService) @@ -54,5 +60,69 @@ bool CAEDRIsServiceSupported(const char **serviceUUID, int32_t serviceCount, return false; } +CAConnectedDeviceInfo_t *CAEDRGetDeviceInfoFromAddress(const char *remoteAddress) +{ + OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "CAEDRGetDeviceInfoFromAddress"); + if (!remoteAddress) + { + OIC_LOG(ERROR, EDR_ADAPTER_TAG, "remoteAddress is null"); + return NULL; + } + + uint32_t length = u_arraylist_length(g_deviceStateList); + for (uint32_t index = 0; index < length; index++) + { + CAConnectedDeviceInfo_t* deviceInfo = + (CAConnectedDeviceInfo_t*) u_arraylist_get(g_deviceStateList, index); + if (!deviceInfo) + { + OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "deviceInfo object is null"); + continue; + } + + if (!strcmp((const char*) deviceInfo->address, remoteAddress)) + { + return deviceInfo; + } + } + return NULL; +} + +CAResult_t CAEDRAddDeviceInfoToList(const char *remoteAddress, CAConnectedDeviceInfo_t *deviceInfo) +{ + if (!remoteAddress) + { + OIC_LOG(ERROR, EDR_ADAPTER_TAG, "remoteAddress is null"); + return CA_STATUS_INVALID_PARAM; + } + + if (!deviceInfo) + { + OIC_LOG(ERROR, EDR_ADAPTER_TAG, "deviceInfo is null"); + return CA_STATUS_INVALID_PARAM; + } + + for (int i = 0; i < CA_MACADDR_SIZE; i++) + { + deviceInfo->address[i] = (uint8_t) remoteAddress[i]; + } + + if (!g_deviceStateList) + { + g_deviceStateList = u_arraylist_create(); + if (!g_deviceStateList) + { + OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to create Device list"); + return CA_STATUS_FAILED; + } + } + + if (!u_arraylist_add(g_deviceStateList, (void *) deviceInfo)) + { + OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to Add Device to list"); + return CA_STATUS_FAILED; + } + return CA_STATUS_OK; +} \ No newline at end of file