Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp322539ybg; Wed, 10 Jun 2020 01:33:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4cFrJoScGYvEyyXRD38QNZf5ibZpTipMBHDjRL9bYSqlL2MxmmsH3ul/ejQrDvmPu2+ej X-Received: by 2002:aa7:d806:: with SMTP id v6mr1570918edq.174.1591777999483; Wed, 10 Jun 2020 01:33:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591777999; cv=none; d=google.com; s=arc-20160816; b=jErcwychPT1b9DqhmU3UeeLXOrpJxDuBUgE0OPYado82olVxKq0RmTsvzaSKWrk5rF kEQPPddWI28Jsg80B+d+hvf/45smgjL4hqVeMYx+guHeWlZ3zOcW3a51PGv7G1xpl4aM sa1KrIGoTQRA0dtHtARUvv1Rtm29t4EOS9LzMJXzTFyLptjFo3osDv+QR87DOuQ5zi67 FaIDmbKRlf2V0jq1KSfCfrWxXEvDWggHzh9SKbwTxbCfjJO5RAqZq2NrGGgojgzP4AvT EXF/i4ffZf6bn2cFnAnq0t9d5USG/9Lmy2hltRrKQEAZibSfInDv+Y9w+uWY6NcQgcQq 3Cvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=Y9Bsr7sipCKmEj2L9FH7/7A3HHMe2/1NWeyusxGXhhk=; b=bt+ej7to3mg/pDheh5xHDoa708sjbyX8CMDjN2Z8lbVJsCzdWJp41o3DTYwKFcq4wY 4CnqfrgFb1w9GOLHHJYwN6Jt5tAr4iGA/YeizEaDDA90Tjnd+0y6bn31I3K8FNJ5q1Mg yjHdmX0NdNXWoTo8PhMgvrs/YYu5HblKDgr70MeMYJhf88Nh75xA+JPF6BSXywpOG9Mg AXsXx6iKoVmbcZBo1BQ0T5mWD09WVLSqKcKKG0o+lfQBi9rx0pQIcgmpgMFETOshrNWM qc0R811hx/AzgLu7CxEBKnPbRUOnPAfXaMjgbIH+1cPxPqFnIve8d6g1CmIXBuEkzZuK oJqg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o4si2339217eja.704.2020.06.10.01.32.54; Wed, 10 Jun 2020 01:33:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726633AbgFJIcj convert rfc822-to-8bit (ORCPT + 99 others); Wed, 10 Jun 2020 04:32:39 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:39874 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726424AbgFJIcj (ORCPT ); Wed, 10 Jun 2020 04:32:39 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 9E78DCECE0; Wed, 10 Jun 2020 10:42:27 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: Getting ADV_IND and SCAN_RSP data with DBus From: Marcel Holtmann In-Reply-To: Date: Wed, 10 Jun 2020 10:32:37 +0200 Cc: Bluez mailing list Content-Transfer-Encoding: 8BIT Message-Id: <62ED48B7-8173-43A9-B75B-0ED1A72D8442@holtmann.org> References: To: Barry Byford <31baz66@gmail.com> X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Barry, > I attempting to get the advertising data from a commercially available > sensor device using the DBus API. > The sensor device gives different manufacturer data depending if the > event type is ADV_IND or SCAN_RSP, as you can see below in the btmon > output. > > With DBus I am subscribing to the InterfacesAdded signal which > triggers when the device has been found. However, it only seems to > give me the information for the SCAN_RSP. > If I subscribe to the PropertiesChanged signal on the device, that is > also only giving the data from the SCAN_RSP event. > > How do I access both types of data with the DBus API? > > Thanks, > Barry > > $ bluetoothctl -v > bluetoothctl: 5.50 > > > btmon output for sensor device: > >> HCI Event: LE Meta Event (0x3e) plen 43 #1969 [hci0] 740.157687 > LE Advertising Report (0x02) > Num reports: 1 > Event type: Connectable undirected - ADV_IND (0x00) > Address type: Random (0x01) > Address: DC:76:F7:E1:62:E0 (Static) > Data length: 31 > Flags: 0x06 > LE General Discoverable Mode > BR/EDR Not Supported > Company: Blue Maestro Limited (307) > Data: 1b640e10010400e701a527f50100 > Name (complete): DC76F7E1 > RSSI: -44 dBm (0xd4) >> HCI Event: LE Meta Event (0x3e) plen 41 #1970 [hci0] 740.158684 > LE Advertising Report (0x02) > Num reports: 1 > Event type: Scan response - SCAN_RSP (0x04) > Address type: Random (0x01) > Address: DC:76:F7:E1:62:E0 (Static) > Data length: 29 > Company: Blue Maestro Limited (307) > Data: 27fd27f227ea0000010201b600e4017100f4018c0000000000 > RSSI: -44 dBm (0xd4) > @ MGMT Event: Device Found (0x0012) plen 74 > {0x0002} [hci0] 740.158704 > LE Address: DC:76:F7:E1:62:E0 (Static) > RSSI: -44 dBm (0xd4) > Flags: 0x00000000 > Data length: 60 > Flags: 0x06 > LE General Discoverable Mode > BR/EDR Not Supported > Company: Blue Maestro Limited (307) > Data: 1b640e10010400e701a527f50100 > Name (complete): DC76F7E1 > Company: Blue Maestro Limited (307) > Data: 27fd27f227ea0000010201b600e4017100f4018c0000000000 > @ MGMT Event: Device Found (0x0012) plen 74 > {0x0001} [hci0] 740.158704 > LE Address: DC:76:F7:E1:62:E0 (Static) > RSSI: -44 dBm (0xd4) > Flags: 0x00000000 > Data length: 60 > Flags: 0x06 > LE General Discoverable Mode > BR/EDR Not Supported > Company: Blue Maestro Limited (307) > Data: 1b640e10010400e701a527f50100 > Name (complete): DC76F7E1 > Company: Blue Maestro Limited (307) > Data: 27fd27f227ea0000010201b600e4017100f4018c0000000000 > > > Device information from the InterfacesAdded DBus signal: > > {'Adapter': '/org/bluez/hci0', > 'Address': 'DC:76:F7:E1:62:E0', > 'AddressType': 'random', > 'Alias': 'DC76F7E1', > 'Blocked': False, > 'Connected': False, > 'LegacyPairing': False, > 'ManufacturerData': {307: [39, 253, 39, 242, 39, 234, 0, 0, 1, 2, 1, > 182, 0, 228, 1, 113, 0, 244,1, 140, 0, 0, 0, 0, 0]}, > 'Name': 'DC76F7E1', > 'Paired': False, > 'RSSI': -51, > 'ServicesResolved': False, > 'Trusted': False, > 'UUIDs': []} > > Looking at the propertiesChanged signal on the device, it is also only > showing the same manufacturer data: > org.bluez.Device1 {'RSSI': -45, 'ManufacturerData': {307: [39, 253, > 39, 242, 39, 234, 0, 0, 1, 2, 1, 182, 0, 228, 1, 113, 0, 244, 1, 140, > 0, 0, 0, 0, 0]}} [] > org.bluez.Device1 {'RSSI': -52, 'ManufacturerData': {307: [39, 253, > 39, 242, 39, 234, 0, 0, 1, 2, 1, 182, 0, 228, 1, 113, 0, 244, 1, 140, > 0, 0, 0, 0, 0]}} [] > org.bluez.Device1 {'RSSI': -54, 'ManufacturerData': {307: [39, 253, > 39, 242, 39, 234, 0, 0, 1, 2, 1, 182, 0, 228, 1, 113, 0, 244, 1, 140, > 0, 0, 0, 0, 0]}} [] > org.bluez.Device1 {'RSSI': -45, 'ManufacturerData': {307: [39, 253, > 39, 242, 39, 234, 0, 0, 1, 2, 1, 182, 0, 228, 1, 113, 0, 244, 1, 140, > 0, 0, 0, 0, 0]}} [] > org.bluez.Device1 {'RSSI': -54, 'ManufacturerData': {307: [39, 253, > 39, 242, 39, 234, 0, 0, 1, 2, 1, 182, 0, 228, 1, 113, 0, 244, 1, 140, > 0, 0, 0, 0, 0]}} [] > org.bluez.Device1 {'RSSI': -52, 'ManufacturerData': {307: [39, 253, > 39, 242, 39, 234, 0, 0, 1, 2, 1, 182, 0, 228, 1, 113, 0, 244, 1, 140, > 0, 0, 0, 0, 0]}} [] this is nasty from the device. So the MGMT event should return the combined data from ADV_IND and SCAN_RSP and as you see we just concat that information coming from the kernel. However when it goes out via D-Bus, it actually gets overwritten and only one is provided. Now the question is how we represent the same manufacturer data coming once from ADV_IND and second from SCAN_RSP via the D-Bus API. You need to have a look into doc/device-api.txt and the code in src/device.c on how we handle this. Regards Marcel