Skip to content

Commit

Permalink
Remove spurious print, added MAC filtering to module app,uppded the rev
Browse files Browse the repository at this point in the history
  • Loading branch information
frawau committed Jun 26, 2017
1 parent 18d8b40 commit fe17ed9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
21 changes: 21 additions & 0 deletions aioblescan/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,24 @@
import sys
import asyncio
import argparse
import re
import aioblescan as aiobs

def check_mac(val):
try:
if re.match("[0-9a-f]{2}([-:])[0-9a-f]{2}(\\1[0-9a-f]{2}){4}$", val.lower()):
return val.lower()
except:
pass
raise argparse.ArgumentTypeError("%s is not a MAC address" % val)

parser = argparse.ArgumentParser(description="Track BLE advertised packets")
parser.add_argument("-e", "--eddy", action='store_true', default=False,
help="Look specificaly for Eddystone messages.")
parser.add_argument("-r","--ruuvi", action='store_true', default=False,
help="Look only for Ruuvi tag Weather station messages")
parser.add_argument("-m", "--mac", type=check_mac, action='append',
help="Look for these MAC addresses.")
try:
opts = parser.parse_args()
except Exception as e:
Expand All @@ -42,6 +53,16 @@ def my_process(data):

ev=aiobs.HCI_Event()
xx=ev.decode(data)
if opts.mac:
goon = False
mac= ev.retrieve("peer")
for x in mac:
if x.val in opts.mac:
goon=True
break
if not goon:
return

if opts.eddy:
xx=aiobs.EddyStone(ev)
if xx:
Expand Down
3 changes: 1 addition & 2 deletions aioblescan/aioblescan.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
class MACAddr:
def __init__(self,name,mac="00:00:00:00:00:00"):
self.name = name
self.val=mac
self.val=mac.lower()

def encode (self):
return int(self.val.replace(":",""),16).to_bytes(6,"little")
Expand Down Expand Up @@ -571,7 +571,6 @@ def __init__(self):


def decode(self,data):
print ("Got: {}".format(data))
for x in self.payload:
data=x.decode(data)
return data
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

setup(name='aioblescan',
packages=['aioblescan'],
version='0.1.1',
version='0.1.3',
author='François Wautier',
author_email='francois@wautier.eu',
description='Scanning Bluetooth for advertised info with asyncio.',
url='http://github.com/frawau/aioblescan',
download_url='https://github.com/frawau/aioblescan/archive/0.1.1.tar.gz',
keywords = ['bluetooth', 'advertising', 'hci'],
download_url='https://github.com/frawau/aioblescan/archive/0.1.3.tar.gz',
keywords = ['bluetooth', 'advertising', 'hci', 'ble'],
license='MIT',
install_requires=[],
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
Expand Down

0 comments on commit fe17ed9

Please sign in to comment.