Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2152199ybb; Mon, 30 Mar 2020 00:06:57 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuP3vETtB1dKi3dklVb+eUKK+b1tjKLtydBS67IdQr8HyqOtS923ErEa7VcHV28sJOaOEGC X-Received: by 2002:a9d:5f18:: with SMTP id f24mr3155100oti.325.1585552017335; Mon, 30 Mar 2020 00:06:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585552017; cv=none; d=google.com; s=arc-20160816; b=c7wABvGaP7WSNZqUru9Xg9vCXnrMS5QlK0Bwl+GgPOiU3RII1fqoBbjH2EWeLYHDDk X4uIdT9ydGCPOse5Fb27kDQlXhacPV9y2lWQriiG+QD/NdUim3B2ZVqXv77YcErB802O FpvWLas//lGSu7QuuvO1kl3z+2uAPMuyn8PI0ECMxD6y8pkxitH0PpGdpwKMCepfDHg3 QT8waMMRUOfGlDN/RKEgBTcKlLiCfqS87DddMQ7Dq5jhburSVckZdJ1QSnNxP5lLgmPs lU8X3eHyEojGyuDut9m2y9dlZLUKf/Co+2lz4fMQovnuBJWZjKNChYU25jGwDhgQlddh XBKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=sRxvBt9CbHrEaWbg6j4fY+lBQ0TJ6ryxG2Jm/LbqOgg=; b=Q455R37JtNw3+pXLQX3kLrc0bzN8JA4xD7uR6Izdo/S9VfDYofdET51XOJExcMIid5 gC1FJbFjmlvq+iUmWBfpj6ljo2ceVIfk9YoM1OzSgxfvIGMa6tBHT63ZvXqQNkulUpX8 ARzCPEXpMGBlAd09qmqQnqr3nM+EZ8YGVw4PF1GOzmtS2pBA0Mc4tI5MO4CjvQs0cDZZ lP6iZoWHOAHNJf3iKoLRxLyHH0h3jcNt7iBGxR3VioF7d57nfONSmsSonc8XPTQwUFDI EIe8X1t2ixFZhZHCP/HX2yTrC5l6BhZGMeCJRrH2/qERAA5/878GfE+PwQK8JdOrCIgG zEXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=g2bqqkdj; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a17si2260991oie.2.2020.03.30.00.06.46; Mon, 30 Mar 2020 00:06:57 -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=@google.com header.s=20161025 header.b=g2bqqkdj; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728957AbgC3HFk (ORCPT + 99 others); Mon, 30 Mar 2020 03:05:40 -0400 Received: from mail-pl1-f201.google.com ([209.85.214.201]:47617 "EHLO mail-pl1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728731AbgC3HFk (ORCPT ); Mon, 30 Mar 2020 03:05:40 -0400 Received: by mail-pl1-f201.google.com with SMTP id l1so12274156pld.14 for ; Mon, 30 Mar 2020 00:05:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=sRxvBt9CbHrEaWbg6j4fY+lBQ0TJ6ryxG2Jm/LbqOgg=; b=g2bqqkdjudMNT02IE4EeyXbWWp3tAWdmRbnAuSj+zdL/5/cBgR5Ogh7+2Rp/3sh85M YXhZ1fK0ejcXS9Io8TMr9itHrkewI2f+447X+B5P/ONbZUHFt8agW3BBCg16M8MahZ48 BB0lxJ6x20rhd9KuzQlKU268xNFR+dNjIZlBlo0+yAV5hZ91ycqDCtnhSPYPnF1WPU+S UrDnyC4pIp/VRVvK/lL4x70FSYFKIfo6g0DEIepCINNqz62HR75+cpSZYVISBzJ96t93 lGyZLcDofST1lLsi8iNXEpgDFK9cVu90q6BjUKkMdWATQFBlKhfU9YhUQ4HOxMDqT2OY 8oWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=sRxvBt9CbHrEaWbg6j4fY+lBQ0TJ6ryxG2Jm/LbqOgg=; b=Yv4dhbWPZJHUq6GdNXvDD02ty+Sp9SAzwuRH7mhAfKcW2Yq4zIp8ZoUaKh7vG2WUfW 4ssJKM9EStDYZVxzyQe5lLBV0r7ObETfWII89CBHOtxILqkKdREqUPcQh2T61Gi1vbxI bxzmXLyFxQU82WTkklX09POaZS15MNC8oHw2s6k6qVMbFGFbyRCbggd4pf4ev+rE5oHF 2tsTFr7TGWqSgxI1Y1BmLIajY2LlHKZaT9Lm1WkVkCuYPUgZ50iatf09OcpIuDULfR6D JvNWVsar1HwXvmV5rPtOe8zMO+nqYbM61NuLbOaDve8BR0cey4U9imbFXYwRE0qvvULz XScw== X-Gm-Message-State: AGi0PuapDA0pCfo3+QMcACYOGQf6dR33UAKMZk3GkpACYBBjz/MkA98J pJB4AHvgkrKxwt8ryRP1isTHKIRaHY8B9OlvSNMHh+0JCnmFb4UF55lzy6T9LgYD+pveFTgrGzX qFmc6uSneetFu+9sijLAE4moMsxu8nRZqgx1Oq6u+gDnvd05FVGyLfWYeMryKR8iW0FiiKZ4L7E jwjGvLQ1pDfXc= X-Received: by 2002:a17:90b:1116:: with SMTP id gi22mr10026804pjb.134.1585551939036; Mon, 30 Mar 2020 00:05:39 -0700 (PDT) Date: Mon, 30 Mar 2020 15:04:37 +0800 In-Reply-To: <20200330070438.37316-1-howardchung@google.com> Message-Id: <20200330150424.Bluez.v1.5.Ie551a8a414d17604f04e10cf8d9c514a2b170e31@changeid> Mime-Version: 1.0 References: <20200330070438.37316-1-howardchung@google.com> X-Mailer: git-send-email 2.26.0.rc2.310.g2932bb562d-goog Subject: [Bluez PATCH v1 5/6] test: Add test for LE Set Advertising Interval From: Howard Chung To: linux-bluetooth@vger.kernel.org, luiz.von.dentz@intel.com Cc: chromeos-bluetooth-upstreaming@chromium.org, Howard Chung Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Perform the following steps to verify advertising intervals. Open a terminal on the DUT, and execute $ btmon Open another terminal on the DUT, and register an advertisement. $ ./example-advertisement Observe that the default intervals are 1280 msec in btmon log. < HCI Command: LE Set Advertising Parameters (0x08|0x0006) plen 15 Min advertising interval: 1280.000 msec (0x0800) Max advertising interval: 1280.000 msec (0x0800) Press ctrl-c to terminate the advertisement. Set new intervals to 200 ms. $ ./example-advertising-intervals 200 200 It would show the following line in btmon log. = bluetoothd: Set Advertising Intervals: 0x0140, 0x0140 Register an advertisement again. $ ./example-advertisement Observe that the new intervals bcome 200 msec in btmon log. < HCI Command: LE Set Advertising Parameters (0x08|0x0006) plen 15 Min advertising interval: 200.000 msec (0x0140) Max advertising interval: 200.000 msec (0x0140) Press ctrl-c to terminate the advertisement. Signed-off-by: Howard Chung --- test/example-advertising-intervals | 48 ++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 test/example-advertising-intervals diff --git a/test/example-advertising-intervals b/test/example-advertising-intervals new file mode 100644 index 000000000..8afc7225e --- /dev/null +++ b/test/example-advertising-intervals @@ -0,0 +1,48 @@ +#!/usr/bin/python + +"""A simple script to set advertising intervals through the dbus method. + +Usage: + $ ./example_advertising_intervals.py min_interval_ms max_interval_ms + + Example: + # Set both min and max advertising intervals to 200 ms. + $ ./exampel_advertising_intervals.py 200 200 +""" + +import dbus +import time +import subprocess +import sys + +argv = sys.argv +argc = len(argv) +prog = argv[0] +if argc == 3: + min_interval_ms = int(argv[1]) + max_interval_ms = int(argv[2]) + print 'Set advertising intervals: [%d, %d]' % (min_interval_ms, + max_interval_ms) +else: + print 'Usage: python %s min_interval_ms max_interval_ms' % prog + print ' python %s 200 200' % prog + sys.exit(1) + + +# Set advertising intervals. +bus = dbus.SystemBus() +adapter = bus.get_object('org.bluez', '/org/bluez/hci0') +adapter.SetAdvertisingIntervals( + min_interval_ms, max_interval_ms, + dbus_interface='org.bluez.LEAdvertisingManager1') + + +# Wait a little while for dbus method to complete. +time.sleep(0.2) + + +# Check the current settings using btmgmt. +btmgmt_cmd = 'btmgmt info' +for line in subprocess.check_output(btmgmt_cmd.split()).splitlines(): + if 'current settings' in line: + print line.strip() -- 2.26.0.rc2.310.g2932bb562d-goog