How to use aioblescan - 10 common examples

To help you get started, we’ve selected a few aioblescan examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github frawau / aioblescan / tests / test_eddystone.py View on Github external
def test_eddystone_url(self):
        pckt = aioblescan.HCI_Event()
        pckt.decode(
            b'\x04>)\x02\x01\x03\x01\xdc)e\x90U\xf1\x1d\x02\x01\x06\x03\x03\xaa\xfe\x15\x16\xaa\xfe\x10\xf6\x03makecode\x00#about\xb5')
        result = EddyStone().decode(pckt)
        self.assertDictEqual(result, {'mac address': 'f1:55:90:65:29:dc',
                                      'tx_power': -10,
                                      'url': 'https://makecode.com/#about',
                                      'rssi': -75})
github frawau / aioblescan / tests / test_eddystone.py View on Github external
def test_eddystone_uid(self):
        pckt = aioblescan.HCI_Event()
        pckt.decode(
            b'\x04>)\x02\x01\x03\x01\xdc)e\x90U\xf1\x1d\x02\x01\x06\x03\x03\xaa\xfe\x15\x16\xaa\xfe\x00\xf6\x00\x00\x00\x00\x00\x00\x00\x00\x00c\x00\x00\x00\x00\x00X\xb6')
        result = EddyStone().decode(pckt)
        self.assertDictEqual(result, {'tx_power': -10,
                                      'rssi': -74,
                                      'name space': (0x63).to_bytes(10,byteorder="big"),
                                      'instance': (0x58).to_bytes(6,byteorder="big"),
                                      'mac address': 'f1:55:90:65:29:dc'})
github frawau / aioblescan / tests / test_eddystone.py View on Github external
def test_eddystone_uid(self):
        pckt = aioblescan.HCI_Event()
        pckt.decode(
            b'\x04>)\x02\x01\x03\x01\xdc)e\x90U\xf1\x1d\x02\x01\x06\x03\x03\xaa\xfe\x15\x16\xaa\xfe\x00\xf6\x00\x00\x00\x00\x00\x00\x00\x00\x00c\x00\x00\x00\x00\x00X\xb6')
        result = EddyStone().decode(pckt)
        self.assertDictEqual(result, {'tx_power': -10,
                                      'rssi': -74,
                                      'name space': (0x63).to_bytes(10,byteorder="big"),
                                      'instance': (0x58).to_bytes(6,byteorder="big"),
                                      'mac address': 'f1:55:90:65:29:dc'})
github frawau / aioblescan / tests / test_eddystone.py View on Github external
def test_eddystone_url(self):
        pckt = aioblescan.HCI_Event()
        pckt.decode(
            b'\x04>)\x02\x01\x03\x01\xdc)e\x90U\xf1\x1d\x02\x01\x06\x03\x03\xaa\xfe\x15\x16\xaa\xfe\x10\xf6\x03makecode\x00#about\xb5')
        result = EddyStone().decode(pckt)
        self.assertDictEqual(result, {'mac address': 'f1:55:90:65:29:dc',
                                      'tx_power': -10,
                                      'url': 'https://makecode.com/#about',
                                      'rssi': -75})
github frawau / aioblescan / aioblescan / plugins / eddystone.py View on Github external
extval=None
        if myhostname.split(".")[-1] in url_domain:
            extval = url_domain.index(myhostname.split(".")[-1])
            myhostname = ".".join(myhostname.split(".")[:-1])
        if extval is not None and not mypath.startswith("/"):
            extval+=7
        else:
            if myurl.port is None:
                if extval is not None:
                    mypath = mypath[1:]
            else:
                extval += 7
        encodedurl.append(aios.String("URL string"))
        encodedurl[-1].val = myhostname
        if extval is not None:
            encodedurl.append(aios.IntByte("URL Extention",extval))

        if myurl.port:
            asisurl += ":"+str(myurl.port)+mypath
        asisurl += mypath
        if myurl.params:
            asisurl += ";"+myurl.params
        if myurl.query:
            asisurl += "?"+myurl.query
        if myurl.fragment:
            asisurl += "#"+myurl.fragment
        encodedurl.append(aios.String("Rest of URL"))
        encodedurl[-1].val = asisurl
        tlength=0
        for x in encodedurl: #Check the payload length
            tlength += len(x)
        if tlength > 19: #Actually 18 but we have tx power
github frawau / aioblescan / aioblescan / plugins / eddystone.py View on Github external
def url_encoder(self):
        encodedurl = []
        encodedurl.append(aios.IntByte("Tx Power",self.power))
        asisurl=""
        myurl = urlparse(self.type_payload)
        myhostname = myurl.hostname
        mypath = myurl.path
        if (myurl.scheme,myhostname.startswith("www.")) in url_schemes:
            encodedurl.append(aios.IntByte("URL Scheme",
                                           url_schemes.index((myurl.scheme,myhostname.startswith("www.")))))
            if myhostname.startswith("www."):
                myhostname = myhostname[4:]
        extval=None
        if myhostname.split(".")[-1] in url_domain:
            extval = url_domain.index(myhostname.split(".")[-1])
            myhostname = ".".join(myhostname.split(".")[:-1])
        if extval is not None and not mypath.startswith("/"):
            extval+=7
        else:
            if myurl.port is None:
                if extval is not None:
                    mypath = mypath[1:]
            else:
                extval += 7
        encodedurl.append(aios.String("URL string"))
github frawau / aioblescan / aioblescan / plugins / eddystone.py View on Github external
def url_encoder(self):
        encodedurl = []
        encodedurl.append(aios.IntByte("Tx Power",self.power))
        asisurl=""
        myurl = urlparse(self.type_payload)
        myhostname = myurl.hostname
        mypath = myurl.path
        if (myurl.scheme,myhostname.startswith("www.")) in url_schemes:
            encodedurl.append(aios.IntByte("URL Scheme",
                                           url_schemes.index((myurl.scheme,myhostname.startswith("www.")))))
            if myhostname.startswith("www."):
                myhostname = myhostname[4:]
        extval=None
        if myhostname.split(".")[-1] in url_domain:
            extval = url_domain.index(myhostname.split(".")[-1])
            myhostname = ".".join(myhostname.split(".")[:-1])
        if extval is not None and not mypath.startswith("/"):
            extval+=7
        else:
github thorrak / fermentrack / gravity / tilt / tilt_monitor_aio.py View on Github external
if tilts[this_tilt].should_save():
            if verbose:
                LOG.info("Saving {} to Fermentrack".format(this_tilt))
            tilts[this_tilt].save_value_to_fermentrack(verbose=verbose)

        if reload:  # Users editing/changing objects in Fermentrack doesn't signal this process so reload on a timer
            if verbose:
                LOG.info("Loading {} from Fermentrack".format(this_tilt))
            tilts[this_tilt].load_obj_from_fermentrack()


event_loop = asyncio.get_event_loop()

# First create and configure a raw socket
try:
    mysocket = aiobs.create_bt_socket(mydev)
except OSError as e:
    LOG.error("Unable to create socket - {}".format(e))
    exit(1)

# create a connection with the raw socket (Uses _create_connection_transport instead of create_connection as this now
# requires a STREAM socket) - previously was fac=event_loop.create_connection(aiobs.BLEScanRequester,sock=mysocket)
fac = event_loop._create_connection_transport(mysocket, aiobs.BLEScanRequester, None, None)
conn, btctrl = event_loop.run_until_complete(fac)  # Start the bluetooth control loop
btctrl.process=processBLEBeacon  # Attach the handler to the bluetooth control loop

# Begin probing
btctrl.send_scan_request()
try:
    event_loop.run_forever()
except KeyboardInterrupt:
    if verbose:
github frawau / aioblescan / aioblescan / plugins / eddystone.py View on Github external
url_schemes.index((myurl.scheme,myhostname.startswith("www.")))))
            if myhostname.startswith("www."):
                myhostname = myhostname[4:]
        extval=None
        if myhostname.split(".")[-1] in url_domain:
            extval = url_domain.index(myhostname.split(".")[-1])
            myhostname = ".".join(myhostname.split(".")[:-1])
        if extval is not None and not mypath.startswith("/"):
            extval+=7
        else:
            if myurl.port is None:
                if extval is not None:
                    mypath = mypath[1:]
            else:
                extval += 7
        encodedurl.append(aios.String("URL string"))
        encodedurl[-1].val = myhostname
        if extval is not None:
            encodedurl.append(aios.IntByte("URL Extention",extval))

        if myurl.port:
            asisurl += ":"+str(myurl.port)+mypath
        asisurl += mypath
        if myurl.params:
            asisurl += ";"+myurl.params
        if myurl.query:
            asisurl += "?"+myurl.query
        if myurl.fragment:
            asisurl += "#"+myurl.fragment
        encodedurl.append(aios.String("Rest of URL"))
        encodedurl[-1].val = asisurl
        tlength=0
github thorrak / fermentrack / gravity / tilt / tilt_monitor_aio.py View on Github external
LOG.info("Loading {} from Fermentrack".format(this_tilt))
            tilts[this_tilt].load_obj_from_fermentrack()


event_loop = asyncio.get_event_loop()

# First create and configure a raw socket
try:
    mysocket = aiobs.create_bt_socket(mydev)
except OSError as e:
    LOG.error("Unable to create socket - {}".format(e))
    exit(1)

# create a connection with the raw socket (Uses _create_connection_transport instead of create_connection as this now
# requires a STREAM socket) - previously was fac=event_loop.create_connection(aiobs.BLEScanRequester,sock=mysocket)
fac = event_loop._create_connection_transport(mysocket, aiobs.BLEScanRequester, None, None)
conn, btctrl = event_loop.run_until_complete(fac)  # Start the bluetooth control loop
btctrl.process=processBLEBeacon  # Attach the handler to the bluetooth control loop

# Begin probing
btctrl.send_scan_request()
try:
    event_loop.run_forever()
except KeyboardInterrupt:
    if verbose:
        LOG.info('Keyboard interrupt')
finally:
    if verbose:
        LOG.info('Closing event loop')
    btctrl.stop_scan_request()
    command = aiobs.HCI_Cmd_LE_Advertise(enable=False)
    btctrl.send_command(command)