wrong place
This commit is contained in:
parent
4f8d4ac222
commit
a79b3e1f24
30
server.py
30
server.py
@ -8,8 +8,8 @@ from tenacity import wait_exponential, retry, stop_after_attempt
|
|||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
|
||||||
@retry(wait=wait_exponential(multiplier=2, min=2, max=30), stop=stop_after_attempt(5))
|
|
||||||
@app.route("/on")
|
@app.route("/on")
|
||||||
|
@retry(wait=wait_exponential(multiplier=2, min=2, max=30), stop=stop_after_attempt(5))
|
||||||
def on():
|
def on():
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
[f"gatttool -i hci0 -b b2:3b:03:00:14:d6 --char-write-req -a 0x0009 -n cc2333"],
|
[f"gatttool -i hci0 -b b2:3b:03:00:14:d6 --char-write-req -a 0x0009 -n cc2333"],
|
||||||
@ -23,8 +23,8 @@ def on():
|
|||||||
return "On"
|
return "On"
|
||||||
|
|
||||||
|
|
||||||
@retry(wait=wait_exponential(multiplier=2, min=2, max=30), stop=stop_after_attempt(5))
|
|
||||||
@app.route("/off")
|
@app.route("/off")
|
||||||
|
@retry(wait=wait_exponential(multiplier=2, min=2, max=30), stop=stop_after_attempt(5))
|
||||||
def off():
|
def off():
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
[f"gatttool -i hci0 -b b2:3b:03:00:14:d6 --char-write-req -a 0x0009 -n cc2433"],
|
[f"gatttool -i hci0 -b b2:3b:03:00:14:d6 --char-write-req -a 0x0009 -n cc2433"],
|
||||||
@ -38,8 +38,8 @@ def off():
|
|||||||
return "Off"
|
return "Off"
|
||||||
|
|
||||||
|
|
||||||
@retry(wait=wait_exponential(multiplier=2, min=2, max=30), stop=stop_after_attempt(5))
|
|
||||||
@app.route("/colour")
|
@app.route("/colour")
|
||||||
|
@retry(wait=wait_exponential(multiplier=2, min=2, max=30), stop=stop_after_attempt(5))
|
||||||
def hello():
|
def hello():
|
||||||
# a = request.query_string
|
# a = request.query_string
|
||||||
r = int(request.args.get("r"))
|
r = int(request.args.get("r"))
|
||||||
@ -50,15 +50,17 @@ def hello():
|
|||||||
|
|
||||||
str = "56" + hex + "00f0aa"
|
str = "56" + hex + "00f0aa"
|
||||||
try:
|
try:
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
[f"gatttool -i hci0 -b b2:3b:03:00:14:d6 --char-write-req -a 0x0009 -n {str}"],
|
[
|
||||||
stdout=subprocess.PIPE,
|
f"gatttool -i hci0 -b b2:3b:03:00:14:d6 --char-write-req -a 0x0009 -n {str}"
|
||||||
shell=True,
|
],
|
||||||
).stdout.decode("utf-8")
|
stdout=subprocess.PIPE,
|
||||||
print(result)
|
shell=True,
|
||||||
if "Characteristic value was written successfully" not in result:
|
).stdout.decode("utf-8")
|
||||||
raise Exception
|
print(result)
|
||||||
else:
|
if "Characteristic value was written successfully" not in result:
|
||||||
return request.query_string
|
raise Exception
|
||||||
|
else:
|
||||||
|
return request.query_string
|
||||||
except:
|
except:
|
||||||
raise Exception
|
raise Exception
|
||||||
|
Loading…
x
Reference in New Issue
Block a user