1 /* ****************************************************************
3 * Copyright 2014 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************/
24 * This file provides APIs to manage discovered bluetooth device list.
27 #ifndef CA_EDR_DEVICE_LIST_H_
28 #define CA_EDR_DEVICE_LIST_H_
38 * Structure to maintain the data needs to send to peer Bluetooth device.
42 void *data; /**< Data to be sent to peer Bluetooth device. */
43 uint32_t dataLength; /**< Length of the data. */
47 * Structure to maintain list of data needs to send to peer Bluetooth device.
49 typedef struct _EDRDataList
51 EDRData *data; /**< Data to be sent to peer Bluetooth device. */
52 struct _EDRDataList *next;/**< Reference to next data in list. */
56 * Structure to maintain information of peer Bluetooth device.
60 char *remoteAddress; /**< Address of peer Bluetooth device. */
61 char *serviceUUID; /**< OIC service UUID running in peer Bluetooth device. */
62 int socketFD; /**< RfComm connection socket FD. */
63 EDRDataList *pendingDataList;/**< List of data needs to send to peer Bluetooth device. */
64 bool serviceSearched; /**< Flag to indicate the status of service search. */
68 * Structure to maintain list of peer Bluetooth device information.
70 typedef struct _EDRDeviceList
72 EDRDevice *device; /**< Bluetooth device information. */
73 struct _EDRDeviceList *next; /**< Reference to next device information. */
77 * Creates ::EDRDevice for specified remote address and uuid and to device list.
79 * @param[in/out] deviceList Device list which created device add to.
80 * @param[in] deviceAddress Bluetooth device address.
81 * @param[in] uuid Service uuid.
82 * @param[in] device Created ::EDRDevice.
84 * @return ::CA_STATUS_OK or Appropriate error code.
85 * @retval ::CA_STATUS_OK Successful.
86 * @retval ::CA_STATUS_INVALID_PARAM Invalid input parameters.
87 * @retval ::CA_STATUS_FAILED Failed to create device and add to list.
89 CAResult_t CACreateAndAddToDeviceList(EDRDeviceList **deviceList, const char *deviceAddress,
90 const char *uuid, EDRDevice **device);
93 * Insert device to specified list.
95 * @param[in/out] deviceList Device list to which specifed @device to be added.
96 * @param[in] device Device to be added to list.
98 * @return ::CA_STATUS_OK or Appropriate error code.
99 * @retval ::CA_STATUS_OK Successful.
100 * @retval ::CA_STATUS_INVALID_PARAM Invalid input parameters.
101 * @retval ::CA_MEMORY_ALLOC_FAILED Memory allocation failed.
103 CAResult_t CAAddEDRDeviceToList(EDRDeviceList **deviceList, EDRDevice *device);
106 * Get the device from list which matches specified device address.
108 * @param[in] deviceList Device list to search for the device.
109 * @param[in] deviceAddress Device address used for matching.
110 * @param[out] device ::EDRDevice which has matching device address.
112 * @return ::CA_STATUS_OK or Appropriate error code.
113 * @retval ::CA_STATUS_OK Successful.
114 * @retval ::CA_STATUS_INVALID_PARAM Invalid input parameters.
115 * @retval ::CA_STATUS_FAILED Device is not found in the list.
117 CAResult_t CAGetEDRDevice(EDRDeviceList *deviceList,
118 const char *deviceAddress, EDRDevice **device);
121 * Get the device from list which matches specified RFCOMM socket id.
123 * @param[in] deviceList Device list to search for the device.
124 * @param[in] socketID RFCOMM socket id.
125 * @param[out] device ::EDRDevice which has matching RFCOMM socket id .
127 * @return ::CA_STATUS_OK or Appropriate error code.
128 * @retval ::CA_STATUS_OK Successful.
129 * @retval ::CA_STATUS_INVALID_PARAM Invalid input parameters.
130 * @retval ::CA_STATUS_FAILED Device is not found in the list.
132 CAResult_t CAGetEDRDeviceBySocketId(EDRDeviceList *deviceList, int32_t socketID,
136 * Remove and delete the device matching specified device address from list.
138 * @param[in/out] deviceList Device list to search for the device.
139 * @param[in] deviceAddress Bluetooth device address.
141 * @return ::CA_STATUS_OK or Appropriate error code.
142 * @retval ::CA_STATUS_OK Successful.
143 * @retval ::CA_STATUS_INVALID_PARAM Invalid input parameters.
144 * @retval ::CA_STATUS_FAILED Device is not found in the list.
146 CAResult_t CARemoveEDRDeviceFromList(EDRDeviceList **deviceList,
147 const char *deviceAddress);
150 * Destroy the specified device list. Removes and delete all the devices in the list.
151 * @param[in/out] deviceList Device list to be destroyed.
153 void CADestroyEDRDeviceList(EDRDeviceList **deviceList);
156 * Insert data to specified list.
158 * @param[in] dataList Data list to which data will be add.
159 * @param[in] data Data to be stored.
160 * @param[in] dataLength Length of the data.
162 * @return ::CA_STATUS_OK or Appropriate error code.
163 * @retval ::CA_STATUS_OK Successful.
164 * @retval ::CA_STATUS_INVALID_PARAM Invalid input parameters.
165 * @retval ::CA_MEMORY_ALLOC_FAILED Memory allocation failed.
167 CAResult_t CAAddEDRDataToList(EDRDataList **dataList, const void *data, uint32_t dataLength);
170 * Remove and delete data from front end of list.
171 * @param[in/out] dataList Data list from which data will be removed.
173 * @return ::CA_STATUS_OK or Appropriate error code.
174 * @retval ::CA_STATUS_OK Successful.
175 * @retval ::CA_STATUS_INVALID_PARAM Invalid input parameters.
177 CAResult_t CARemoveEDRDataFromList(EDRDataList **dataList);
180 * Destroy the specified data list. Removes and deletes all the data in the list.
181 * @param[in] dataList Data list to be destroyed.
183 void CADestroyEDRDataList(EDRDataList **dataList);
189 #endif /* CA_EDR_DEVICE_LIST_H_ */