Skip to content

Instantly share code, notes, and snippets.

@electronut
Created July 9, 2017 06:08
Show Gist options
  • Save electronut/7b1132d121520555e631dff40e4e3d79 to your computer and use it in GitHub Desktop.
Save electronut/7b1132d121520555e631dff40e4e3d79 to your computer and use it in GitHub Desktop.
bluey-beacon - python
data = None
while True:
for line in scanner.get_lines():
if line:
found_mac = line[14:][:12]
reversed_mac = ''.join(
reversed([found_mac[i:i + 2] for i in range(0, len(found_mac), 2)]))
mac = ':'.join(a+b for a,b in zip(reversed_mac[::2], reversed_mac[1::2]))
data = line[26:]
if mac == deviceId and len(data) == 66:
#print(mac, data)
if u'626C756579' in data:
data2 = data[24:50]
#print(data)
x1 = int(data2[0:4], 16)
x2 = int(data2[4:8], 16)
x3 = int(data2[8:12], 16)
x4 = int(data2[12:16], 16)
#print("%x %x %x %x\n" % (x1, x2, x3, x4))
T, H, L = decodeData(x1, x2, x3, x4)
dweetURL = baseURL + "T=%.2f&&H=%.1f&&L=%d" % (T, H, L)
print(dweetURL)
try:
f = urllib2.urlopen(dweetURL)
res = f.read()
print(res)
f.close()
except:
print("dweet failed!")
scanner.stop()
exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment