i think working

This commit is contained in:
karl.hudgell 2021-10-26 16:33:17 +01:00
parent 55e226d50d
commit 9ecf3b6b31

View File

@ -42,21 +42,21 @@ 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 = (request.args.get("rgb") rgb = list(request.args.get("rgb"))
# r = int(request.args.get("r")) r = rgb[0]
# g = int(request.args.get("g")) g = rgb[1]
# b = int(request.args.get("b")) b = rgb[2]
# hex = rgb2hex(r, g, b) hex = rgb2hex(r, g, b)
# hex = hex.replace("#", "") hex = hex.replace("#", "")
# str = "56" + hex + "00f0aa" str = "56" + hex + "00f0aa"
# result = subprocess.run( result = subprocess.run(
# [f"gatttool -i hci0 -b b2:3b:03:00:14:d6 --char-write-req -a 0x0009 -n {str}"], [f"gatttool -i hci0 -b b2:3b:03:00:14:d6 --char-write-req -a 0x0009 -n {str}"],
# stdout=subprocess.PIPE, stdout=subprocess.PIPE,
# shell=True, shell=True,
# ).stdout.decode("utf-8") ).stdout.decode("utf-8")
# print(result) print(result)
if "Characteristic value was written successfully" not in result: if "Characteristic value was written successfully" not in result:
raise Exception raise Exception
else: else:
return request.query_string return hex