Skip to content

Instantly share code, notes, and snippets.

Created September 16, 2018 18:22
What would you like to do?
import argparse
import time
import sys
from iotile.core.hw import HardwareManager
def build_parser():
parser = argparse.ArgumentParser(description="Print broadcast readings from a specific device")
parser.add_argument('-d', '--dev', type=lambda x: int(x, 0), help="Optional, the UUID of the device you want to see broadcasts from (0x21 for example)")
parser.add_argument('-i', '--interval', type=float, default=1.0, help="The minimum interval in seconds between two reported readings (only applies when -d is given), defaults to 1s")
parser.add_argument('-p', '--port', default="bled112", help="The port to use, defaults to bled112")
return parser
def main():
parser = build_parser()
args = parser.parse_args()
with HardwareManager(port=args.port) as hw:
while True:
found_reading = False
for report in hw.iter_broadcast_reports(blocking=False):
if is not None and report.origin !=
if not ( and found_reading):
reading = report.visible_readings[0]
print("%04X: %d" % (, reading.value))
found_reading = True
if __name__ == "__main__":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment