Debug message cleanup
[platform/core/connectivity/bluetooth-frwk.git] / include / bluetooth-api.h
index 8adf067..99d6634 100644 (file)
@@ -86,6 +86,8 @@ extern "C" {
  */
 #define BLUETOOTH_MAX_OTP_SERVER_DIR_NAME 100
 
+#define BLUETOOTH_OTP_CHARC_VAL_MAX_LENGTH   500 /**< OTP Characteristics Value Max length */
+
 /**
  * This is Bluetooth error code
  */
@@ -182,6 +184,48 @@ extern "C" {
 
 #define BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION    ((int)BLUETOOTH_ERROR_BASE - 0x28)
                                                                /**< Device Policy Restricted */
+/**
+* Error codes for ATT Error response *
+*/
+#define BLUETOOTH_ATT_ERROR_INTERNAL                           -1
+#define BLUETOOTH_ATT_ERROR_NONE                               0x00
+#define BLUETOOTH_ATT_ERROR_INVALID_HANDLE                     0x01
+#define BLUETOOTH_ATT_ERROR_READ_NOT_PERMITTED                 0x02
+#define BLUETOOTH_ATT_ERROR_WRITE_NOT_PERMITTED                        0x03
+#define BLUETOOTH_ATT_ERROR_INVALID_PDU                                0x04
+#define BLUETOOTH_ATT_ERROR_AUTHENTICATION                     0x05
+#define BLUETOOTH_ATT_ERROR_REQUEST_NOT_SUPPORTED              0x06
+#define BLUETOOTH_ATT_ERROR_INVALID_OFFSET                     0x07
+#define BLUETOOTH_ATT_ERROR_AUTHORIZATION                      0x08
+#define BLUETOOTH_ATT_ERROR_PREPARE_QUEUE_FULL                 0x09
+#define BLUETOOTH_ATT_ERROR_ATTRIBUTE_NOT_FOUND                        0x0A
+#define BLUETOOTH_ATT_ERROR_ATTRIBUTE_NOT_LONG                 0x0B
+#define BLUETOOTH_ATT_ERROR_INSUFFICIENT_ENCRYPTION_KEY_SIZE   0x0C
+#define BLUETOOTH_ATT_ERROR_INVALID_ATTRIBUTE_VALUE_LEN                0x0D
+#define BLUETOOTH_ATT_ERROR_UNLIKELY                           0x0E
+#define BLUETOOTH_ATT_ERROR_INSUFFICIENT_ENCRYPTION            0x0F
+#define BLUETOOTH_ATT_ERROR_UNSUPPORTED_GROUP_TYPE             0x10
+#define BLUETOOTH_ATT_ERROR_INSUFFICIENT_RESOURCES             0x11
+/* Common profile error codes */
+#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
+
+/*
+ * Bluetooth ATT error codes specific to OTP
+ */
+#define BLUETOOTH_OTP_ERROR_WRITE_REQUEST_REJECTED     0x80
+#define BLUETOOTH_OTP_ERROR_OBJECT_NOT_SELECTED        0x81
+#define BLUETOOTH_OTP_ERROR_CONCURRENCY_LIMIT_EXCEEDED 0x82
+#define BLUETOOTH_OTP_ERROR_OBJECT_NAME_EXISTS         0x83
+
+/*
+ * Bluetooth OTP error codes
+ * TODO: Check error code conflict
+ */
+#define BLUETOOTH_ERROR_INVALID_DIRECTORY      0x01
+#define BLUETOOTH_ERROR_NO_OBJECTS_FOUND       0x02
 
 /**
  * Device disconnection reasons; received from stack
@@ -202,8 +246,6 @@ extern "C" {
 #define BLUETOOTH_ERROR_CONNECTION_TERMINATED_DUE_TO_MIC_FAILURE 0x3d
 #define BLUETOOTH_ERROR_CONNECTION_FAILED_TO_BE_ESTABLISHED    0x3e
 
-#define BLUETOOTH_ERROR_INVALID_DIRECTORY 0x01
-
 /**
 * Device disconnect reason
 */
@@ -230,6 +272,15 @@ typedef enum {
 } bluetooth_device_address_type_t;
 
 /**
+ * This is BD Address type defined in kernel BT header
+ */
+typedef enum {
+       BLUETOOTH_BDADDR_BREDR = 0x00,
+       BLUETOOTH_BDADDR_LE_PUBLIC = 0x01,
+       BLUETOOTH_BDADDR_LE_RANDOM = 0x02
+} bluetooth_bdaddr_type_e;
+
+/**
  * This is Bluetooth version
  */
 typedef struct {
@@ -489,6 +540,32 @@ typedef struct {
 } bluetooth_tds_transport_data_info_t;
 
 /**
+* OTP Characteristics Value
+*/
+typedef struct {
+       int length;                                                     /**< Characteristics value length */
+       guint8 data[BLUETOOTH_OTP_CHARC_VAL_MAX_LENGTH];        /**< Characteristics data */
+} bluetooth_otp_charc_data_t;
+
+/**
+* Structure to hold the OTP response data from remote OTP server
+*/
+typedef struct {
+       char *handle;      /**< Handle */
+       int data_length;                        /**< Data length */
+       char *data;                             /**< Read data */
+} bluetooth_otp_resp_info_t;
+
+/**
+* Structure to hold the OTC Channel Info
+*/
+typedef struct {
+       gboolean connected;     /**< Connection Status */
+       int fd;                         /**< Fd */
+       char *address;      /**< Remote address */
+} bluetooth_otc_info_t;
+
+/**
 * Advertising parameters
 */
 typedef struct {
@@ -805,6 +882,11 @@ typedef enum {
        BLUETOOTH_EVENT_TDS_ACTIVATION_INDICATION,    /** TDS Activation Indication from Provider */
 
        BLUETOOTH_EVENT_OTP_SERVER_STATE_CHANGED,       /* OTP Server Status **/
+       BLUETOOTH_EVENT_OTP_READ_CHAR_VAL,      /* OTP Read Value Response */
+       BLUETOOTH_EVENT_OTP_NOTIFICATION_ENABLED,       /* OTP Notification Enabled Response */
+       BLUETOOTH_EVENT_OTP_WRITE_CHAR_VAL,     /* OTP Write Value Response */
+       BLUETOOTH_EVENT_OTP_INDICATION, /* OTP Indication */
+       BLUETOOTH_EVENT_OTC_STATE_CHANGED,              /* OTC Connection State Changed Event */
 } bluetooth_event_type_t;
 
  /**
@@ -1239,7 +1321,9 @@ typedef enum {
        HTYPE_TRANS_GET_PROTOCOL,
        HTYPE_TRANS_SET_PROTOCOL,
        HTYPE_TRANS_DATA,
-       HTYPE_TRANS_UNKNOWN
+       HTYPE_TRANS_UNKNOWN,
+       HTYPE_TRANS_GET_IDLE = 0xF0,
+       HTYPE_TRANS_SET_IDLE = 0xF1,
 } bt_hid_header_type_t;
 
 /**
@@ -1561,6 +1645,15 @@ typedef struct {
 } bt_gatt_indicate_confirm_t;
 
 /**
+ * Structure for GATT response data
+ */
+typedef struct {
+       guint8 *value;
+       guint32 len;
+       gpointer user_data;
+} bt_gatt_resp_data_t;
+
+/**
  * Structure to RSSI Signal Strength Alert
  */
 
@@ -2236,6 +2329,7 @@ int bluetooth_check_adapter_le(void);
 int bluetooth_enable_adapter_le(void);
 
 int bluetooth_disable_adapter_le(void);
+int bluetooth_get_uuid_name(const char *uuid, char **name);
 
 /**
  * @fn int bluetooth_reset_adapter(void)
@@ -5081,6 +5175,7 @@ int bluetooth_oob_read_local_data(bt_oob_data_t *local_oob_data);
 /**
  * @fn int bluetooth_oob_add_remote_data(
  *                     const bluetooth_device_address_t *remote_device_address,
+ *                     bluetooth_bdaddr_type_e address_type,
  *                     bt_oob_data_t *oob_data)
  * @brief Add/updated the remote device  Hash and Randmizer.
  *
@@ -5092,6 +5187,7 @@ int bluetooth_oob_read_local_data(bt_oob_data_t *local_oob_data);
  *
  * @exception  None
  * @param[in] remote_device_address - Remote device address
+  *          address_type - bdaddr type
  *           remote_oob_data - Ponter to Hash and Randomizer oob data structure
  *
  * @remark     None
@@ -5100,6 +5196,7 @@ int bluetooth_oob_read_local_data(bt_oob_data_t *local_oob_data);
 
 int bluetooth_oob_add_remote_data(
                   const bluetooth_device_address_t *remote_device_address,
+                  bluetooth_bdaddr_type_e address_type,
                   bt_oob_data_t *remote_oob_data);
 
 
@@ -5197,7 +5294,7 @@ int bluetooth_gatt_get_service_property(const char *service_handle,
                                                bt_gatt_service_property_t *service);
 
 /**
- * @fn int bluetooth_gatt_watch_characteristics(const char *service_handle)
+ * @fn int bluetooth_gatt_watch_characteristics(const char *service_handle, const char *svc_name)
  *
  * @brief Register to GATT based service to receive value change notification/indication.
  *
@@ -5211,11 +5308,12 @@ int bluetooth_gatt_get_service_property(const char *service_handle,
  *
  * @exception  None
  * @param[in]  service_handle - Handle for remote service.
+ * @param[in]  service_name - Friednly name of service uuid.
  *
  * @remark     None
  * @see        None
  */
-int bluetooth_gatt_watch_characteristics(const char *service_handle);
+int bluetooth_gatt_watch_characteristics(const char *service_handle, const char *svc_name);
 
 /**
  * @fn int bluetooth_gatt_unwatch_characteristics(const char *service_handle)
@@ -5335,7 +5433,8 @@ int bluetooth_gatt_set_characteristics_value(const char *char_handle,
  * @see                None
  */
 int bluetooth_gatt_set_characteristics_value_by_type(const char *char_handle,
-                               const guint8 *value, int length, guint8 write_type);
+                                       const guint8 *value, int length,
+                                       guint8 write_type, gpointer app_data);
 
 
 /**
@@ -5380,7 +5479,7 @@ int bluetooth_gatt_set_characteristics_value_request(const char *char_handle,
  * @remark     None
  * @see        None
  */
-int bluetooth_gatt_read_characteristic_value(const char *char_handle);
+int bluetooth_gatt_read_characteristic_value(const char *char_handle, gpointer app_data);
 
 /**
  * @fn int bluetooth_gatt_get_service_from_uuid(bluetooth_device_address_t *address,
@@ -5547,7 +5646,7 @@ int bluetooth_gatt_discover_characteristic_descriptor(const char *characteristic
  * @remark     None
  * @see        None
  */
-int bluetooth_gatt_read_descriptor_value(const char *desc_handle);
+int bluetooth_gatt_read_descriptor_value(const char *desc_handle, gpointer app_data);
 
 /**
  * @fn int bluetooth_gatt_write_descriptor_value(const char *desc_handle,
@@ -5571,7 +5670,7 @@ int bluetooth_gatt_read_descriptor_value(const char *desc_handle);
  * @see        None
  */
 int bluetooth_gatt_write_descriptor_value(const char *desc_handle,
-                       const guint8 *value, int length);
+                       const guint8 *value, int length, gpointer app_data);
 
 /* @fn int bluetooth_gatt_init(void)
 *
@@ -7550,6 +7649,93 @@ int bluetooth_otp_server_init(const char *directory);
 int bluetooth_otp_server_deinit();
 
 /**
+ * @fn int bluetooth_otp_enable_notification(const char *handle);
+ *
+ * @brief Enable notification for remote OACP & OLCP characteristics.
+ *
+ * This function is a synchronous call.
+ *
+ * @return
+ *
+ * @exception  None
+ * @param[in] None
+ * @param[out] None
+ *
+ * @remark     None
+ */
+int bluetooth_otp_enable_notification(const char *handle);
+
+/**
+ * @fn int bluetooth_otp_write_characteristics_value( const char *handle,
+ *                                             unsigned char *buf, int length);
+ *
+ * @brief Write value on remote characteristics.
+ *
+ * This function is a synchronous call.
+ *
+ * @return
+ *
+ * @exception  None
+ * @param[in] None
+ * @param[out] None
+ *
+ * @remark     None
+ */
+int bluetooth_otp_write_characteristics_value( const char *handle,
+                                       unsigned char *buf, int length);
+
+/**
+ * @fn int bluetooth_otp_read_characteristic_value(const char *handle);
+ *
+ * @brief Read value for remote characteristics.
+ *
+ * This function is a synchronous call.
+ *
+ * @return
+ *
+ * @exception  None
+ * @param[in] None
+ * @param[out] None
+ *
+ * @remark     None
+ */
+int bluetooth_otp_read_characteristic_value(const char *handle);
+
+/**
+ * @fn int bluetooth_otp_connect_otc(const bluetooth_device_address_t *device_address);
+ *
+ * @brief Read value for remote characteristics.
+ *
+ * This function is a synchronous call.
+ *
+ * @return
+ *
+ * @exception  None
+ * @param[in] None
+ * @param[out] None
+ *
+ * @remark     None
+ */
+int bluetooth_otp_connect_otc(const bluetooth_device_address_t *device_address);
+
+/**
+ * @fn int bluetooth_otp_disconnect_otc(const bluetooth_device_address_t *device_address);
+ *
+ * @brief Read value for remote characteristics.
+ *
+ * This function is a synchronous call.
+ *
+ * @return
+ *
+ * @exception  None
+ * @param[in] None
+ * @param[out] None
+ *
+ * @remark     None
+ */
+int bluetooth_otp_disconnect_otc(const bluetooth_device_address_t *device_address);
+
+/**
  * @}
  */