Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1071749ybb; Wed, 1 Apr 2020 15:14:17 -0700 (PDT) X-Google-Smtp-Source: APiQypLPGeF/MEgj5l3yAX8+5jiscC/3t5s/4nTtOXqAo91SvfiqQxHh/hPE68kkZGJcQgfvE2aP X-Received: by 2002:aca:c6d1:: with SMTP id w200mr107974oif.43.1585779257293; Wed, 01 Apr 2020 15:14:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585779257; cv=none; d=google.com; s=arc-20160816; b=AfU5HtnQChVZXQTujEKxOylHL1yR4mtX+efPQqNeNbsSY3pw9q6la868zruEvPzbvc kWvlKAJsPuPrEA6vRDEVn94olJbLEPF3hpGgiY18aHfIP7xCs7BDjbMzvPe7amYgFZkn H2kO+QED70LeGXclIFLnDcNxPK0U+Q3JtCfJBlb826cSfmK7mpIxCpVaJHxYm0SANLTr daWI6rXqr76wL7aGHTKzgWnHS7uRUoIYiTCcgDyElCQq00q864WDoYzXm35C0pQ8nvtm d4XtNWSqYJHQJ/Syvs12wsFoGSrxX2zwuxzgPZK4nAFoNQ+scTSb9vwFaYkWtqyzsLuH l8Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=+xr2rEcqkTvnh0oYOe3jlueoi2NAyuaNMHum7SWLrDc=; b=KucaukBwN4pZ51m8GZnre3iO7L7FoV0E8hVcXWRP3I/yBrCgrW9IzsTs9eV8FD+lYv u2vduX2ZBgTP0IJcWFnhUL0rVPaypcIN3HtJNRazPjbLqVstxMLm9J0T0k6s7+I7aw6N RU/shnipd3nUGEwZqwi/+Qap7T3Xm+p1pSuKRy69cNfNb0o5r+xneoJppTIgbl8EzF8u 03gwaBJwolWaekKfLc+LGh9zoX/kWWMt9CAnobzOFZi0LYyTW+QBq+tBFO+uguKW+AFO pvjpv93cqukTrZwuQonYNj4Ng4AhUUpO1hLilWEsWY7wq0clg3jX4cG8q5oJRXxsKHfh qNZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=asBdPD6V; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v126si1448415oia.106.2020.04.01.15.13.48; Wed, 01 Apr 2020 15:14:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=asBdPD6V; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732554AbgDAWNj (ORCPT + 99 others); Wed, 1 Apr 2020 18:13:39 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:37354 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732537AbgDAWNj (ORCPT ); Wed, 1 Apr 2020 18:13:39 -0400 Received: by mail-pg1-f193.google.com with SMTP id i34so832646pgl.4 for ; Wed, 01 Apr 2020 15:13:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+xr2rEcqkTvnh0oYOe3jlueoi2NAyuaNMHum7SWLrDc=; b=asBdPD6Vp0Q50ivPa6Mi23j8RX8iJuojMKd23NWBeZQvokLFXD3m63BI/ryn+lJAJs DEbxBUp7NMVzqCUSt+rhoJfdLnxd6RteNVY82xSVbXv2Yzyw7TCNiUW76L6xolasZGX9 ItZ1GZ72Ri9cYuXQgaIZgN4VRQqGUKCIpQNJQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+xr2rEcqkTvnh0oYOe3jlueoi2NAyuaNMHum7SWLrDc=; b=AXfFp3cfR9TRapVQU/Pb4+UQyDuBMG9/16n8bHtaHvGCO/aw65jqr8k4PQmS6/C+Xh zsHE/vkTjbfroVf2XqRT9rgqp0NnccLha4fycUzleJC3gXuTBWp4KzJouyLXteTeaHlf 6F3edbZu8Y1EDwMVmfMB8SDANN/FTjZnbnLdyPFZUwONVrHyA/bjnopJPQa1f1dDOA/c FaA8aYmWY/JY+bh4Y8wim2fdi7n4KCwqCkJPrHPNHUuTFFRGer7R+GL2jW8FlAm3Ap79 XyNAIhj4eVrbZ0XQlo0tLSyKBw213B44irqQaCW0mo7KDppHko88G/EHtAnSuCIW0N3N oubA== X-Gm-Message-State: AGi0PuYoIKzU6/CQ5vej9fVqBAzz1Umdmjm3HZHJSbk6OOl1du2+7ggI q/UM8e21mLz6JTdfds/6ZgDsOKCXBrg= X-Received: by 2002:aa7:919a:: with SMTP id x26mr21739216pfa.39.1585779217770; Wed, 01 Apr 2020 15:13:37 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:b7e2:9910:bd78:608d]) by smtp.gmail.com with ESMTPSA id f15sm2265366pfd.215.2020.04.01.15.13.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Apr 2020 15:13:37 -0700 (PDT) From: Sonny Sasaka To: linux-bluetooth@vger.kernel.org Cc: Eric Caruso Subject: [PATCH] device: Add device type property Date: Wed, 1 Apr 2020 15:13:20 -0700 Message-Id: <20200401221320.12105-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Eric Caruso This allows us to gather information about whether a device supports BR/EDR, BLE, or both. It appears as DBus Property "Type" on the org.bluez.Device1 interface. --- doc/device-api.txt | 5 +++++ src/device.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/doc/device-api.txt b/doc/device-api.txt index 65d8fee37..ceb68d2f6 100644 --- a/doc/device-api.txt +++ b/doc/device-api.txt @@ -158,6 +158,11 @@ Properties string Address [readonly] The Bluetooth class of device of the remote device. + string Type [readonly, optional] + + The carriers supported by this remote device. If it + exists, it can be one of "BR/EDR", "LE", or "DUAL". + uint16 Appearance [readonly, optional] External appearance of device, as found on GAP service. diff --git a/src/device.c b/src/device.c index 5f9ad227d..ace9c348c 100644 --- a/src/device.c +++ b/src/device.c @@ -849,6 +849,35 @@ static gboolean dev_property_get_class(const GDBusPropertyTable *property, return TRUE; } +static gboolean dev_property_exists_type(const GDBusPropertyTable *property, + void *data) +{ + struct btd_device *device = data; + + return device->bredr || device->le; +} + +static gboolean dev_property_get_type(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct btd_device *device = data; + const char *type; + + if (!device->bredr && !device->le) + return FALSE; + + if (!device->bredr) + type = "LE"; + else if (!device->le) + type = "BR/EDR"; + else + type = "DUAL"; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &type); + + return TRUE; +} + static gboolean get_appearance(const GDBusPropertyTable *property, void *data, uint16_t *appearance) { @@ -2752,6 +2781,8 @@ static const GDBusPropertyTable device_properties[] = { { "Alias", "s", dev_property_get_alias, dev_property_set_alias }, { "Class", "u", dev_property_get_class, NULL, dev_property_exists_class }, + { "Type", "s", dev_property_get_type, NULL, + dev_property_exists_type }, { "Appearance", "q", dev_property_get_appearance, NULL, dev_property_exists_appearance }, { "Icon", "s", dev_property_get_icon, NULL, -- 2.24.1