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 contains the util function for LE adapter. This maintains the
25 * list of services an individual GATT Client connected to and operations on
26 * that list, such as getting the service info with BD address or with
27 * position etc. This is mainly useful for the multicast transmission of
28 * data where client needs to have the info of all the services to which it
32 #ifndef TZ_BLE_UTIL_H_
33 #define TZ_BLE_UTIL_H_
35 #include <bluetooth.h>
41 bt_gatt_client_h clientHandle;
42 bt_gatt_h serviceHandle;
48 typedef struct _LEServerInfoList
50 LEServerInfo *serverInfo;
51 struct _LEServerInfoList *next;
55 * Different characteristics types.
57 * This provides information of different characteristics
58 * which will be added to OIC service.
62 BLE_GATT_WRITE_CHAR = 0, /**< write_char This will be used to get the unicast response. */
63 BLE_GATT_READ_CHAR, /**< read_char This will be used update value to OIC server. */
64 BLE_GATT_NOTIFY_CHAR /**< Reserved char for the time being. */
68 * Used to increment the registered service count.
70 void CAIncrementRegisteredServiceCount();
73 * Used to decrement the registered service count.
75 void CADecrementRegisteredServiceCount();
78 * Used to reset the registered service count.
80 void CAResetRegisteredServiceCount();
83 * Used to get the total registered service count.
84 * @return Total registered service count.
86 int32_t CAGetRegisteredServiceCount();
89 * @brief Used to add the serverListInfo structure to the Client List.
91 * @param[in] serverList Pointer to the ble server list which holds the info of list of
92 * servers registered by the client.
93 * @param[in] leServerInfo Pointer where serverInfo structure needs to be appended with
95 * @return ::CA_STATUS_OK or Appropriate error code.
96 * @retval ::CA_STATUS_OK Successful.
97 * @retval ::CA_STATUS_INVALID_PARAM Invalid input arguments.
98 * @retval ::CA_STATUS_FAILED Operation failed.
100 CAResult_t CAAddLEServerInfoToList(LEServerInfoList **serverList,
101 LEServerInfo *leServerInfo);
104 * Used to get the serviceInfo from the list.
106 * @param[in] serverList Pointer to the ble service list which holds the info of list
107 * of servers registered by the client.
108 * @param[in] leAddress BD address of the device where GATTServer information is required.
109 * @param[out] leServerInfo Info of service and characteristic handle of the given BD address
110 * registered by client.
111 * @return ::CA_STATUS_OK or Appropriate error code.
112 * @retval ::CA_STATUS_OK Successful.
113 * @retval ::CA_STATUS_INVALID_PARAM Invalid input arguments.
114 * @retval ::CA_STATUS_FAILED Operation failed.
116 CAResult_t CAGetLEServerInfo(LEServerInfoList *serverList, const char *leAddress,
117 LEServerInfo **leServerInfo);
120 * Used to get the clientInfo from the list by position.
122 * @param[in] serverList Pointer to the ble service list which holds the info of list
123 * of servers registered by the client.
124 * @param[in] position The service information of particular position in the list.
125 * @param[out] leServerInfo Info of service and characteristic handle of the given BD address
126 * registered by client.
127 * @return ::CA_STATUS_OK or Appropriate error code.
128 * @retval ::CA_STATUS_OK Successful.
129 * @retval ::CA_STATUS_INVALID_PARAM Invalid input arguments.
130 * @retval ::CA_STATUS_FAILED Operation failed.
132 CAResult_t CAGetLEServerInfoByPosition(LEServerInfoList *serverList, int32_t position,
133 LEServerInfo **leServerInfo);
136 * Used to clear BLE service list.
138 * @param[in] serverList Pointer to the ble service list which holds the info of list of
139 * servers registered by the client.
141 void CAFreeLEServerList(LEServerInfoList *serverList);
144 * @brief Used to get remove particular BLE service info from list
145 * @param[in] bleServerInfo Pointer to the structure which needs to be cleared.
147 void CAFreeLEServerInfo(LEServerInfo *bleServerInfo);
150 * Used to get the Error message.
151 * @param[in] err Error code(::bt_error_e).
152 * @return Error string corresponding to the BT error code.
154 const char *CALEGetErrorMsg(bt_error_e err);
156 #endif /* TZ_BLE_UTIL_H_ */