Initial commit of junk
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
import pygatt
|
||||||
|
|
||||||
|
adapter = pygatt.BGAPIBackend()
|
||||||
|
|
||||||
|
adapter.start()
|
||||||
|
device = adapter.connect('E3:AE:CD:AF:28:E2')
|
||||||
|
print(device.char_read("64a70010-f691-4b93-a6f4-0968f5b648f8"))
|
||||||
@@ -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.")
|
||||||
Reference in New Issue
Block a user