2 * Open Adaptation Layer (OAL)
4 * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
23 #include <oal-manager.h>
25 #define OAL_GATT_MAX_ATTR_LEN 600
26 #define GATTC_READ_VALUE_TYPE_VALUE 0x0000 /* Attribute value itself */
27 #define GATTC_READ_VALUE_TYPE_AGG_FORMAT 0x2905 /* Characteristic Aggregate Format*/
29 /** GATT value type used in response to remote read requests */
31 uint8_t value[OAL_GATT_MAX_ATTR_LEN];
38 /** GATT remote read request response type */
40 oal_gatt_value_t attr_value;
42 } oal_gatt_response_t;
48 uint8_t include_txpower;
50 char* manufacturer_data;
51 uint16_t manufacturer_data_len;
53 uint16_t service_data_len;
55 uint16_t service_uuid_len;
57 uint16_t solicit_uuid_len;
58 uint16_t min_interval;
59 uint16_t max_interval;
64 } oal_ble_multi_adv_param_setup_t;
67 * @brief Enable Bluetooth Low Energy GATT Feature
69 * @remarks Application will be able to advertise and scan other Low Energy devices.
71 * @return OAL_STATUS_SUCCESS on success, otherwise non-zero error value.
72 * @retval #OAL_STATUS_SUCCESS Successful
74 * @pre OAL API must be initialized with oal_bt_init().
78 oal_status_t gatt_enable(void);
81 * @brief Disable Bluetooth Low Energy GATT Feature
83 * @remarks Application will not be able to advertise or scan other Low Energy devices.
85 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
86 * @retval #OAL_STATUS_SUCCESS Successful
88 * @pre OAL API should be enabled with gatt_enable().
92 oal_status_t gatt_disable(void);
95 * @brief Register the GATT Server
97 * @remarks Application will register the GATT Server
99 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
100 * @retval #OAL_STATUS_SUCCESS Successful
102 * @pre OAl API should be enabled with gatt_enable().
106 oal_status_t gatts_register(oal_uuid_t* server_uuid);
109 * @brief UnRegister the GATT Server
111 * @remarks Application will unregister the GATT Server
113 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
114 * @retval #OAL_STATUS_SUCCESS Successful
116 * @pre OAl API should be enabled with gatti_enable().
118 * @see gatts_register()
120 oal_status_t gatts_unregister(int instance_id);
123 * @brief Start BLE Advertising feature
125 * @remarks Application will start advertising and behave as a peripheral device
127 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
128 * @retval #OAL_STATUS_SUCCESS Successful
130 * @pre OAl API should be enabled with gatt_enable().
134 oal_status_t gatts_start_listen(int instance_id, gboolean enable);
137 * @brief Stop BLE Advertising feature
139 * @remarks Application will stop advertising and will no longer behave as a peripheral device.
141 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
142 * @retval #OAL_STATUS_SUCCESS Successful
144 * @pre Advertising should have been started with gatts_start_advertising().
146 * @see gatts_start_listen()
148 oal_status_t gatts_stop_advertising(int instance_id);
151 * @brief Enables the Bluetooth Low Energy Multiple advertisement feature
153 * @remarks The application will be able to do multiple advertising
155 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
156 * @retval #OAL_STATUS_SUCCESS Successful
158 * @pre OAL API must be initialized with oal_bt_init().
160 * @see gatts_multi_adv_disable()
162 oal_status_t gatts_multi_adv_enable(int instance_id);
165 * @brief Disables the Bluetooth Low Energy Multiple advertisement feature
167 * @remarks The application will not be able to do multiple advertising
169 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
170 * @retval #OAL_STATUS_SUCCESS Successful
172 * @pre OAL API must be initialized with oal_bt_init().
174 * @see gatts_multi_adv_enable()
176 oal_status_t gatts_multi_adv_disable(int instance_id);
179 * @brief Updates the parameters to configure the Multiple Advertising Features
181 * @remarks The parameters like min and max interval, advertising type,
182 * channel map, tx power and timeout will be updated.
184 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
185 * @retval #OAL_STATUS_SUCCESS Successful
187 * @pre OAL API should be enabled with gatts_multi_adv_enable().
189 * @see gatts_multi_adv_enable()
191 oal_status_t gatts_multi_adv_update(int instance_id, int min_intv, int max_intv,
192 int adv_type, int chnl_map,
193 int tx_power, int timeout_s);
196 * @brief Sets the the Multiple Advertising Data
198 * @remarks The Multiple advertising data will be set.
200 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
201 * @retval #OAL_STATUS_SUCCESS Successful
203 * @pre OAL API should be enabled with gatts_multi_adv_enable().
205 * @see gatts_multi_adv_enable()
207 oal_status_t gatts_multi_adv_set_inst_data(int instance_id,
208 oal_ble_multi_adv_param_setup_t *adv_param_setup);
211 * @brief Get current ATT MTU size of the connection
213 * @remarks The application will get current ATT MTU size of the connection
215 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
216 * @retval #OAL_STATUS_SUCCESS>-Successful
218 * @pre OAL API must be initialized with oal_bt_init().
220 * @param conn_id: active connection id (input)
221 * mtu: att mtu size of the connection (output)
223 * @see gatts_multi_adv_enable()
225 oal_status_t gatts_get_att_mtu(int conn_id, int *mtu);
228 * @brief GATT Server Add Service
230 * @remarks GATT Server will add new service in gatt server database.
232 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
233 * @retval #OAL_STATUS_SUCCESS Successful
235 * @pre Advertising should have been started with gatts_start_advertising().
237 * @see gatts_start_advertising()
239 oal_status_t gatts_add_service(int instance_id, oal_gatt_srvc_id_t *gatt_serv_id, int num_handles);
242 * @brief GATT Server Add Included Service
244 * @remarks GATT Server will add new included service in gatt server database.
246 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
247 * @retval #OAL_STATUS_SUCCESS Successful
249 * @pre Primary service should have been added with gatts_add_service().
251 * @see gatts_add_service()
253 oal_status_t gatts_add_included_services(int instance_id, int srv_handle, int incld_handle);
256 * @brief GATT Server Add Charactertistic
258 * @remarks GATT Server will add new Charactertistic in gatt server database.
260 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
261 * @retval #OAL_STATUS_SUCCESS Successful
263 * @pre Primary service should have been added with gatts_add_service().
265 * @see gatts_add_service()
267 oal_status_t gatts_add_characteristics(int instance_id, int srv_handle, oal_uuid_t* charc_uuid, int propts, int permsn);
270 * @brief GATT Server Add Descriptor
272 * @remarks GATT Server will add new Descriptor in gatt server database.
274 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
275 * @retval #OAL_STATUS_SUCCESS Successful
277 * @pre Primary service should have been added with gatts_add_service().
279 * @see gatts_add_service()
281 oal_status_t gatts_add_descriptor(int instance_id, int srv_handle, oal_uuid_t* desc_uuid, int permsn);
284 * @brief GATT Server make ready the new service for advertiment
286 * @remarks GATT Server will enable the new service for advertiment.
288 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
289 * @retval #OAL_STATUS_SUCCESS Successful
291 * @pre Primary service should have been added with gatts_add_service().
293 * @see gatts_add_service()
295 oal_status_t gatts_start_service(int innstance_id, int svc_handle, int transport);
298 * @brief GATT Server Stop the added service from advertiment
300 * @remarks GATT Server will Stop the added service from advertiment .
302 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
303 * @retval #OAL_STATUS_SUCCESS Successful
305 * @pre Primary service should have been started with gatts_start_service().
307 * @see gatts_start_service()
309 oal_status_t gatts_stop_service(int instance_id, int svc_hdl);
312 * @brief GATT Server delete the already added service
314 * @remarks GATT Server will delete the already added service in gatt server database.
316 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
317 * @retval #OAL_STATUS_SUCCESS Successful
319 * @pre Primary service should have been added with gatts_add_service().
321 * @see gatts_add_service()
323 oal_status_t gatts_delete_service(int instance_id, int svc_handle);
326 * @brief GATT Server send the indication for change in attribute value
328 * @remarks GATT Server will send the indication to client for change in attribute value .
330 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
331 * @retval #OAL_STATUS_SUCCESS Successful
333 * @pre A Client should be connected to this server.
335 * @see gatts_connect()
337 oal_status_t gatts_send_indication(int ins_id, int attr_hndl, int conn_id, int len, int confirm, char* value);
340 * @brief GATT Server Update value of the attribute associated with a GATT server instance
342 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
343 * @retval #OAL_STATUS_SUCCESS Successful
345 oal_status_t gatts_update_att_value(int ins_id, oal_gatt_value_t *value);
348 * @brief GATT Server send the response for attribute value
350 * @remarks GATT Server will send the response for attribute value asked from client .
352 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
353 * @retval #OAL_STATUS_SUCCESS Successful
355 * @pre A Client should be connected to this server.
357 * @see gatts_connect()
359 oal_status_t gatts_send_response(int conn_id, int trans_id, int resp_status, oal_gatt_response_t *response);
362 * @brief Start LE Device discovery
364 * @remarks BLE discovery will be started
366 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
367 * @retval #OAL_STATUS_SUCCESS Successful
369 * @pre OAL API should be enabled with gatt_enable().
373 oal_status_t gattc_start_le_discovery(void);
376 * @brief Stop LE Device discovery
378 * @remarks BLE discovery will be stopped
380 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
381 * @retval #OAL_STATUS_SUCCESS Successful
383 * @pre BLE Discovery should be started using the gattc_start_le_discovery().
385 * @see gattc_start_le_discovery()
387 oal_status_t gattc_stop_le_discovery(void);
390 * @brief Set scan parameters
392 * @remarks scan parameters will be set
394 * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
395 * @retval #OAL_STATUS_SUCCESS Successful
398 oal_status_t gattc_set_le_scan_param(int scan_type, int itv, int win);
400 #endif /* OAL_GATT_H_ */