Add new method to disconnect device
[platform/core/connectivity/bluetooth-frwk.git] / include / bluetooth-api.h
index 003563c..f7ee242 100644 (file)
@@ -36,7 +36,7 @@ extern "C" {
  * @{
  */
 
-#define BLUETOOTH_ADDRESS_STRING_LENGTH                17 /**< This specifies bluetooth device address length (AA:BB:CC:DD:EE:FF) */
+#define BLUETOOTH_ADDRESS_STRING_LENGTH                18 /**< This specifies bluetooth device address length (AA:BB:CC:DD:EE:FF) */
 #define BLUETOOTH_ADDRESS_LENGTH               6 /**< This specifies bluetooth device address length */
 #define BLUETOOTH_VERSION_LENGTH_MAX           30 /**< This specifies bluetooth device version length */
 #define BLUETOOTH_INTERFACE_NAME_LENGTH                16
@@ -58,6 +58,10 @@ extern "C" {
 
 #define BLUETOOTH_PIN_CODE_MAX_LENGTH 16
 
+#ifdef TIZEN_GATT_CLIENT
+#define BLUETOOTH_GATT_ATT_DATA_LENGTH_MAX      610 /**< GATT ATT value max len */
+#endif
+
 /**
  * This is Bluetooth Connected event role
  */
@@ -184,6 +188,13 @@ extern "C" {
 
 #define BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION    ((int)BLUETOOTH_ERROR_BASE - 0x28)
                                                                /**< Device Policy Restricted */
+
+#define BLUETOOTH_ERROR_NO_DATA    ((int)BLUETOOTH_ERROR_BASE - 0x29)
+                                                               /**< No data */
+
+#define BLUETOOTH_ERROR_AUTHORIZATION_REJECTED ((int)BLUETOOTH_ERROR_BASE - 0x2a)
+                                                               /**< Authorization rejected */
+
 /**
 * Error codes for ATT Error response *
 */
@@ -210,7 +221,7 @@ extern "C" {
 #define BLUETOOTH_ATT_ERROR_WRITE_REQUEST_REJECTED             0xFC
 #define BLUETOOTH_ATT_ERROR_CCCD_IMPROPERLY_CONFIGURED         0xFD
 #define BLUETOOTH_ATT_ERROR_PROCEDURE_ALREADY_IN_PROGRESS      0xFE
-#define BLUETOOTH_ATT_ERROR_OUT_OF_RANGE                       0xFF
+#define BLUETOOTH_ATT_ERROR_OUT_OF_RANGE       0xFF
 
 /*
  * Bluetooth ATT error codes specific to OTP
@@ -786,8 +797,15 @@ typedef enum {
        BLUETOOTH_EVENT_GATT_READ_DESC, /**<Gatt Read Characteristic Descriptor Value */
        BLUETOOTH_EVENT_GATT_WRITE_DESC, /**<Gatt Write Characteristic Descriptor Value */
        BLUETOOTH_EVENT_GATT_SVC_CHAR_DESC_DISCOVERED, /**<Gatt Char Descriptors Discovered Event*/
+#ifdef TIZEN_GATT_CLIENT
+       BLUETOOTH_EVENT_GATT_SERVER_CONNECTED,/**<Local Gatt Server connected event */
+       BLUETOOTH_EVENT_GATT_SERVER_DISCONNECTED, /**<Local Gatt Server Disconnected event */
+       BLUETOOTH_EVENT_GATT_CLIENT_CONNECTED,/**<Local Gatt Client connected event */
+       BLUETOOTH_EVENT_GATT_CLIENT_DISCONNECTED, /**<Local Gatt Client Disconnected event */
+#else
        BLUETOOTH_EVENT_GATT_CONNECTED,/**<Gatt connected event */
        BLUETOOTH_EVENT_GATT_DISCONNECTED, /**<Gatt Disconnected event */
+#endif
        BLUETOOTH_EVENT_GATT_ATT_MTU_CHANGED, /**<Attribute protocol MTU changed event */
        BLUETOOTH_EVENT_GATT_SERVER_CHARACTERISTIC_VALUE_CHANGED, /**<Gatt Char write callback event */
        BLUETOOTH_EVENT_GATT_SERVER_READ_REQUESTED, /** <GATT Characteristic/Descriptor Read Request event */
@@ -795,7 +813,8 @@ typedef enum {
        BLUETOOTH_EVENT_GATT_SERVER_NOTIFICATION_STATE_CHANGED, /** <GATT Characteristic Notification change event */
        BLUETOOTH_EVENT_GATT_SERVER_NOTIFICATION_COMPLETED, /** <GATT Characteristic Notification or Indication completed event */
        BLUETOOTH_EVENT_GATT_CLIENT_SERVICE_CHANGED, /** <GATT Client service change event */
-
+       BLUETOOTH_EVENT_GATT_SERVER_ACQUIRE_WRITE, /** <GATT Characteristic/Descriptor Value change event */
+       BLUETOOTH_EVENT_GATT_SERVER_ACQUIRE_NOTIFY,
        BLUETOOTH_EVENT_AG_CONNECTED = BLUETOOTH_EVENT_AUDIO_BASE, /**<AG service connected event*/
        BLUETOOTH_EVENT_AG_DISCONNECTED, /**<AG service disconnected event*/
        BLUETOOTH_EVENT_AG_SPEAKER_GAIN, /**<Speaker gain request event*/
@@ -812,6 +831,7 @@ typedef enum {
        BLUETOOTH_EVENT_AVRCP_SETTING_EQUALIZER_STATUS, /**<AVRCP service player equalizer status event*/
        BLUETOOTH_EVENT_AVRCP_SETTING_REPEAT_STATUS, /**<AVRCP service player repeat status event*/
        BLUETOOTH_EVENT_AVRCP_SETTING_SCAN_STATUS, /**<AVRCP service player scan status event*/
+       BLUETOOTH_EVENT_AVRCP_DELAY_CHANGED, /**<AVRCP service transport delay changed event*/
        BLUETOOTH_EVENT_HF_CONNECTED,
        BLUETOOTH_EVENT_HF_DISCONNECTED,
        BLUETOOTH_EVENT_HF_AUDIO_CONNECTED,
@@ -1380,13 +1400,6 @@ typedef struct {
                                              /**< device address */
 } bluetooth_rfcomm_connection_request_t;
 
-typedef struct {
-       int socket_fd;
-               /**< the socket fd */
-       bluetooth_device_address_t device_addr;
-                                             /**< device address */
-} bluetooth_hid_request_t;
-
 /**
  * HDP QOS types
  */
@@ -1521,8 +1534,23 @@ typedef struct {
 typedef struct {
        int count;
        char **handle;
+#ifdef TIZEN_GATT_CLIENT
+       char uuids[BLUETOOTH_MAX_SERVICES_FOR_DEVICE][BLUETOOTH_UUID_STRING_MAX];
+       int inst_id[BLUETOOTH_MAX_SERVICES_FOR_DEVICE];
+#endif
 } bt_gatt_handle_info_t;
 
+#ifdef TIZEN_GATT_CLIENT
+/**
+ * Structure to a most basic GATT attribute handle data
+ */
+typedef struct {
+       int instance_id;
+       unsigned char uuid[16];
+       char address[BLUETOOTH_ADDRESS_STRING_LENGTH];
+} bt_gatt_handle_property_t;
+#endif
+
 /**
  * Structure to GATT Remote service data
  */
@@ -1533,6 +1561,9 @@ typedef struct {
        gboolean primary;
        bt_gatt_handle_info_t include_handles;
        bt_gatt_handle_info_t char_handle;
+#ifdef TIZEN_GATT_CLIENT
+       bt_gatt_handle_property_t prop; /* Added Service UUID, instance_id & associated remote device  */
+#endif
 } bt_gatt_service_property_t;
 
 /**
@@ -1571,6 +1602,12 @@ typedef struct {
        unsigned int permission;
        char *representation;
        bt_gatt_handle_info_t char_desc_handle;
+#ifdef TIZEN_GATT_CLIENT
+       bt_gatt_handle_property_t prop;      /* Added Char UUID, instance_id */
+       bt_gatt_handle_property_t svc_prop;  /* Added Service UUID, instance_id */
+       char value[BLUETOOTH_GATT_ATT_DATA_LENGTH_MAX]; /* Added */
+       char address[BLUETOOTH_ADDRESS_STRING_LENGTH];         /* Added */
+#endif
 } bt_gatt_char_property_t;
 
 /**
@@ -1582,6 +1619,13 @@ typedef struct {
        char *uuid;
        unsigned char *val;
        unsigned int val_len;
+#ifdef TIZEN_GATT_CLIENT
+       bt_gatt_handle_property_t prop;      /* Added Descriptor UUID, instance_id */
+       bt_gatt_handle_property_t char_prop; /* Added Char UUID, instance_id */
+       bt_gatt_handle_property_t svc_prop;  /* Added Service UUID, instance_id */
+       char value[BLUETOOTH_GATT_ATT_DATA_LENGTH_MAX];/* Added */
+       char address[BLUETOOTH_ADDRESS_STRING_LENGTH];          /* Added */
+#endif
 } bt_gatt_char_descriptor_property_t;
 
 /**
@@ -1594,6 +1638,13 @@ typedef struct {
        guint32 val_len;
 } bt_gatt_char_value_t;
 
+typedef struct {
+       unsigned char UUID[16];
+       char address[18];
+       char *val;
+       int len;
+} bt_gatt_notify_req_t ;
+
 /**
  * Structure to GATT Read Request
  */
@@ -1648,6 +1699,7 @@ typedef struct {
  * Structure for GATT response data
  */
 typedef struct {
+       char *handle;
        guint8 *value;
        guint32 len;
        gpointer user_data;
@@ -3269,6 +3321,8 @@ int bluetooth_set_connectable(gboolean is_connectable);
 
 int bluetooth_is_connectable(gboolean *is_connectable);
 
+int bluetooth_disconnect_device(const bluetooth_device_address_t *device_address);
+
 /**
  * @fn int bluetooth_bond_device(const bluetooth_device_address_t *device_address)
  * @brief Initiate a bonding process
@@ -3620,7 +3674,6 @@ void bt_get_bonded_device(void)
 int bluetooth_get_bonded_device(const bluetooth_device_address_t *device_address,
                                        bluetooth_device_info_t *dev_info);
 
-
 /**
  * @fn int bluetooth_get_is_alias_set(const bluetooth_device_address_t *device_address,
  *                                     gboolean *is_alias_set)
@@ -5555,9 +5608,19 @@ int bluetooth_gatt_free_char_property(bt_gatt_char_property_t *char_pty);
  */
 int bluetooth_gatt_free_desc_property(bt_gatt_char_descriptor_property_t *desc_pty);
 
+#ifdef TIZEN_GATT_CLIENT
+int bluetooth_connect_le(const bluetooth_device_address_t *device_address,
+                               gboolean auto_connect, int client_id);
+#else
 int bluetooth_connect_le(const bluetooth_device_address_t *device_address, gboolean auto_connect);
+#endif
 
+#ifdef TIZEN_GATT_CLIENT
+int bluetooth_disconnect_le(const bluetooth_device_address_t *device_address,
+               int client_id);
+#else
 int bluetooth_disconnect_le(const bluetooth_device_address_t *device_address);
+#endif
 
  /**
  * @fn int bluetooth_gatt_discover_characteristic_descriptor(const char *characteristic_handle);
@@ -7629,7 +7692,7 @@ int bluetooth_otp_enable_notification(const char *handle);
  *
  * @remark     None
  */
-int bluetooth_otp_write_characteristics_value( const char *handle,
+int bluetooth_otp_write_characteristics_value(const char *handle,
                                        unsigned char *buf, int length);
 
 /**
@@ -7684,6 +7747,44 @@ int bluetooth_otp_connect_otc(const bluetooth_device_address_t *device_address);
 int bluetooth_otp_disconnect_otc(const bluetooth_device_address_t *device_address);
 
 /**
+ * @fn int bluetooth_is_le_2m_phy_supported(gboolean *is_supported)
+ * @brief Check if Adapter supports LE 2M PHY feature or not.
+ *
+ * This API is used to check the whether LE Adapter supports LE 2M PHY feature, which is introduced
+ * in BT 5.0 specification.
+ *
+ * This function is a synchronous call.
+ *
+ * @return     BLUETOOTH_ERROR_NONE - Succeess \n
+ *             BLUETOOTH_ERROR_INVALID_PARAM -  Invalid parameter (NULL buffer) \n
+ *             BLUETOOTH_ERROR_DEVICE_NOT_ENABLED -  Adapter is disabled \n
+ *             BLUETOOTH_ERROR_INTERNAL -  Internal error \n
+ * @param[out] is_supported. This boolean variable indicates whether LE 2M PHY is supported or not
+ *
+ * @remark      None
+ */
+int bluetooth_is_le_2m_phy_supported(gboolean *is_supported);
+
+/**
+ * @fn int bluetooth_is_le_coded_phy_supported(gboolean *is_supported)
+ * @brief Check if Adapter supports LE 2M CODED feature or not.
+ *
+ * This API is used to check the whether LE Adapter supports LE CODED PHY feature, which is introduced
+ * in BT 5.0 specification.
+ *
+ * This function is a synchronous call.
+ *
+ * @return     BLUETOOTH_ERROR_NONE - Succeess \n
+ *             BLUETOOTH_ERROR_INVALID_PARAM -  Invalid parameter (NULL buffer) \n
+ *             BLUETOOTH_ERROR_DEVICE_NOT_ENABLED -  Adapter is disabled \n
+ *             BLUETOOTH_ERROR_INTERNAL -  Internal error \n
+ * @param[out] is_supported. This boolean variable indicates whether LE CODED PHY is supported or not
+ *
+ * @remark      None
+ */
+int bluetooth_is_le_coded_phy_supported(gboolean *is_supported);
+
+/**
  * @}
  */