Skip to content

Instantly share code, notes, and snippets.

@electronut
Created June 14, 2017 09:28
Show Gist options
  • Save electronut/8921d2ed70ad17bdfb593db7902895e1 to your computer and use it in GitHub Desktop.
Save electronut/8921d2ed70ad17bdfb593db7902895e1 to your computer and use it in GitHub Desktop.
Process BLE UUID to code format...
"""
process_uid.py
eg.
Input: 80c4a66b-ddb7-46e3-87bc-ae7053faf6ee
Output: 0xee,0xf6,0xfa,0x53,0x70,0xae,0xbc,0x87,0xe3,0x46,0xb7,0xdd,0x6b,0xa6,0xc4,0x80
electronut.in
"""
import sys
if (len(sys.argv) < 2):
print("missing args!")
exit(0)
# expecting something like "80c4a66b-ddb7-46e3-87bc-ae7053faf6ee"
a = sys.argv[1]
a = a.replace("-","")
b = [a[i:i+2] for i in range(0, len(a), 2)][::-1]
c = ",".join(["0x%s" % x for x in b])
print(c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment