-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.py
32 lines (27 loc) · 750 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from network import Bluetooth
from ubinascii import hexlify
from bleAdvReader import BLEAdvReader
def hex(data) :
if data :
return hexlify(data).decode().upper()
return ''
def mac2str(mac) :
if mac :
return hexlify(mac, ':').decode().upper()
return ''
bt = Bluetooth()
bt.start_scan(-1)
while True :
adv = bt.get_adv()
if adv :
mac = mac2str(adv.mac)
print()
print()
print(' - MAC ADDRESS : %s' % mac)
print(' - RSSI : %s' % adv.rssi)
try :
r = BLEAdvReader(adv.data)
for advObj in r.GetAllElements() :
print(' - OBJECT : [%s] %s' % (type(advObj), advObj))
except :
pass