Fix SAM tool violations (GlobalVariable)
[platform/core/connectivity/bluetooth-frwk.git] / bt-oal / oal-gatt.c
index 355427f..4fd1513 100644 (file)
@@ -1621,7 +1621,7 @@ static void cb_gattc_read_characteristic(int conn_id, int status, btgatt_read_pa
 {
        char uuid_str1[2*BT_UUID_STRING_MAX];
        char uuid_str2[2*BT_UUID_STRING_MAX];
-       BT_INFO("BTGATT Client Read Charcateristic Callback, conn_id:%d, read_status:%d", conn_id, status);
+       BT_DBG("BTGATT Client Read Charcateristic Callback, conn_id:%d, read_status:%d", conn_id, status);
 
        event_gattc_read_data *event = g_new0(event_gattc_read_data, 1);
        event->uuid_status.conn_status.conn_id = conn_id;
@@ -1632,9 +1632,9 @@ static void cb_gattc_read_characteristic(int conn_id, int status, btgatt_read_pa
        if (status == 0) {
                uuid_to_stringname((oal_uuid_t *)&(p_data->srvc_id.id.uuid), uuid_str1);
                uuid_to_stringname((oal_uuid_t *)&(p_data->char_id.uuid), uuid_str2);
-               BT_INFO("Service=> [%s], Inst_id [%u], Type [%s]", uuid_str1,
+               BT_DBG("Service=> [%s], Inst_id [%u], Type [%s]", uuid_str1,
                        p_data->srvc_id.id.inst_id, p_data->srvc_id.is_primary ? "Primary" : "Secondary");
-               BT_INFO("Charac => [%s], Inst_id [%u]", uuid_str2, p_data->char_id.inst_id);
+               BT_DBG("Charac => [%s], Inst_id [%u]", uuid_str2, p_data->char_id.inst_id);
                BT_DBG("Len: %u, value_type: %u", p_data->value.len, p_data->value_type);
                if (p_data->value.len > 0 && event->value_type == GATTC_READ_VALUE_TYPE_VALUE) {
                        event->data_len = p_data->value.len;
@@ -1670,7 +1670,7 @@ static void cb_gattc_write_descriptor(int conn_id, int status, btgatt_write_para
        char uuid_str1[2*BT_UUID_STRING_MAX];
        char uuid_str2[2*BT_UUID_STRING_MAX];
        char uuid_str3[2*BT_UUID_STRING_MAX];
-       BT_INFO("BTGATT Client Write Descriptor Callback, conn_id:%d, write_status:%d", conn_id, status);
+       BT_DBG("BTGATT Client Write Descriptor Callback, conn_id:%d, write_status:%d", conn_id, status);
 
        event_gattc_write_data *event = g_new0(event_gattc_write_data, 1);
        event->conn_status.conn_id = conn_id;
@@ -1845,7 +1845,7 @@ oal_status_t gattc_connect(int client_id, bt_address_t *device_address, int isDi
        bdstr_t bdstr;
 
        OAL_CHECK_PARAMETER(device_address, return);
-       API_TRACE("Client Connect: [%s]", bdt_bd2str(device_address, &bdstr));
+       API_TRACE("Client Connect: [%s]", bdt_bd2str(device_address, &bdstr) + 12);
        CHECK_OAL_GATT_ENABLED();
        CHECK_CLIENT_REGISTRATION(client_id);
 
@@ -1865,7 +1865,7 @@ oal_status_t gattc_disconnect(int client_id, bt_address_t *device_address, int c
        bdstr_t bdstr;
 
        OAL_CHECK_PARAMETER(device_address, return);
-       API_TRACE("Client Disconnect: [%s]", bdt_bd2str(device_address, &bdstr));
+       API_TRACE("Client Disconnect: [%s]", bdt_bd2str(device_address, &bdstr) + 12);
        CHECK_OAL_GATT_ENABLED();
        CHECK_CLIENT_REGISTRATION(client_id);
        CHECK_CLIENT_CONNECTION(conn_id);
@@ -2159,10 +2159,9 @@ oal_status_t gattc_conn_param_update(bt_address_t * address, int min, int max, i
        bdstr_t bdstr;
 
        OAL_CHECK_PARAMETER(address, return);
-       API_TRACE("Conn Param Update: [%s]", bdt_bd2str(address, &bdstr));
        CHECK_OAL_GATT_ENABLED();
 
-       BT_INFO("[%s] min[%d] max[%d] latency[%d] timeout[%d]", bdt_bd2str(address, &bdstr), min, max, latency, timeout);
+       BT_DBG("[%s] min[%d] max[%d] latency[%d] timeout[%d]", bdt_bd2str(address, &bdstr), min, max, latency, timeout);
        ret = gatt_api->client->conn_parameter_update((bt_bdaddr_t *)address, min, max, latency, timeout);
        if (ret != BT_STATUS_SUCCESS) {
                BT_ERR("error: %s", status2string(ret));
@@ -2430,6 +2429,30 @@ oal_status_t gattc_register_scan_filter(oal_ble_scan_filter_t* filter_data)
        return OAL_STATUS_SUCCESS;
 }
 
+oal_status_t gattc_get_att_mtu(int conn_id, int *mtu)
+{
+       int ret = OAL_STATUS_SUCCESS;
+       API_TRACE("Get ATT MTU, conn_id: %d", conn_id);
+       CHECK_OAL_GATT_ENABLED();
+       CHECK_CLIENT_CONNECTION(conn_id);
+       OAL_CHECK_PARAMETER(mtu, return);
+
+       /* To prevent crash in case other libraries not support this api */
+       if (gatt_api->client->get_att_mtu == NULL) {
+               BT_WARN("get_att_mtu is NULL");
+               return OAL_STATUS_NOT_SUPPORT;
+       }
+
+       ret = gatt_api->client->get_att_mtu(conn_id, mtu);
+       if (ret != BT_STATUS_SUCCESS) {
+               BT_ERR("GATT MTU Size failed, status: %s", status2string(ret));
+               return convert_to_oal_status(ret);
+       }
+
+       BT_INFO("Current ATT MTU Size: %d", *mtu);
+       return OAL_STATUS_SUCCESS;
+}
+
 oal_status_t gattc_configure_mtu(int conn_id, int mtu)
 {
        int ret;
@@ -2500,11 +2523,8 @@ oal_status_t gattc_add_connection_info(bt_address_t *device_address, int conn_id
        bdstr_t bdstr;
 
        OAL_CHECK_PARAMETER(device_address, return);
-       API_TRACE("Add connection info: [%s]", bdt_bd2str(device_address, &bdstr));
+       API_TRACE("Add connection info: [%s]", bdt_bd2str(device_address, &bdstr) + 12);
        CHECK_OAL_GATT_ENABLED();
-       CHECK_SERVER_INSTANCE(instance_id);
-       if (__gatts_find_server_instance(instance_id) == NULL)
-               return OAL_STATUS_INTERNAL_ERROR;
 
        ret = gatt_api->client->add_connection_info((bt_bdaddr_t *)device_address, conn_id, instance_id);
        if (ret != BT_STATUS_SUCCESS) {