Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1834962lqm; Fri, 3 May 2024 07:52:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVsJntyXJgkBUCEzbbVz7UgTLXP8kGk2ScGnJFi8/lzz6A/NL8XjfR0emqXOAJH2/BbQMiN4zkBxgqD3LNByt2yNYyTRulXiXg9TiVb4Q== X-Google-Smtp-Source: AGHT+IFjWCMYQXbIistufqkPiA54FvDnFmiS/smGhbQYFUZ8d14SopHylBIXsW9H4JVnxVSOkE3A X-Received: by 2002:a17:906:cf83:b0:a58:d757:66bb with SMTP id um3-20020a170906cf8300b00a58d75766bbmr1952838ejb.14.1714747969231; Fri, 03 May 2024 07:52:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714747969; cv=pass; d=google.com; s=arc-20160816; b=yhNJXS1fZIoV5SaPrlLnEwIDIQdMExg4lCcYmHVyiwJZ1YIo8znQbzy/X0ZI7U3/L8 S1+uKv+1+V52z0ViuB/S/gWh8LoU+EvwRdZ9f8BW1GCpSvAN2QKYayQEyPSQNHbu8Vgp Pv4tw0RfdoPpQJzWaCHlPk/yScBSxpby+dUcVDA/VIgNe97uN0bi7sLlh0nTCDx4bxQX 4u1z6tK7upWerdYHvSfAbQrtPXeIP67T/ZU9wmeM6iWdJvFDdt7b47PuCAlJLbVD/lAn pUnYRvNF2T5vh2f2c9nHNEMHlg73lVyLlSwfAOK5odI9F0EI4iTlEWL6BntuyuQEU5H+ ethw== 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:message-id:date:subject:to:from :dkim-signature; bh=J2RB8XQQMJx5SNox7pgY9V6kBnScvAsuzlE8+sFEQmI=; fh=4lGQI6056MBa4/oovMyIYaKLn+Wz/24RGvUivMmQP8E=; b=TxkECRt/h+tH9DYKtVJPGFXgK8iw9ZwPVcP62istEwWt8lcxLXCiYymV17oJZpFeDo KlKzCeGP4O2kRkC2f3F3+dK5xMeZ/e89zKIpyc5I4TuXToSvYWsNKK8fxVrFMsJRHXmU ohnARgeD/uPKHZob4zd2HPnETkwUQJvwb5gUjTCuHEmAlv1ENr+YiGQiAN6E/MAWCk+q ujAC8VhUDoGN+tLmkw7FZMSyI6KOW0EBFSTnMFpAHzzOLzHoDmjhVDcdb0VnZDpCotsF e+P3SGc/ujSSl8rqxu0iqhig7vtLcBfI+G9eSR7et9BmYiojzZZFL5HlaZg/nBCgDul0 Tpew==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ndQstN26; 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-4294-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4294-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id gn39-20020a1709070d2700b00a55b5bf6ee1si1715728ejc.309.2024.05.03.07.52.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 07:52:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-4294-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ndQstN26; 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-4294-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4294-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 am.mirrors.kernel.org (Postfix) with ESMTPS id C73CF1F20F89 for ; Fri, 3 May 2024 14:52:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AB22947A48; Fri, 3 May 2024 14:52:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ndQstN26" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-vs1-f44.google.com (mail-vs1-f44.google.com [209.85.217.44]) (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 B635F6FC7 for ; Fri, 3 May 2024 14:52:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714747965; cv=none; b=MzEF+Gv7dL24yFVh/H4G8wbjSgBmLF6bSojFF5i2pCkHBc/Y4d8S9AKcyvVaNs/Csgj9EJozfqWWkIuoRfECbl6qWHTXP6AvXkjtimi2N1B29ZSYxZSEg12pvF2SiZXcnrC1kjInWzT/IJd2sGUqzJb/KtvUlotU9S4r00EzBwQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714747965; c=relaxed/simple; bh=21YXkGg/Jk7e/B4j7TJMqtu++lw3s2v42JLfjAscqkg=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=dVffTOxp1fHuk1gmwUgmt9R3yO4DWUekdkot24TILUo5wk7dyjYmUNk2yXRna897A1UWMsuLfuLLBKt1h9USSDXUwwb6Br4ZSWlNo7pIaBkXBfrfxUGiIbmIrRCqL763/C1Fa6X+sJ7TJZ2eBIguGyfnnhwQ9CV1PhzYLRuEvgA= 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=ndQstN26; arc=none smtp.client-ip=209.85.217.44 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-vs1-f44.google.com with SMTP id ada2fe7eead31-47efd8fa124so154912137.1 for ; Fri, 03 May 2024 07:52:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714747962; x=1715352762; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=J2RB8XQQMJx5SNox7pgY9V6kBnScvAsuzlE8+sFEQmI=; b=ndQstN26T1pQX/EafUtleMe/kMgTpjXp1VFm1E8kqa+IwpgGVyFjqmHVLKpBLZMOvJ dz2pljkl+r96BxQVp50sEv9+0P+dMKmBWOF090PjyfWmpcmD/5Wo0MsF+gtbJtZg5+fS sS3IWEA79mj9Pd/JACLk9a6HRDdikmT4k5T8cgpnj8hYHAgPpa5f1QIySoczU6yxKzWJ P3hOn7E0j6FqNu/X7gj+DypAhHicPTKPKTLnAgphQf65CP4ZtDm7XyItZRpHVSTC2Y/8 KcGD/lsKiI0xSrngAMp8Zx5mcB1dbXszkbIRd/phhyLufWM+mPX5AH8Zw3NR7TDPltUZ wL+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714747962; x=1715352762; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=J2RB8XQQMJx5SNox7pgY9V6kBnScvAsuzlE8+sFEQmI=; b=ejpMmf5i3LvdhdXkYbdsMMQnM2BQFvSd0ua7Jw6nkU5C6gwAk7T5W/e6U1q0svbMK1 FH0CrfV4dAGjsYjAHo7dr/1bYHIHBlyKAa8aHzvUQc8AdwkOKrDhdkN9hHMlthuPTRl9 9MZf+4HlaequrXPS7KuyyQDzF9M0nllWWxDdg0easGF/PQH3PJhYVZz1/ScY6/bERGKD WYeptyxHleNW1veWGGnfeV3CfBl+0Stz8p2/bjsxFbiQuAID+MPNoibELn6UEzTeMI86 GFL2L2OQ/40dXjF7Z5iUHOYShR210Gg7bgHhTQhCS5f2FCWBZNSM8K6nfyf/cik4h3v8 DqxQ== X-Gm-Message-State: AOJu0YyLFl2fxDWoFUrBJsmGjIXYOJFNT7lBsSK71ZnD7fRjgKVP83/Q KmsAyvmPdm78fY6j4zUxMnFam5HZLC6BJTDF3KErD0/QJwWcgbJBKEceRw== X-Received: by 2002:a05:6102:244a:b0:47c:1255:dc2d with SMTP id g10-20020a056102244a00b0047c1255dc2dmr3011299vss.33.1714747961502; Fri, 03 May 2024 07:52: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 cy29-20020a0561300f9d00b007f3b48cdaeesm430216uab.18.2024.05.03.07.52.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 07:52:39 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v1] gatt-database: Fix error registering characteristic with Handle 0x0000 Date: Fri, 3 May 2024 10:52:38 -0400 Message-ID: <20240503145238.3771921-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.44.0 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: Luiz Augusto von Dentz Registering a characteristic with handle 0x0000 means that the application wants a handles to be auto allocated but requires to be informed of what values they end up in the database. Fixes: https://github.com/bluez/bluez/issues/821 --- src/gatt-database.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gatt-database.c b/src/gatt-database.c index 5823aebcbfdb..5756eb9d17cb 100644 --- a/src/gatt-database.c +++ b/src/gatt-database.c @@ -3334,12 +3334,12 @@ static void database_add_includes(struct external_service *service) static bool database_add_chrc(struct external_service *service, struct external_chrc *chrc) { - uint16_t handle; + uint16_t handle = 0, value_handle; bt_uuid_t uuid; char str[MAX_LEN_UUID_STR]; const struct queue_entry *entry; - if (!parse_handle(chrc->proxy, &handle)) { + if (!parse_handle(chrc->proxy, &value_handle)) { error("Failed to read \"Handle\" property of characteristic"); return false; } @@ -3354,8 +3354,11 @@ static bool database_add_chrc(struct external_service *service, return false; } + if (value_handle) + handle = value_handle - 1; + chrc->attrib = gatt_db_service_insert_characteristic(service->attrib, - handle - 1, handle, &uuid, + handle, value_handle, &uuid, chrc->perm, chrc->props, chrc_read_cb, chrc_write_cb, chrc); -- 2.44.0