new try
This commit is contained in:
parent
b31d16958f
commit
541fc7dc6a
30
server.py
30
server.py
@ -10,19 +10,31 @@ app = Flask(__name__)
|
|||||||
@retry
|
@retry
|
||||||
@app.route("/on")
|
@app.route("/on")
|
||||||
def on():
|
def on():
|
||||||
os.system(
|
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"],
|
||||||
)
|
stdout=subprocess.PIPE,
|
||||||
return "On"
|
shell=True,
|
||||||
|
).stdout.decode("utf-8")
|
||||||
|
print(result)
|
||||||
|
if "Characteristic value was written successfully" not in result:
|
||||||
|
raise Exception
|
||||||
|
else:
|
||||||
|
return "On"
|
||||||
|
|
||||||
|
|
||||||
@retry
|
@retry
|
||||||
@app.route("/off")
|
@app.route("/off")
|
||||||
def off():
|
def off():
|
||||||
os.system(
|
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"],
|
||||||
)
|
stdout=subprocess.PIPE,
|
||||||
return "Off"
|
shell=True,
|
||||||
|
).stdout.decode("utf-8")
|
||||||
|
print(result)
|
||||||
|
if "Characteristic value was written successfully" not in result:
|
||||||
|
raise Exception
|
||||||
|
else:
|
||||||
|
return "Off"
|
||||||
|
|
||||||
|
|
||||||
@retry
|
@retry
|
||||||
@ -44,6 +56,6 @@ def hello():
|
|||||||
).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("Didn't work")
|
raise Exception
|
||||||
else:
|
else:
|
||||||
return request.query_string
|
return request.query_string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user