Initial commit of junk

This commit is contained in:
Lucas Oskorep
2019-08-04 17:55:17 -05:00
parent 76ff3a5c40
commit 8484b8ef45
2 changed files with 35 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
from bluetooth.ble import BeaconService
class Beacon(object):
def __init__(self, data, address):
self._uuid = data[0]
self._major = data[1]
self._minor = data[2]
self._power = data[3]
self._rssi = data[4]
self._address = address
def __str__(self):
ret = "Beacon: address:{ADDR} uuid:{UUID} major:{MAJOR}" \
" minor:{MINOR} txpower:{POWER} rssi:{RSSI}" \
.format(ADDR=self._address, UUID=self._uuid, MAJOR=self._major,
MINOR=self._minor, POWER=self._power, RSSI=self._rssi)
return ret
service = BeaconService()
devices = service.scan(2)
for address, data in list(devices.items()):
b = Beacon(data, address)
print(b)
print("Done.")