Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2189881ybb; Mon, 30 Mar 2020 01:06:18 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtPsWAJbE/RMNDvvuuzrdKNh4qSI/isooHNiTzZktIFNfiuH1rHW+XqJMD/L3B8PEGFNw99 X-Received: by 2002:a05:6830:1bca:: with SMTP id v10mr5564666ota.286.1585555577945; Mon, 30 Mar 2020 01:06:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585555577; cv=none; d=google.com; s=arc-20160816; b=lHC/Xtx+S9G+wcPAAlh3n87fFNL43OyXhfe3Wk2tnOA/pvWGRdCi829D7J62kgiXXn IHogJjYusIfja5zKY/GSbA5H4gJ9dnrUSyjZlGk34VJVFvLBfMbfMpsDCqscmi+z2zF4 PPlBxrGwPlLJ7rTl2De+mxcHWBEZPx2QdAny89AlqYJOrv+YPTaexHDHw2Ocmzjsnbzf +dvR6vwYcjAMjd0lynrffMjPFp/iPwNuSlQQms6PEvl/GalUb3zayH19gblpFdjyuqWJ C9HJGvLjYupz8BqgCI38EoA31T2j7OiWJ8FVUawsYmKBB2EKwZKUkik65/vzAqKA2BXZ VE4Q== 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=t9KWA9TXseSGKzSaj2xUqPufvYRn2IcAIkpo4hpGUsc=; b=hFB2etYvitIMFqYSqHGRwLvIx0RkMzBkcWj0M35Mq5XYwbg68XYWje68PnI0rWf3qR MbO54koTJRoqQAJ6eTevRTIB4O43zdaUzyNkpj+d32ycTGbBn1sjlIkCppzveEucdIf9 jW0LXN0uo16M+DSRmVuCjFXE9k77nxTNSy1FoAcd7+RvmkSz3OV2j1vHCF/lu/VPD6CK zmnQ30E6xGZhvVfzqVV9LfgMLoa2axDH4C935Ju1A5lMXlKd3MaPLPsxsYPryu3s0oz5 S14n9X+wgzzpnropsxfUbzeqy+AYIPjZ7zWwUr6SflTDNxCBjPjVMETjYHOslSFjCLja XkGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ffyP0Yfe; 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 l7si5907199otj.49.2020.03.30.01.06.06; Mon, 30 Mar 2020 01:06: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=@google.com header.s=20161025 header.b=ffyP0Yfe; 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 S1729600AbgC3IEd (ORCPT + 99 others); Mon, 30 Mar 2020 04:04:33 -0400 Received: from mail-vk1-f202.google.com ([209.85.221.202]:54606 "EHLO mail-vk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729586AbgC3IEd (ORCPT ); Mon, 30 Mar 2020 04:04:33 -0400 Received: by mail-vk1-f202.google.com with SMTP id i26so5249050vkk.21 for ; Mon, 30 Mar 2020 01:04:30 -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=t9KWA9TXseSGKzSaj2xUqPufvYRn2IcAIkpo4hpGUsc=; b=ffyP0YfeWxCIApygAbhLHpnjKIfPKABqJpPKCFr0wm7vM/pBH7Q77tFwzLta0vKY2M OuGEcVtwXb8b8MfALymPYYoSSdUVbuGB6L/my4jIktEeFbbA7mHtyvtKwDuexR5+6KiQ +kxti8BKd7RoTNO+5j9S86SbE0Uv7lDgXwWDrn+JmBDe1M+JPdIUuYDHQkQAQLUqHVEF Jk/JR9skcw7oqK9D9aHnFOXfbN98hTy8Abm4bdwDCLt8/g5/+F576q5DcCx8rqk3DRpu GlNjol8OOLWCGKSuYM3IgayzsoOckJFj8+TPMS4ohYay8jFi0cg0Z+rsvW8ZDM3HU7D4 t0EQ== 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=t9KWA9TXseSGKzSaj2xUqPufvYRn2IcAIkpo4hpGUsc=; b=eevGhsEe8aGKIGOMvvNo2SS9DAPbnsfMBigmxBBwiD4QK8b8quxxELAOTTGtDzRGsc PR76FYOIkue9GZfhah55y7GOrtsg08jjSTmfOlyZ4P1xEal9cxm+h9UCccAz0fdINkP4 kTCnR/wjv3Hk/COWBjZQZMJvGOHt+4QqUT2bxomDXxPqcGChU6vPFLPvZoSsQHmGX3He AuF/tRfvilnXSRgG5RoTJ+bcU70h+DXNL8NnYK1BsIrVSm3wBzhvlBmS3XwbTIDdxijM w3W6ol11+6fuhq4j4+l/bPrFJ32T0yzg/6SmfCLkP675oQiXg06JB5CZML835a524TqQ M/dQ== X-Gm-Message-State: AGi0PuYIAxykrmZsxTfpBmYjphq/CasdRFlDAFOBWHsaxirp2fpFXhDY WGM0DOw0Cv5nQEm0vI0SdPYUR8fl4yI5GMfOUys2gLWRf6P8aLHiRRZbZaISojEemGvkPr9mBRi b81P8hAQUTwj7eqgCP91XjjzIS5C8GW0JCtPxvPixV3m0UoTFSKyB0AH5hmPNyXcUE6DLVsKka3 DGOnuwTLFBIWw= X-Received: by 2002:a1f:a2d0:: with SMTP id l199mr6578040vke.77.1585555470048; Mon, 30 Mar 2020 01:04:30 -0700 (PDT) Date: Mon, 30 Mar 2020 16:03:56 +0800 In-Reply-To: <20200330080357.96989-1-howardchung@google.com> Message-Id: <20200330160343.Bluez.v2.5.Ie551a8a414d17604f04e10cf8d9c514a2b170e31@changeid> Mime-Version: 1.0 References: <20200330080357.96989-1-howardchung@google.com> X-Mailer: git-send-email 2.26.0.rc2.310.g2932bb562d-goog Subject: [Bluez PATCH v2 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 --- Changes in v2: None 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