Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp566350lqo; Fri, 10 May 2024 08:09:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXaUgzAy/0c67B/TueaPo9eIA/uV1KqDyWueyvc1fpuiJAkPyiic02RHg3tFnya4t2McIyFVxuOeg2vqVEN/zbpclMgUzS+p7y7F7xsEg== X-Google-Smtp-Source: AGHT+IFF95327Y1nvUeugtKW3ah6yxsICdHG9XVNKFR+ZLh4Q3xK89a3N7nTOGnFzl1/9k+dqbA/ X-Received: by 2002:a05:6214:3a8a:b0:6a0:b479:52bb with SMTP id 6a1803df08f44-6a168140b0fmr26529396d6.11.1715353791956; Fri, 10 May 2024 08:09:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715353791; cv=pass; d=google.com; s=arc-20160816; b=RDX0S+owlW/nhF7tWp0LEDJebCGLgEZqDEbyUotRjKuZ98xqoyzpb3Yu0b43jm+dCM IZZkfhvNLLVMr+LkyaKcQ/uLQLHKEXNCDMywmYptPhBAoJxj6V0uj6APCidiXPIw3/ca 0d/aMzgXdOvkbBGxIXBIj1RrJjikWLvDSb6d1WFidvHbfixpzxKrbiDD/S3nUuW9nVBX JGh6klMbXxh8MHBCcZBrM5VD+MehFKoxa3mbcsWiFCnDwl7AlVs230hfaFNI9Ea+ak8J RMfldHK5eeXMHI5/qoFt6GsScKf5peJhSj8FZM19iOd7MOei9Yx1IC8yAae882Gxskz2 /iFA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=+NYPamNuvUWNaKXtsTZIVx1vuT1dcpKc6L70cng3uqM=; fh=4lGQI6056MBa4/oovMyIYaKLn+Wz/24RGvUivMmQP8E=; b=aiPMwQ2gF1qMmMGBt9Rett8PY+9gM9WlVIr4EBzbqPqTODN3RUi9gM/4bG5I/wv+Vk QPi60cHLmRxQJkfUSdyyjsa5dt5HEcCxen0qZNJP52yYr+aIDkg8Ev6/0W3w9tgbnjaL 3zn/JwoNSFeb+j9kglS4/8EwpXMQlgX4BDgBAndla35xB0DOFNyvf6BR/BbhOMR7mAwj v6pTIJUEOiVMFzNTb+RGkUy5yydsTJaOMIaZGS21zgInSdj5+tsxBCx+5osHCOZibdYp QVYqMkyuVqonktyvS0bimPGsKJBy/qBkfftkbOenBzlPU0hDdalt8JHy2iLQkzsZRJTY Cevg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=COloPPDO; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-bluetooth+bounces-4500-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4500-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6a15f2b5ffdsi37506486d6.356.2024.05.10.08.09.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 08:09:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-4500-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=COloPPDO; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-bluetooth+bounces-4500-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4500-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9D6491C23D63 for ; Fri, 10 May 2024 15:09:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DA903171647; Fri, 10 May 2024 15:09:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="COloPPDO" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-yb1-f174.google.com (mail-yb1-f174.google.com [209.85.219.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBFDC17108A for ; Fri, 10 May 2024 15:09:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715353785; cv=none; b=XEuOulRu10FHg+Oapn5Of5rWsQIhMh2fnPUplRWEuSueo9D+zcsHZuPJCTbARUF7EsZrnz0bWkz0QLUcv/T/xjL5eV8rUu+VmrtzluOyeL5LxX3Z9LDtzeSfE7ypQ758/lblCTQeUwflE1NWdaiw2+baFBTALm2ws8ke/rPUHgc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715353785; c=relaxed/simple; bh=rlrNutOX/JtzQ2vvYouzl+ju8rzQd9ExsU6WNCQAOKQ=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QipZMLZ+GlzDJV+owmUoyk0Cm4cc3vThm7FjSs77ecyDu7X1JpJND4/tn6IokPKr/5EbNS1hhqU8XUm9Iezkgon/VSCfw1ZhgBiYbtibpInCEyHsCcYqtIsCKibNHnFiGthsIQ0fFonm+Q3YBweGfaU6KLwozehZACPu/7R6GQc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=COloPPDO; arc=none smtp.client-ip=209.85.219.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-yb1-f174.google.com with SMTP id 3f1490d57ef6-dcd7c526cc0so2339356276.1 for ; Fri, 10 May 2024 08:09:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715353782; x=1715958582; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=+NYPamNuvUWNaKXtsTZIVx1vuT1dcpKc6L70cng3uqM=; b=COloPPDOFfzze7ik19N28aVRjxl5Mnlp16V80gVpf6OW9JPqJdCp0mNMlnzQEhtQCW vtegHRwiCd2E9s3Hfsp8/96HyM0BeKIzYQn2YQ7x3iY9H6XtHogk0FdiWTI214bw9cQ9 IP9NZlX3P3L2yPyc9hIDCPWb7pF+Dni0R5k7mrdh1OS92aT7aPLUz6XI/pK5fs6RFImT PnV5kazNdAglBW5AipNq6AfVz6EorKrwMSR6/Y0KEeKv+EOLXil5ClQvK6e0i7oAaEQB zhH7f8V5h/GxcAiGBFm6PbsxObCzzrNBIavufP/1TPeaXXe0WkwIABO87oGJIgaI4OBe Hfjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715353782; x=1715958582; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+NYPamNuvUWNaKXtsTZIVx1vuT1dcpKc6L70cng3uqM=; b=JDQlTz7Sx1rNnHEEZFZASjgB6dSjXZFddV6xs4esfXFFSCMZz/MgXB4X6Tc1CNhr02 d2uMjjBwNYEOI3HwDkIS/tGldQdNTwwdPOG5Q0p+wZTqehcLf+UTOinwodf7C7JR+60Y 30k7toRfeE2peRlaZSAl+cL/rLOkfXdEjaIubz6geofSgzbiRq+M619ZSeWCx0PdFFQi I4dAvrJCrlyTzgg/cQU/eTGy1dy8klBvd4vdVaeDuY7VlcPVCapWR0ATbW7t4Ajf928h nHv6xPugrBh/DUgM5kKjN9wJbxXZ1lOzn1osGrm54NyNQ2SoUZxG+1kFtnudWFdeJ0Zx 8XQw== X-Gm-Message-State: AOJu0YyWKO/OV2Tz7gC3dqcGOdXesPavAPqEufsoWmPZ5wQDAvfexCXU KgVC+ND5pjJxy16P+8FvYPXQUc+8+a6XoI4OVRtiMVcUgv8kksIqa99yqg== X-Received: by 2002:a25:b985:0:b0:de6:168f:f2d7 with SMTP id 3f1490d57ef6-dee4f4ee845mr3064185276.55.1715353781886; Fri, 10 May 2024 08:09:41 -0700 (PDT) Received: from lvondent-mobl4.. (syn-107-146-107-067.res.spectrum.com. [107.146.107.67]) by smtp.gmail.com with ESMTPSA id ada2fe7eead31-4806cb008d2sm510050137.2.2024.05.10.08.09.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 08:09:40 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v3 2/4] src/adapter: Added connection parameter load/store functions Date: Fri, 10 May 2024 11:09:36 -0400 Message-ID: <20240510150938.1492169-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240510150938.1492169-1-luiz.dentz@gmail.com> References: <20240510150938.1492169-1-luiz.dentz@gmail.com> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: "Felipe F. Tonello" It is interesting to let other parts of bluetoothd to access these functions since there are few different use-cases where this updating and loading connection parameters can happen. --- src/adapter.c | 34 +++++++++++++++++++++++++++++----- src/adapter.h | 10 ++++++++++ 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 5505edbb29c1..4943e5e88e70 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -4635,6 +4635,30 @@ static void load_conn_params(struct btd_adapter *adapter, GSList *params) btd_error(adapter->dev_id, "Load connection parameters failed"); } +void btd_adapter_load_conn_param(struct btd_adapter *adapter, + const bdaddr_t *peer, uint8_t bdaddr_type, + uint16_t min_interval, uint16_t max_interval, + uint16_t latency, uint16_t timeout) +{ + GSList *params = NULL; + struct conn_param param; + + /* Only versions >= 1.23 support updating connection parameters */ + if (MGMT_VERSION(mgmt_version, mgmt_revision) >= MGMT_VERSION(1, 23)) + return; + + bacpy(¶m.bdaddr, peer); + param.bdaddr_type = bdaddr_type; + param.max_interval = max_interval; + param.min_interval = min_interval; + param.latency = latency; + param.timeout = timeout; + + params = g_slist_append(params, ¶m); + load_conn_params(adapter, params); + g_slist_free(params); +} + static uint8_t get_addr_type(GKeyFile *keyfile) { uint8_t addr_type; @@ -8919,10 +8943,10 @@ static void new_irk_callback(uint16_t index, uint16_t length, btd_device_set_temporary(device, false); } -static void store_conn_param(struct btd_adapter *adapter, const bdaddr_t *peer, - uint8_t bdaddr_type, uint16_t min_interval, - uint16_t max_interval, uint16_t latency, - uint16_t timeout) +void btd_adapter_store_conn_param(struct btd_adapter *adapter, + const bdaddr_t *peer, uint8_t bdaddr_type, + uint16_t min_interval, uint16_t max_interval, + uint16_t latency, uint16_t timeout) { char device_addr[18]; char filename[PATH_MAX]; @@ -9002,7 +9026,7 @@ static void new_conn_param(uint16_t index, uint16_t length, if (!ev->store_hint) return; - store_conn_param(adapter, &ev->addr.bdaddr, ev->addr.type, + btd_adapter_store_conn_param(adapter, &ev->addr.bdaddr, ev->addr.type, ev->min_interval, ev->max_interval, ev->latency, ev->timeout); } diff --git a/src/adapter.h b/src/adapter.h index 2ca045539ec0..3534986f5a72 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -289,3 +289,13 @@ bool btd_adapter_set_allowed_uuids(struct btd_adapter *adapter, struct queue *uuids); bool btd_adapter_is_uuid_allowed(struct btd_adapter *adapter, const char *uuid_str); + +void btd_adapter_load_conn_param(struct btd_adapter *adapter, + const bdaddr_t *peer, uint8_t bdaddr_type, + uint16_t min_interval, uint16_t max_interval, + uint16_t latency, uint16_t timeout); + +void btd_adapter_store_conn_param(struct btd_adapter *adapter, + const bdaddr_t *peer, uint8_t bdaddr_type, + uint16_t min_interval, uint16_t max_interval, + uint16_t latency, uint16_t timeout); -- 2.44.0