Merge the code from tizen_2.4
[platform/core/connectivity/bluetooth-frwk.git] / include / bluetooth-api.h
index 90dda2a..7703e48 100755 (executable)
@@ -45,6 +45,7 @@ extern "C" {
 #define BLUETOOTH_VERSION_LENGTH_MAX       30 /**< This specifies bluetooth device version length */
 #define BLUETOOTH_INTERFACE_NAME_LENGTH        16
 #define BLUETOOTH_DEVICE_NAME_LENGTH_MAX       248 /**< This specifies maximum device name length */
+#define BLUETOOTH_DEVICE_PASSKEY_LENGTH_MAX       50 /**< This specifies maximum length of the passkey */
 #define BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX  31 /**< This specifies maximum AD data length */
 #define BLUETOOTH_SCAN_RESP_DATA_LENGTH_MAX     31 /**< This specifies maximum LE Scan response data length */
 #define BLUETOOTH_MANUFACTURER_DATA_LENGTH_MAX 240 /**< This specifies maximum manufacturer data length */
@@ -55,7 +56,10 @@ extern "C" {
 #define BLUETOOTH_UUID_STRING_MAX 50
 #define BLUETOOTH_PATH_STRING 50
 
-#define BLUETOOTH_OOB_DATA_LENGTH              16
+#define BLUETOOTH_OOB_DATA_LENGTH 16
+
+#define BLUETOOTH_PIN_CODE_MAX_LENGTH 16
+
 /**
  * This is Bluetooth Connected event role
  */
@@ -212,6 +216,10 @@ typedef struct {
        char data[BLUETOOTH_MANUFACTURER_DATA_LENGTH_MAX];
 } bluetooth_manufacturer_data_t;
 
+typedef struct {
+       char pin_code[BLUETOOTH_PIN_CODE_MAX_LENGTH + 1];
+} bluetooth_device_pin_code_t;
+
 /**
  * Adapter state
  */
@@ -345,6 +353,14 @@ typedef enum
 }bt_gatt_characteristic_property_t;
 
 /**
+* Remote device request types for attributes
+*/
+typedef enum {
+       BLUETOOTH_GATT_ATT_REQUEST_TYPE_READ = 0x00, /* Read Requested*/
+       BLUETOOTH_GATT_ATT_REQUEST_TYPE_WRITE = 0x01, /* Write Requested*/
+} bluetooth_gatt_att_request_tyep_t;
+
+/**
 * Advertising parameters
 */
 typedef struct {
@@ -370,8 +386,9 @@ typedef struct {
        guint16 interval_min;
        guint16 interval_max;
        guint16 latency;
-       guint16 time_out;
-} bluetooth_le_conn_update_t;
+       guint16 timeout;
+} bluetooth_le_connection_param_t;
+
 /*
        LE Read Maximum Data Length
  */
@@ -427,6 +444,8 @@ typedef struct {
                                                                /**< Base ID for PBAP Client events */
 #define BLUETOOTH_EVENT_AVRCP_CONTROL_BASE ((int)(BLUETOOTH_EVENT_PBAP_CLIENT_BASE + 0x0020))
                                                                /**< Base ID for AVRCP events */
+#define BLUETOOTH_EVENT_IPSP_BASE ((int)(BLUETOOTH_EVENT_AVRCP_CONTROL_BASE + 0x0020))
+                                                               /**< Base ID for IPSP events */
 
 /**
  * Bluetooth event type
@@ -457,6 +476,10 @@ typedef enum {
        BLUETOOTH_EVENT_DEVICE_AUTHORIZED,          /**< Bluetooth event authorize device */
        BLUETOOTH_EVENT_DEVICE_UNAUTHORIZED,        /**< Bluetooth event unauthorize device */
        BLUETOOTH_EVENT_DISCOVERABLE_TIMEOUT_CHANGED,  /**< Bluetooth event mode changed */
+       BLUETOOTH_EVENT_KEYBOARD_PASSKEY_DISPLAY,       /**Bluetooth event for displaying keyboard  passkey to user*/
+       BLUETOOTH_EVENT_PIN_REQUEST,    /**Bluetooth event for PIN input by user*/
+       BLUETOOTH_EVENT_PASSKEY_REQUEST,        /**Bluetooth event for entering Passkey by user*/
+       BLUETOOTH_EVENT_PASSKEY_CONFIRM_REQUEST,        /**Bluetooth event for Passkey confirmation by user*/
        BLUETOOTH_EVENT_CONNECTABLE_CHANGED,        /**< Bluetooth event connectable changed */
 
        BLUETOOTH_EVENT_RSSI_ENABLED,           /**< Bluetooth event RSSI monitoring enabled */
@@ -523,6 +546,9 @@ typedef enum {
        BLUETOOTH_EVENT_GATT_DISCONNECTED, /**<Gatt Disconnected 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 */
+       BLUETOOTH_EVENT_GATT_SERVER_VALUE_CHANGED, /** <GATT Characteristic/Descriptor Value change event */
+       BLUETOOTH_EVENT_GATT_SERVER_NOTIFICATION_STATE_CHANGED, /** <GATT Characteristic Notification change event */
+       BLUETOOTH_EVENT_GATT_SERVER_INDICATE_CONFIRMED, /** <GATT Characteristic Notification change event */
 
        BLUETOOTH_EVENT_AG_CONNECTED = BLUETOOTH_EVENT_AUDIO_BASE, /**<AG service connected event*/
        BLUETOOTH_EVENT_AG_DISCONNECTED, /**<AG service disconnected event*/
@@ -590,6 +616,10 @@ typedef enum {
        BLUETOOTH_EVENT_AVRCP_SONG_POSITION_STATUS, /**<AVRCP control play Postion status event*/
        BLUETOOTH_EVENT_AVRCP_PLAY_STATUS_CHANGED, /**<AVRCP control play status event*/
        BLUETOOTH_EVENT_AVRCP_TRACK_CHANGED, /**<AVRCP control song metadata event*/
+
+       BLUETOOTH_EVENT_IPSP_INIT_STATE_CHANGED = BLUETOOTH_EVENT_IPSP_BASE, /**<IPSP init event*/
+       BLUETOOTH_EVENT_IPSP_CONNECTED, /**< IPSP connected event  */
+       BLUETOOTH_EVENT_IPSP_DISCONNECTED, /**< IPSP Disconnected event */
        BLUETOOTH_EVENT_LE_DATA_LENGTH_CHANGED,  /** LE data length values changed */
 } bluetooth_event_type_t;
 
@@ -862,6 +892,15 @@ typedef enum {
 } bluetooth_le_scan_filter_feature_t;
 
 /**
+ * LE connection mode
+ */
+typedef enum {
+       BLUETOOTH_LE_CONNECTION_MODE_BALANCED,
+       BLUETOOTH_LE_CONNECTION_MODE_LOW_LATENCY,
+       BLUETOOTH_LE_CONNECTION_MODE_LOW_POWER
+} bluetooth_le_connection_mode_t;
+
+/**
 * structure to hold the device information
 */
 typedef struct {
@@ -930,6 +969,26 @@ typedef struct {
 } bluetooth_network_device_info_t;
 
 /**
+ * Authentication event types
+ */
+
+typedef enum {
+       BLUETOOTH_AUTH_KEYBOARD_PASSKEY_REQUEST = 0,
+       BLUETOOTH_AUTH_PIN_REQUEST,
+       BLUETOOTH_AUTH_PASSKEY_REQUEST,
+       BLUETOOTH_AUTH_PASSKEY_CONFIRM_REQUEST,
+} bluetooth_auth_type_t;
+
+/**
+* structure to hold the pincode/pass-key req informations
+*/
+typedef struct {
+       bluetooth_device_address_t device_address;  /**< remote device address */
+       bluetooth_device_name_t device_name;        /**< device name */
+       char str_passkey[BLUETOOTH_DEVICE_PASSKEY_LENGTH_MAX]; /**< pass-key string */
+} bluetooth_authentication_request_info_t;
+
+/**
 * Stucture to hold discovery option
 */
 typedef struct {
@@ -1234,7 +1293,7 @@ typedef struct {
  * Structure to GATT Read Request
  */
 typedef struct {
-       char *char_handle;
+       char *att_handle;
        char *service_handle;
        char *address;
        guint16 offset;
@@ -1242,6 +1301,38 @@ typedef struct {
 } bt_gatt_read_req_t;
 
 /**
+ * Structure to GATT Value change
+ */
+typedef struct {
+       char *att_handle;
+       char *service_handle;
+       char *address;
+       guint8 req_id;
+       guint16 offset;
+       guint8 *att_value;
+       guint32 val_len;
+} bt_gatt_value_change_t;
+
+/**
+ * Structure to GATT characteristc Notification change
+ */
+typedef struct {
+       char *att_handle;
+       char *service_handle;
+       gboolean att_notify;
+} bt_gatt_char_notify_change_t;
+
+/**
+ * Structure to Indication confirmation
+ */
+typedef struct {
+       char *att_handle;
+       char *service_handle;
+       char *address;
+       gboolean complete;
+ } bt_gatt_indicate_confirm_t;
+
+/**
  * Structure to RSSI Signal Strength Alert
  */
 
@@ -3010,6 +3101,32 @@ ret = bluetooth_authorize_device(&device_address,authorized);
 int bluetooth_authorize_device(const bluetooth_device_address_t *device_address,
                                       gboolean authorized);
 
+int bluetooth_set_pin_code(const bluetooth_device_address_t *device_address,
+                               const bluetooth_device_pin_code_t *pin_code);
+
+int bluetooth_unset_pin_code(const bluetooth_device_address_t *device_address);
+
+/**
+ * @fn int bluetooth_passkey_reply(char *passkey, gboolean reply)
+ *
+ * @brief Receives Legacy Passkey\pin with following authentication response types
+ *
+ * @param[in]   passkey : This is the PIN or PASSKEY string required for remote device authentication
+ * @param[in]   reply    TRUE : Accept AUthentication FALSE: Cancels authentication
+ *
+ */
+int bluetooth_passkey_reply(char *passkey, gboolean reply);
+
+/**
+ * @fn int bluetooth_passkey_confirmation_reply(gboolean reply);
+ *
+ * @brief This API sends user confirmation reply to the local adapter.
+ *
+ * @param[in] reply TRUE : Accept AUthentication FALSE: Cancels authentication
+ *
+ */
+int bluetooth_passkey_confirmation_reply(gboolean reply);
+
 /**
  * @fn int bluetooth_search_service(const bluetooth_device_address_t *device_address)
  * @brief Get all services supported by remote device
@@ -4996,6 +5113,8 @@ int bluetooth_gatt_unregister_service(const char *svc_path);
 *
 * @exception    None
 * @param[in] request_id The identification of a read request
+* @param[in] req_type The identification of  request type (TRUE for Read request and FALSE for write request)
+* @param[in] resp_state The identification of response state
 * @param[in] offset The offset from where a value is read
 * @param[in] value The value to be sent. It will be sent from @a offset.
 *              If it is NULL, a requested GATT handle's value will be sent from @a offset.
@@ -5007,9 +5126,29 @@ int bluetooth_gatt_unregister_service(const char *svc_path);
 * @see bluetooth_gatt_add_descriptor()
 * @see bluetooth_gatt_register_service()
 */
-int bluetooth_gatt_send_response(int request_id,
-                               int offset, char *value, int value_length);
+int bluetooth_gatt_send_response(int request_id, guint req_type,
+                               int resp_state, int offset, char *value, int value_length);
 
+/* @fn bluetooth_gatt_server_set_notification(const char *char_path)
+*
+* @brief Sets the notification property for a characteristic.
+*
+* This function is a synchronous call.
+*
+* @return      BLUETOOTH_ERROR_NONE    - Success \n
+*       BLUETOOTH_ERROR_INTERNAL - Internal Error \n
+*       BLUETOOTH_ERROR_INVALID_PARAM -Invalid Parameters \n
+*       BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
+*
+* @exception    None
+* @param[in] char_path characteristic object path.
+* @param[in]   unicast_address remote device address. if set notification is sent to only one device.
+*
+* @remark  Adapter should be enabled
+* @see bluetooth_gatt_update_characteristic()
+*/
+int bluetooth_gatt_server_set_notification(const char *char_path,
+                               bluetooth_device_address_t *unicast_address);
 
 /* @fn int bluetooth_gatt_delete_services(void)
 *
@@ -5331,7 +5470,7 @@ int bluetooth_clear_white_list(void);
 
 /**
  * @fn int bluetooth_le_conn_update(bluetooth_device_address_t *address,
- *          const bluetooth_le_conn_update_t *parameters)
+ *          const bluetooth_le_connection_param_t *parameters)
  * @brief update connection paramter of LE connection.
  *
  * This function is a synchronous call.
@@ -5347,7 +5486,7 @@ int bluetooth_clear_white_list(void);
  * @see     bluetooth_bond_device
  */
 int bluetooth_le_conn_update(const bluetooth_device_address_t *address,
-            const bluetooth_le_conn_update_t *parameters);
+            const bluetooth_le_connection_param_t *parameters);
 
 
 /**
@@ -5370,6 +5509,27 @@ int bluetooth_le_conn_update(const bluetooth_device_address_t *address,
  * @remark     None
  */
 int bluetooth_enable_le_privacy(gboolean enable_privacy);
+
+/**
+ * @fn int bluetooth_update_le_connection_mode(bluetooth_device_address_t *address,
+ *                                             bluetooth_le_connection_mode_t mode)
+ * @brief update connection paramter of LE connection.
+ *
+ * This function is a synchronous call.
+ *
+ * @return   BLUETOOTH_ERROR_NONE  - Success \n
+ *           BLUETOOTH_ERROR_INTERNAL - Internal Error \n
+ *           BLUETOOTH_ERROR_INVALID_PARAM - Parameter is not valid \n
+ *
+ * @exception  None
+ * @param[in]  address - remote device address value.
+ * @param[in]  mode - new connection mode.
+ *
+ * @remark       None
+ */
+int bluetooth_update_le_connection_mode(const bluetooth_device_address_t *address,
+               bluetooth_le_connection_mode_t mode);
+
 /**
  * @fn int bluetooth_le_read_maximum_data_length()
  * @brief reads the maximum LE data length supported in the controller.