From 4f8d4ac222e5179b298b762a7d79a012bfd891fe Mon Sep 17 00:00:00 2001 From: "karl.hudgell" Date: Tue, 26 Oct 2021 15:54:18 +0100 Subject: [PATCH] meh --- server.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/server.py b/server.py index 381e445..ae4e2ed 100644 --- a/server.py +++ b/server.py @@ -49,14 +49,16 @@ def hello(): hex = hex.replace("#", "") str = "56" + hex + "00f0aa" - # try: - 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 + try: + 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 + except: + raise Exception \ No newline at end of file