i think working
This commit is contained in:
parent
55e226d50d
commit
9ecf3b6b31
28
server.py
28
server.py
@ -42,21 +42,21 @@ def off():
|
||||
@retry(stop=stop_after_attempt(5))
|
||||
def hello():
|
||||
print(request.args.get("rgb"))
|
||||
# rgb = (request.args.get("rgb")
|
||||
# r = int(request.args.get("r"))
|
||||
# g = int(request.args.get("g"))
|
||||
# b = int(request.args.get("b"))
|
||||
# hex = rgb2hex(r, g, b)
|
||||
# hex = hex.replace("#", "")
|
||||
rgb = list(request.args.get("rgb"))
|
||||
r = rgb[0]
|
||||
g = rgb[1]
|
||||
b = rgb[2]
|
||||
hex = rgb2hex(r, g, b)
|
||||
hex = hex.replace("#", "")
|
||||
|
||||
# str = "56" + hex + "00f0aa"
|
||||
# result = subprocess.run(
|
||||
# [f"gatttool -i hci0 -b b2:3b:03:00:14:d6 --char-write-req -a 0x0009 -n {str}"],
|
||||
# stdout=subprocess.PIPE,
|
||||
# shell=True,
|
||||
# ).stdout.decode("utf-8")
|
||||
# print(result)
|
||||
str = "56" + hex + "00f0aa"
|
||||
result = subprocess.run(
|
||||
[f"gatttool -i hci0 -b b2:3b:03:00:14:d6 --char-write-req -a 0x0009 -n {str}"],
|
||||
stdout=subprocess.PIPE,
|
||||
shell=True,
|
||||
).stdout.decode("utf-8")
|
||||
print(result)
|
||||
if "Characteristic value was written successfully" not in result:
|
||||
raise Exception
|
||||
else:
|
||||
return request.query_string
|
||||
return hex
|
||||
|
Loading…
x
Reference in New Issue
Block a user