Fix the svace issue (DEREF_OF_NULL)
[platform/core/connectivity/bluetooth-frwk.git] / include / bluetooth-api.h
index af81b14..47aa397 100644 (file)
@@ -22,6 +22,8 @@
 #include <stdbool.h>
 #include <unistd.h>
 #include <glib.h>
+#include <stdint.h>
+
 
 #ifdef __cplusplus
 extern "C" {
@@ -56,11 +58,11 @@ extern "C" {
 
 #define BLUETOOTH_OOB_DATA_LENGTH 16
 
+#define BLUETOOTH_LE_OOB_DATA_LENGTH 100
+
 #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
@@ -245,6 +247,7 @@ extern "C" {
 #define BLUETOOTH_ERROR_AUTH_FAILURE   0x05
 #define BLUETOOTH_ERROR_PIN_OR_KEY_MISSING     0x06
 #define BLUETOOTH_ERROR_CONNECTION_TIMEOUT     0x08
+#define BLUETOOTH_ERROR_CONNECTION_REJECTED_DUE_TO_SECURITY_REASONS 0x0e
 #define BLUETOOTH_ERROR_REMOTE_USER_TERM       0x13
 #define BLUETOOTH_ERROR_REMOTE_LOW_RESOURCES   0x14
 #define BLUETOOTH_ERROR_REMOTE_POWER_OFF       0x15
@@ -318,6 +321,29 @@ typedef struct {
 } bluetooth_device_pin_code_t;
 
 /**
+ * This is data for battery usage monitoring
+ */
+
+typedef struct {
+       time_t session_start_time;
+       time_t session_end_time;
+       uint32_t tx_time;
+       uint32_t rx_time;
+       uint32_t idle_time;
+       uint32_t session_connected_time;
+       uint32_t session_scan_time;
+       GSList *atm_list;
+} bt_battery_data;
+
+typedef struct {
+       uid_t uid;
+       pid_t pid;
+       uint32_t rx_bytes;
+       uint32_t tx_bytes;
+       uint time;
+} bt_battery_app_data;
+
+/**
  * Adapter state
  */
 typedef enum {
@@ -596,6 +622,14 @@ typedef struct {
        float window;  /**< LE scan window */
 } bluetooth_le_scan_params_t;
 
+/**
+* LE Scan type
+*/
+typedef enum {
+       BLUETOOTH_LE_PASSIVE_SCAN = 0x00,
+       BLUETOOTH_LE_ACTIVE_SCAN
+} bluetooth_le_scan_type_t;
+
 /*
        LE Connection Update
  */
@@ -677,6 +711,8 @@ typedef struct {
                                                                /**< Base ID for IPSP events */
 #define BLUETOOTH_EVENT_MAP_BASE  ((int)(BLUETOOTH_EVENT_IPSP_BASE + 0x0020))
                                                                /**< Base ID for MAP events */
+#define BLUETOOTH_EVENT_MESH_BASE  ((int)(BLUETOOTH_EVENT_MAP_BASE + 0x0020))
+                                                               /**< Base ID for MAP events */
 
 /**
  * Bluetooth event type
@@ -686,6 +722,7 @@ typedef enum {
 
        BLUETOOTH_EVENT_ENABLED,                    /**< Bluetooth event adpater enabled */
        BLUETOOTH_EVENT_DISABLED,                   /**< Bluetooth event adpater disabled */
+       BLUETOOTH_EVENT_DISABLED_BATTERY_DATA,      /**< Bluetooth event adapter disabled battery data*/
        BLUETOOTH_EVENT_LE_ENABLED,                 /**< Bluetooth event adpater enabled */
        BLUETOOTH_EVENT_LE_DISABLED,                /**< Bluetooth event adpater disabled */
        BLUETOOTH_EVENT_LOCAL_NAME_CHANGED,         /**< Bluetooth event local name changed*/
@@ -798,16 +835,12 @@ 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_ATT_MTU_CHANGED, /**<Attribute protocol Server 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 */
        BLUETOOTH_EVENT_GATT_SERVER_VALUE_CHANGED, /** <GATT Characteristic/Descriptor Value change event */
@@ -833,6 +866,8 @@ typedef enum {
        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_AVRCP_VOLUME_CHANGED, /**<AVRCP service transport volume changed event*/
+       BLUETOOTH_EVENT_AUDIO_AVC_STATUS, /**<Absolute Volume Control status changed event*/
        BLUETOOTH_EVENT_HF_CONNECTED,
        BLUETOOTH_EVENT_HF_DISCONNECTED,
        BLUETOOTH_EVENT_HF_AUDIO_CONNECTED,
@@ -856,6 +891,7 @@ typedef enum {
        BLUETOOTH_EVENT_HF_CALLSETUP_DIALING,
        BLUETOOTH_EVENT_HF_CALLSETUP_ALERTING,
        BLUETOOTH_EVENT_HF_CIEV_DEVICE_STATUS_CHANGED,
+       BLUETOOTH_EVENT_AUDIO_AVC_MODE_CHANGED,
 
        BLUETOOTH_HID_CONNECTED = BLUETOOTH_EVENT_HID_BASE, /**< Input connectd event*/
        BLUETOOTH_HID_DISCONNECTED, /**< Input disconnectd event*/
@@ -908,6 +944,22 @@ typedef enum {
        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_MESH_SCAN_STARTED = BLUETOOTH_EVENT_MESH_BASE,
+       BLUETOOTH_EVENT_MESH_SCAN_FINISHED,
+       BLUETOOTH_EVENT_MESH_SCAN_RESULT,
+       BLUETOOTH_EVENT_MESH_AUTHENTICATION_REQUEST,
+       BLUETOOTH_EVENT_MESH_PROVISIONING_FINISHED,
+       BLUETOOTH_EVENT_MESH_NODE_BROWSED,
+       BLUETOOTH_EVENT_MESH_NODE_VENDOR_FEATURES,
+       BLUETOOTH_EVENT_MESH_NODE_KEY_CONFIGURED,
+       BLUETOOTH_EVENT_MESH_NODE_TTL_CONFIGURED,
+       BLUETOOTH_EVENT_MESH_MODEL_APPKEY_BIND,
+       BLUETOOTH_EVENT_MESH_MODEL_APPKEY_LIST,
+       BLUETOOTH_EVENT_MESH_MODEL_MSG_EXECUTED,
+       BLUETOOTH_EVENT_MESH_MODEL_SUBSCRIPTION_LIST,
+       BLUETOOTH_EVENT_MESH_MODEL_SUBSCRIPTION_CONFGURED,
+       BLUETOOTH_EVENT_MESH_MODEL_VIRTUAL_SUBSCRIPTION_CONFGURED,
+       BLUETOOTH_EVENT_MESH_MODEL_PUBLICATION_STATUS,
 } bluetooth_event_type_t;
 
  /**
@@ -1318,6 +1370,7 @@ typedef struct {
        bluetooth_device_address_t device_addr;
        unsigned char addr_type;
        int disc_reason;
+       int rssi;
 } bt_connection_info_t;
 
 /**
@@ -1527,6 +1580,9 @@ typedef struct {
        unsigned char randomizer256[BLUETOOTH_OOB_DATA_LENGTH];
        unsigned int hash256_len;
        unsigned int randomizer256_len;
+
+       unsigned char eir[BLUETOOTH_LE_OOB_DATA_LENGTH];
+       unsigned int eir_len;
 } bt_oob_data_t;
 
 /**
@@ -1536,13 +1592,10 @@ 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
  */
@@ -1551,7 +1604,6 @@ typedef struct {
        unsigned char uuid[16];
        char address[BLUETOOTH_ADDRESS_STRING_LENGTH];
 } bt_gatt_handle_property_t;
-#endif
 
 /**
  * Structure to GATT Remote service data
@@ -1563,9 +1615,7 @@ 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;
 
 /**
@@ -1604,12 +1654,10 @@ 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;
 
 /**
@@ -1621,13 +1669,11 @@ 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;
 
 /**
@@ -1676,6 +1722,8 @@ typedef struct {
        bluetooth_device_address_t device_addr;
        char *svc_path;
        bluetooth_gatt_service_change_type_t change_type;
+       int inst_id;
+       char *uuid;
 } bt_gatt_service_change_t;
 
 /**
@@ -2372,6 +2420,9 @@ ret = bluetooth_disable_adapter();
 @endcode
  */
 int bluetooth_disable_adapter(void);
+int bluetooth_read_battery_data(bt_battery_data *latest);
+int bluetooth_set_battery_monitor_state(bool state);
+int bluetooth_get_battery_monitor_state(void);
 int bluetooth_recover_adapter(void);
 int bluetooth_check_adapter_le(void);
 int bluetooth_enable_adapter_le(void);
@@ -3223,7 +3274,7 @@ is_le_scanning = bluetooth_is_le_scanning ();
  */
 gboolean bluetooth_is_le_scanning(void);
 
-gboolean bluetooth_is_scan_filter_supported(void);
+int  bluetooth_is_scan_filter_supported(gboolean *is_supported);
 
 /**
  * @fn int bluetooth_force_hcidump(int timeout)
@@ -3245,7 +3296,7 @@ gboolean bluetooth_is_scan_filter_supported(void);
 int bluetooth_force_hcidump(int timeout);
 
 /**
- * @fn int bluetooth_register_scan_filter(bluetooth_le_scan_filter_t *filter, int *slot_id)
+ * @fn int bluetooth_register_scan_filter(bluetooth_le_scan_filter_t *filter)
  * @brief Register scan filter.
  *
  * This function registers the scan filter.
@@ -3255,41 +3306,10 @@ int bluetooth_force_hcidump(int timeout);
  * @return     BLUETOOTH_ERROR_NONE - Success \n
  *
  * @param[in]   filter   scan filter to register
- * @param[out]  slot_id  the slot ID of scan filter
  *
  * @remark      None
  */
-int bluetooth_register_scan_filter(bluetooth_le_scan_filter_t *filter, int *slot_id);
-
-/**
- * @fn int bluetooth_unregister_scan_filter(int slot_id)
- * @brief Register scan filter.
- *
- * This function unregisters the scan filter.
- *
- * This function is a synchronous call.
- *
- * @return     BLUETOOTH_ERROR_NONE - Success \n
- *
- * @param[in]   slot_id  the slot ID of scan filter
- *
- * @remark      None
- */
-int bluetooth_unregister_scan_filter(int slot_id);
-
-/**
- * @fn int bluetooth_unregister_all_scan_filters(void)
- * @brief Register scan filter.
- *
- * This function usregisters all scan filters.
- *
- * This function is a synchronous call.
- *
- * @return     BLUETOOTH_ERROR_NONE - Success \n
- *
- * @remark      None
- */
-int bluetooth_unregister_all_scan_filters(void);
+int bluetooth_register_scan_filter(bluetooth_le_scan_filter_t *filter);
 
 /**
  * @fn int bluetooth_enable_rssi(const bluetooth_device_address_t *remote_address,
@@ -5224,6 +5244,51 @@ int bluetooth_oob_add_remote_data(
 int bluetooth_oob_remove_remote_data(
                        const bluetooth_device_address_t *remote_device_address);
 
+
+/**
+ * @fn int bluetooth_le_oob_read_local_data(bt_oob_data_t *local_oob_data)
+ * @brief Read the local Hash and Randmizer.
+ *
+ * This function is a synchronous call.
+ *
+ * @return   BLUETOOTH_ERROR_NONE  - Success \n
+ *           BLUETOOTH_ERROR_INTERNAL - Internal Error \n
+ *
+ * @exception  None
+ * @param[in]  None.
+ * @param[out] local_oob_data - Pointer to the local OOB data
+ *
+ * @remark       None
+ * @see        None
+ */
+int bluetooth_le_oob_read_local_data(bt_oob_data_t *local_oob_data);
+
+/**
+ * @fn int bluetooth_le_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.
+ *
+ * This function is a synchronous call.
+ * No event for this api..
+ *
+ * @return   BLUETOOTH_ERROR_NONE  - Success \n
+ *           BLUETOOTH_ERROR_INTERNAL - Internal Error \n
+ *
+ * @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
+ * @see                None
+ */
+int bluetooth_le_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);
+
 /**
  * @fn int bluetooth_gatt_get_primary_services(const bluetooth_device_address_t *address,
  *                                             bt_gatt_handle_info_t *prim_svc);
@@ -5610,19 +5675,20 @@ 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
+
+int bluetooth_get_gatt_data_batching_available_packets(
+       int *available_packets);
+
+int bluetooth_enable_gatt_data_batching(
+       const bluetooth_device_address_t *device_address, int packet_threshold, int timeout);
+
+int bluetooth_disable_gatt_data_batching(
+       const bluetooth_device_address_t *device_address);
 
  /**
  * @fn int bluetooth_gatt_discover_characteristic_descriptor(const char *characteristic_handle);
@@ -6233,6 +6299,26 @@ int bluetooth_set_scan_response_data(int handle, const bluetooth_scan_resp_data_
 int bluetooth_set_scan_parameters(bluetooth_le_scan_params_t *params);
 
 /**
+ * @fn intbluetooth_set_scan_type(bluetooth_le_scan_type_t scan_type);
+ *ss
+ * @brief Set scan type
+ *
+ * This function is used to set LE scan type
+ *
+ * This function is a synchronous call.
+ *
+ * @return     BLUETOOTH_ERROR_NONE - Success \n
+ *             BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
+ *             BLUETOOTH_ERROR_INTERNAL - Internal IPC error \n
+ *
+ * @exception  None
+ * @param[in]  scan_type - LE scan type
+ *
+ * @remark     None
+ */
+int bluetooth_set_scan_type(bluetooth_le_scan_type_t scan_type);
+
+/**
  * @fn int bluetooth_is_advertising(void)
  * @brief Check for the advertising is in-progress or not.
  *