Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2154032iob; Fri, 20 May 2022 03:19:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1QUb32PxcE56rgdgUl7aImZUokPSjN1NzSPrg6IZYES7IVeEHjQNHFHjaM78ebxRsd+eb X-Received: by 2002:a17:902:7ec9:b0:15f:3ba3:7451 with SMTP id p9-20020a1709027ec900b0015f3ba37451mr9111889plb.15.1653041982849; Fri, 20 May 2022 03:19:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653041982; cv=none; d=google.com; s=arc-20160816; b=Ni8xs4ewm0S3v7zRET7tv9ivP1jwMAhBEEszuznsJQ9Nq8MSTXoAy6L2O7Odl3IhlH kBfzfPWF2H64NUUAUN9R9dRQBn2WVJ/30fv12xdKh1ccjfNnEKF/egqxBf5lGORlAGSI pexB7QCg/X5EjnGphP/ULXTHQXZyCLtzGzHS1pTFUQ/29mWJLOWOamuzhb3h/TwXvp9r QuI6sTHz9oD5vqvPkmCgtuq5vepzddSvkXgPkHdqbWMs/mbrLZMc7vj1/AHZbrrmWfh8 HC8946I//XH5SfKmBJGM87fqTZSM+TYW6IHb6aROGM1HvGh/WhlkxcdG9w4SiyY3BjyK S8ZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=X1tWqgEEva7mkuzTKbVhg+7xlep5rVnxIn+4oJ8Ey4k=; b=qiOGNCherNFxyboVVLSNNejIdpuHpSfOF8FqxK/zU50649miW1yAwv9uLRsxnqxJkK DDlx1rp33FkEa2eQQN1hvHg3Zi5k+znwDlHcCD/0/yYZbBCiX6/zf5p7QXvMHwfjMzKm Yz+eWn4gKXmngnT/0eOccbtH8ibZItlvCyiuegegDTNaD+IP0LcU52ZN1G0B82X+xuKS 9f410YOEvTw4MGPn17dtmmzqFvCauFXlyuGO+m7FvAVn+rmd4TwX3fqeeNnup6xprjZU dgk5royiuGZdJ6R60GxqIyx7KkzlVbQAhGegVhtSqZJcRH8RS/UIloy7EJ9DQs4uaj/L phGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ORzOywuL; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d5-20020a170902cec500b0015ec0ebd289si11126027plg.211.2022.05.20.03.19.08; Fri, 20 May 2022 03:19:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ORzOywuL; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233740AbiETERF (ORCPT + 99 others); Fri, 20 May 2022 00:17:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233029AbiETERF (ORCPT ); Fri, 20 May 2022 00:17:05 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 534426B671 for ; Thu, 19 May 2022 21:17:04 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id a19so6742439pgw.6 for ; Thu, 19 May 2022 21:17:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=X1tWqgEEva7mkuzTKbVhg+7xlep5rVnxIn+4oJ8Ey4k=; b=ORzOywuLtxLy8TNUaOO1kJq2fokVfdNHZonenAOzur8tHwDsXZlfNn9TTxpT03SXWd h+OCmPxeqxb13PNvgEVs3ZVUYQ/87A2jZ9d9vB7lbztuiwIrAF+DesszgPIgJ5fPRgdx YqpVpfz2Ml1ai4WpVxjYZbbG1Chc1wF5QrpHjltM8oIJf2heZjyefM8Hqvqc9Y2xyfnm dkSzq1SaUh+D/a5mcLUs7sNLxbLM9UHtqiG/xgqNIcWnlzqyZ82ASpi09JUHFCrYER9Z eC+IxG7xCWgFKOryt1v3EOZBQD0PtmTkQPF8U3w8aTTsuw/Yn86H0EPr5T96Q6Yjtytm KoLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=X1tWqgEEva7mkuzTKbVhg+7xlep5rVnxIn+4oJ8Ey4k=; b=RaIpyeozntu83EkBAiwLkFnLTEAp4eomz7FzMkcxZdro0S7o4B5x4SPirxdSPugAuB fssVmZGwJJ8Z7lAJt0BerzkpFc2bfS0fO8viuJKyImPeDevca8V2UzbaeBkpaqdo3D8H ZyCqXQ6ZmVIRwDwytKk2p4S1JXkSkudPxXXaSfkFni3dDtvW1/FvfJtY32qMU+YylEpF msxcofE7R1fUknTzTf3dukZDKzAqGJAzlIUAsX1XE66hXxg+WUb9+i7I4YS5wcNz6sDT tGMoKCyTOw46Flu8T8rqX23Pxs+scLEu4VvjX/hnGPMFpr8QTEqXvbn6k6JikOkUvZgq PJTw== X-Gm-Message-State: AOAM532k4Ti6LDAnwNJqpOcdS54vvhjRj5T/xE1BcO4x6GvTIgJjvZKR aJA73dacOFkwDsX/cpXONjeCSVPEjjY= X-Received: by 2002:a63:5357:0:b0:3f2:6210:f8e9 with SMTP id t23-20020a635357000000b003f26210f8e9mr6670136pgl.158.1653020223536; Thu, 19 May 2022 21:17:03 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id u13-20020a17090a450d00b001df955c28f6sm381405pjg.37.2022.05.19.21.17.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 May 2022 21:17:02 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v2 2/7] gatt: Store local GATT database Date: Thu, 19 May 2022 21:16:56 -0700 Message-Id: <20220520041701.2572197-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220520041701.2572197-1-luiz.dentz@gmail.com> References: <20220520041701.2572197-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This enables storing the local (adapter) GATT database which later will be used by btmon to decode GATT handles. --- src/gatt-database.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/gatt-database.c b/src/gatt-database.c index d32f616a9..cf651b5f5 100644 --- a/src/gatt-database.c +++ b/src/gatt-database.c @@ -38,6 +38,8 @@ #include "dbus-common.h" #include "profile.h" #include "service.h" +#include "textfile.h" +#include "settings.h" #define GATT_MANAGER_IFACE "org.bluez.GattManager1" #define GATT_PROFILE_IFACE "org.bluez.GattProfile1" @@ -1528,6 +1530,17 @@ static void send_service_changed(struct btd_gatt_database *database, error("Failed to notify Service Changed"); } +static void database_store(struct btd_gatt_database *database) +{ + char filename[PATH_MAX]; + + create_filename(filename, PATH_MAX, "/%s/attributes", + btd_adapter_get_storage_dir(database->adapter)); + create_file(filename, 0600); + + btd_settings_gatt_db_store(database->db, filename); +} + static void gatt_db_service_added(struct gatt_db_attribute *attrib, void *user_data) { @@ -1538,6 +1551,8 @@ static void gatt_db_service_added(struct gatt_db_attribute *attrib, database_add_record(database, attrib); send_service_changed(database, attrib); + + database_store(database); } static bool ccc_match_service(const void *data, const void *match_data) -- 2.35.1