diff --git a/__pycache__/server.cpython-37.pyc b/__pycache__/server.cpython-37.pyc index aebb677..2582865 100644 Binary files a/__pycache__/server.cpython-37.pyc and b/__pycache__/server.cpython-37.pyc differ diff --git a/app_off.py b/app_off.py new file mode 100644 index 0000000..0b064c3 --- /dev/null +++ b/app_off.py @@ -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() + diff --git a/server.py b/server.py index 5ca726d..709d9a1 100644 --- a/server.py +++ b/server.py @@ -3,7 +3,7 @@ import os import subprocess from colormap import rgb2hex from tenacity import retry, stop_after_attempt - +import ast app = Flask(__name__) @@ -42,10 +42,15 @@ def off(): @retry(stop=stop_after_attempt(5)) def hello(): 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] +# print(r) g = rgb[1] +# print(g) b = rgb[2] +# print(b) hex = rgb2hex(r, g, b) hex = hex.replace("#", "")