| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480 |
- /**
- * @file wm_ble_gatt.h
- *
- * @brief Bluetooth API
- *
- * @author WinnerMicro
- *
- * Copyright (c) 2020 Winner Microelectronics Co., Ltd.
- */
- #ifndef WM_BLE_GATT_H
- #define WM_BLE_GATT_H
- #include "wm_bt_def.h"
- /**
- * @defgroup BT_APIs Bluetooth APIs
- * @brief Bluetooth related APIs
- */
- /**
- * @addtogroup BT_APIs
- * @{
- */
- /**
- * @defgroup BLE_GATT_Client_APIs BLE GATT Client APIs
- * @brief BLE GATT Client APIs
- */
- /**
- * @addtogroup BLE_GATT_Client_APIs
- * @{
- */
- /**
- * @brief initialize the btif_gatt_client callback function
- *
- * @param[in] *p_callback pointer on callback function
- *
- * @retval @ref tls_bt_status_t
- *
- * @note None
- */
- tls_bt_status_t tls_ble_client_app_init(tls_ble_callback_t callback);
- /**
- * @brief free the tls_ble_callback_t pointer
- *
- * @param None
- *
- * @retval @ref tls_bt_status_t
- *
- * @note None
- */
- tls_bt_status_t tls_ble_client_app_deinit(void);
- /**
- * @brief this function is called to register client application
- *
- * @param[in] *uuid pointer on uuid
- *
- * @retval @ref tls_bt_status_t
- *
- * @note None
- */
- tls_bt_status_t tls_ble_client_app_register(tls_bt_uuid_t *uuid);
- /**
- * @brief this function is called to unregister client application
- *
- * @param[in] client_if gatt client access interface
- *
- * @retval @ref tls_bt_status_t
- *
- * @note None
- */
- tls_bt_status_t tls_ble_client_app_unregister(uint8_t client_if);
- /**
- * @brief this function is called to open an BLE connection to a remote
- * device or add a background auto connection
- *
- * @param[in] client_if gatt client access interface
- * @param[in] *bd_addr remote device bluetooth device address
- * @param[in] is_direct direct connection or background auto connection
- * @param[in] transport specific BLE/BR-EDR/mixed
- *
- * @retval @ref tls_bt_status_t
- *
- * @note None
- */
- tls_bt_status_t tls_ble_client_connect(uint8_t client_if, const tls_bt_addr_t *bd_addr, uint8_t is_direct, int transport);
- /**
- * @brief this function is called to disconnect with gatt server connection
- *
- * @param[in] client_if gatt client access interface
- * @param[in] *bd_addr remote device bluetooth device address
- * @param[in] conn_id connection ID to be closed
- *
- * @retval @ref tls_bt_status_t
- *
- * @note None
- */
- tls_bt_status_t tls_ble_client_disconnect(uint8_t client_if, const tls_bt_addr_t *bd_addr, int conn_id);
- /**
- * @brief start or stop advertisements to listen for incoming connections
- *
- * @param[in] client_if gatt client access interface
- * @param[in] start start: 1; stop 0
- *
- * @retval @ref tls_bt_status_t
- *
- * @note None
- */
- tls_bt_status_t tls_ble_client_listen(uint8_t client_if, uint8_t start);
- /**
- * @brief clear the attribute cache for a given device
- *
- * @param[in] client_if gatt client access interface
- * @param[in] *bd_addr remote device address
- *
- * @retval @ref tls_bt_status_t
- *
- * @note None
- */
- tls_bt_status_t tls_ble_client_refresh(uint8_t client_if, const tls_bt_addr_t *bd_addr);
- /**
- * @brief enumerate all GATT services on a connected device
- *
- * @param[in] conn_id connection indicator return value when connected
- * @param[in] *filter_uuid filter this uuid
- *
- * @retval @ref tls_bt_status_t
- *
- * @note Optionally, the results can be filtered for a given UUID
- */
- tls_bt_status_t tls_ble_client_search_service(uint16_t conn_id, tls_bt_uuid_t *filter_uuid);
- /**
- * @brief write a remote characteristic
- *
- * @param[in] conn_id connection indicator return value when connected
- * @param[in] handle the character attribute handle
- * @param[in] write_type the type of attribute write operation
- * @param[in] len length of the value to be written
- * @param[in] auth_req authentication request
- * @param[in] *p_value the value to be written
- *
- * @retval @ref tls_bt_status_t
- *
- * @note None
- */
- tls_bt_status_t tls_ble_client_write_characteristic(uint16_t conn_id, uint16_t handle, int write_type, int len, int auth_req, char *p_value);
- /**
- * @brief read a characteristic on a remote device
- *
- * @param[in] conn_id connection indicator return value when connected
- * @param[in] handle the character attribute handle
- * @param[in] auth_req authentication request
- *
- * @retval @ref tls_bt_status_t
- *
- * @note None
- */
- tls_bt_status_t tls_ble_client_read_characteristic(uint16_t conn_id, uint16_t handle, int auth_req);
- /**
- * @brief read the descriptor for a given characteristic
- *
- * @param[in] conn_id connection indicator return value when connected
- * @param[in] handle the character attribute handle
- * @param[in] auth_req authentication request
- *
- * @retval @ref tls_bt_status_t
- *
- * @note None
- */
- tls_bt_status_t tls_ble_client_read_descriptor(uint16_t conn_id, uint16_t handle, int auth_req);
- /**
- * @brief write a remote descriptor for a given characteristic
- *
- * @param[in] conn_id connection indicator return value when connected
- * @param[in] handle the character attribute handle
- * @param[in] write_type the type of attribute write operation
- * @param[in] len length of the value to be written
- * @param[in] auth_req authentication request
- * @param[in] *p_value the value to be written
- *
- * @retval @ref tls_bt_status_t
- *
- * @note None
- */
- tls_bt_status_t tls_ble_client_write_descriptor(uint16_t conn_id, uint16_t handle, int write_type, int len, int auth_req, char *p_value);
- /**
- * @brief execute a prepared write operation
- *
- * @param[in] conn_id connection indicator return value when connected
- * @param[in] execute execute or cancel
- *
- * @retval @ref tls_bt_status_t
- *
- * @note None
- */
- tls_bt_status_t tls_ble_client_execute_write(uint16_t conn_id, int execute);
- /**
- * @brief Register to receive notifications or indications for a given
- * characteristic
- *
- * @param[in] client_if gatt client access interface
- * @param[in] *bd_addr the target server address
- * @param[in] handle the attribute handle of characteristic
- * @param[in] conn_id the connection id
- *
- * @retval @ref tls_bt_status_t
- *
- * @note None
- */
- tls_bt_status_t tls_ble_client_register_for_notification(int client_if, const tls_bt_addr_t *bd_addr, uint16_t handle, uint16_t conn_id);
- /**
- * @brief deregister a previous request for notifications/indications
- *
- * @param[in] client_if gatt client access interface
- * @param[in] *bd_addr the target server address
- * @param[in] handle the attribute handle of characteristic
- *
- * @retval @ref tls_bt_status_t
- *
- * @note None
- */
- tls_bt_status_t tls_ble_client_deregister_for_notification(int client_if, const tls_bt_addr_t *bd_addr, uint16_t handle,uint16_t conn_id);
- /**
- * @brief configure the MTU for a given connection
- *
- * @param[in] conn_id connection indicator return value when connected
- * @param[in] mtu the max transmit unit of this connection
- *
- * @retval @ref tls_bt_status_t
- *
- * @note None
- */
- tls_bt_status_t tls_ble_client_configure_mtu(uint16_t conn_id, uint16_t mtu);
- /**
- * @brief get gatt db content
- *
- * @param[in] conn_id connection indicator return value when connected
- *
- * @retval @ref tls_bt_status_t
- *
- * @note None
- */
- tls_bt_status_t tls_ble_client_get_gatt_db(uint16_t conn_id);
- /**
- * @}
- */
- /**
- * @defgroup BLE_GATT_Server_APIs BLE GATT Server APIs
- * @brief BLE GATT Server APIs
- */
- /**
- * @addtogroup BLE_GATT_Server_APIs
- * @{
- */
- /**
- * @brief initialize the btif_gatt_server callback function
- *
- * @param[in] *p_callback pointer on callback function
- *
- * @retval @ref tls_bt_status_t
- *
- * @note None
- */
- tls_bt_status_t tls_ble_server_app_init(tls_ble_callback_t callback);
- /*******************************************************************************
- **
- ** Function tls_ble_server_app_deinit
- **
- ** Description free the tls_ble_callback_t pointer
- **
- ** Parameters None
- **
- ** Returns TLS_BT_STATUS_SUCCESS
- ** TLS_BT_STATUS_DONE
- **
- *******************************************************************************/
- tls_bt_status_t tls_ble_server_app_deinit();
- /**
- * @brief this function is called to register server application
- *
- * @param[in] *uuid pointer on uuid
- *
- * @retval @ref tls_bt_status_t
- *
- * @note None
- */
- tls_bt_status_t tls_ble_server_app_register(tls_bt_uuid_t *uuid);
- /**
- * @brief this function is called to unregister server application
- *
- * @param[in] server_if assigned after app registering
- *
- * @retval @ref tls_bt_status_t
- *
- * @note None
- */
- tls_bt_status_t tls_ble_server_app_unregister(uint8_t server_if);
- /**
- * @brief create a new service
- *
- * @param[in] server_if the gatt server access interface created by app register
- * @param[in] inst_id instance identifier of this service
- * @param[in] primay is primary or not service
- * @param[in] *uuid the id property of this service
- * @param[in] num_handles number of handle requested for this service
- *
- * @retval @ref tls_bt_status_t
- *
- * @note None
- */
- tls_bt_status_t tls_ble_server_add_service(uint8_t server_if, int inst_id, int primay, tls_bt_uuid_t *uuid, int num_handles);
- /**
- * @brief add a characteristic to a service
- *
- * @param[in] server_if the gatt server access interface created by app register
- * @param[in] service_handle the handle of this service assigned when creating a service
- * @param[in] *uuid the id property of this characteristic
- * @param[in] properties access properties
- * @param[in] permission access permission
- *
- * @retval @ref tls_bt_status_t
- *
- * @note None
- */
- tls_bt_status_t tls_ble_server_add_characteristic(uint8_t server_if, uint16_t service_handle, tls_bt_uuid_t *uuid, int properties, int permission);
- /**
- * @brief add a descriptor to a given service
- *
- * @param[in] server_if the gatt server access interface created by app register
- * @param[in] service_handle the handle of this service assigned when creating a service
- * @param[in] *uuid the id property of this characteristic
- * @param[in] permission access permission
- *
- * @retval @ref tls_bt_status_t
- *
- * @note None
- */
- tls_bt_status_t tls_ble_server_add_descriptor(uint8_t server_if, uint16_t service_handle, tls_bt_uuid_t *uuid, int permissions);
- /**
- * @brief starts a local service
- *
- * @param[in] server_if the gatt server access interface created by app register
- * @param[in] service_handle the handle of this service assigned when creating a service
- * @param[in] transport tranport type, BLE/BR-EDR/MIXED
- *
- * @retval @ref tls_bt_status_t
- *
- * @note None
- */
- tls_bt_status_t tls_ble_server_start_service(uint8_t server_if, uint16_t service_handle, int transport);
- /**
- * @brief stop a local service
- *
- * @param[in] server_if the gatt server access interface created by app register
- * @param[in] service_handle the handle of this service assigned when creating a service
- *
- * @retval @ref tls_bt_status_t
- *
- * @note None
- */
- tls_bt_status_t tls_ble_server_stop_service(uint8_t server_if, uint16_t service_handle);
- /**
- * @brief delete a local service
- *
- * @param[in] server_if the gatt server access interface created by app register
- * @param[in] service_handle the handle of this service assigned when creating a service
- *
- * @retval @ref tls_bt_status_t
- *
- * @note None
- */
- tls_bt_status_t tls_ble_server_delete_service(uint8_t server_if, uint16_t service_handle);
- /**
- * @brief create a connection to a remote peripheral
- *
- * @param[in] server_if the gatt server access interface created by app register
- * @param[in] *bd_addr the remote device address
- * @param[in] is_direct true direct connection; false: background auto connection
- * @param[in] transport tranport type, BLE/BR-EDR/MIXED
- *
- * @retval @ref tls_bt_status_t
- *
- * @note None
- */
- tls_bt_status_t tls_ble_server_connect(uint8_t server_if, const tls_bt_addr_t *bd_addr, uint8_t is_direct, int transport);
- /**
- * @brief disconnect an established connection or cancel a pending one
- *
- * @param[in] server_if the gatt server access interface created by app register
- * @param[in] *bd_addr the remote device address
- * @param[in] conn_id connection id create when connection established
- *
- * @retval @ref tls_bt_status_t
- *
- * @note None
- */
- tls_bt_status_t tls_ble_server_disconnect(uint8_t server_if, const tls_bt_addr_t *bd_addr, uint16_t conn_id);
- /**
- * @brief send value indication to a remote device
- *
- * @param[in] server_if the gatt server access interface created by app register
- * @param[in] attribute_handle the handle of characteristic
- * @param[in] conn_id connection id create when connection established
- * @param[in] len the length of value to be sent
- * @param[in] confirm need the remote device acked after receive the message , normally
- * Whether a confirmation is required. FALSE sends a GATT notification,
- * TRUE sends a GATT indication
- * @param[in] *p_value the value to be written
- *
- * @retval @ref tls_bt_status_t
- *
- * @note None
- */
- tls_bt_status_t tls_ble_server_send_indication(uint8_t server_if, uint16_t attribute_handle, uint16_t conn_id, int len, int confirm, char *p_value);
- /**
- * @brief send a response to a read/write operation
- *
- * @param[in] conn_id connection id create when connection established
- * @param[in] trans_id the transation identifier
- * @param[in] status TODO:
- * @param[in] offset the offset the fragmented value
- * @param[in] attr_handle the attribute handle
- * @param[in] auth_req access properties
- * @param[in] *p_value the value to be written
- * @param[in] len the length of value to be written
- *
- * @retval @ref tls_bt_status_t
- *
- * @note None
- */
- tls_bt_status_t tls_ble_server_send_response(uint16_t conn_id, uint32_t trans_id, uint8_t status, int offset, uint16_t attr_handle, int auth_req, uint8_t *p_value, int len);
- /**
- * @}
- */
- /**
- * @}
- */
- #endif /* WM_BLE_GATT_H */
|