working :)
This commit is contained in:
parent
9ecf3b6b31
commit
c1b460ab2d
Binary file not shown.
18
app_off.py
Normal file
18
app_off.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
#import pygatt
|
||||||
|
import os
|
||||||
|
|
||||||
|
#adapter = pygatt.GATTToolBackend()
|
||||||
|
on = 'cc2333'
|
||||||
|
off = 'cc2433'
|
||||||
|
|
||||||
|
try:
|
||||||
|
# adapter.start()
|
||||||
|
# device = adapter.connect("b2:3b:03:00:14:d6")
|
||||||
|
# device.char_write_handle(0x0009, bytearray.fromhex(off))
|
||||||
|
os.system('gatttool -i hci0 -b b2:3b:03:00:14:d6 --char-write-req -a 0x0009 -n cc2433')
|
||||||
|
except error as ex:
|
||||||
|
print(ex)
|
||||||
|
#finally:
|
||||||
|
# adapter.stop()
|
||||||
|
|
@ -3,7 +3,7 @@ import os
|
|||||||
import subprocess
|
import subprocess
|
||||||
from colormap import rgb2hex
|
from colormap import rgb2hex
|
||||||
from tenacity import retry, stop_after_attempt
|
from tenacity import retry, stop_after_attempt
|
||||||
|
import ast
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
@ -42,10 +42,15 @@ def off():
|
|||||||
@retry(stop=stop_after_attempt(5))
|
@retry(stop=stop_after_attempt(5))
|
||||||
def hello():
|
def hello():
|
||||||
print(request.args.get("rgb"))
|
print(request.args.get("rgb"))
|
||||||
rgb = list(request.args.get("rgb"))
|
rgb = ast.literal_eval(request.args.get("rgb"))
|
||||||
|
rgb = list(rgb)
|
||||||
|
# print(rgb)
|
||||||
r = rgb[0]
|
r = rgb[0]
|
||||||
|
# print(r)
|
||||||
g = rgb[1]
|
g = rgb[1]
|
||||||
|
# print(g)
|
||||||
b = rgb[2]
|
b = rgb[2]
|
||||||
|
# print(b)
|
||||||
hex = rgb2hex(r, g, b)
|
hex = rgb2hex(r, g, b)
|
||||||
hex = hex.replace("#", "")
|
hex = hex.replace("#", "")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user