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
|
||||
@app.route("/on")
|
||||
def on():
|
||||
os.system(
|
||||
f"gatttool -i hci0 -b b2:3b:03:00:14:d6 --char-write-req -a 0x0009 -n cc2333"
|
||||
)
|
||||
return "On"
|
||||
result = subprocess.run(
|
||||
[f"gatttool -i hci0 -b b2:3b:03:00:14:d6 --char-write-req -a 0x0009 -n cc2333"],
|
||||
stdout=subprocess.PIPE,
|
||||
shell=True,
|
||||
).stdout.decode("utf-8")
|
||||
print(result)
|
||||
if "Characteristic value was written successfully" not in result:
|
||||
raise Exception
|
||||
else:
|
||||
return "On"
|
||||
|
||||
|
||||
@retry
|
||||
@app.route("/off")
|
||||
def off():
|
||||
os.system(
|
||||
f"gatttool -i hci0 -b b2:3b:03:00:14:d6 --char-write-req -a 0x0009 -n cc2433"
|
||||
)
|
||||
return "Off"
|
||||
result = subprocess.run(
|
||||
[f"gatttool -i hci0 -b b2:3b:03:00:14:d6 --char-write-req -a 0x0009 -n cc2433"],
|
||||
stdout=subprocess.PIPE,
|
||||
shell=True,
|
||||
).stdout.decode("utf-8")
|
||||
print(result)
|
||||
if "Characteristic value was written successfully" not in result:
|
||||
raise Exception
|
||||
else:
|
||||
return "Off"
|
||||
|
||||
|
||||
@retry
|
||||
@ -44,6 +56,6 @@ def hello():
|
||||
).stdout.decode("utf-8")
|
||||
print(result)
|
||||
if "Characteristic value was written successfully" not in result:
|
||||
raise Exception("Didn't work")
|
||||
raise Exception
|
||||
else:
|
||||
return request.query_string
|
||||
|
Loading…
x
Reference in New Issue
Block a user