From 1aadfb9b4b5ef8ede65b7216b913cdf869700e6d Mon Sep 17 00:00:00 2001 From: Siarhei Siniak Date: Sun, 13 Nov 2022 17:18:55 +0300 Subject: [PATCH] [~] Refactor --- .gitmodules | 3 +++ deps/rbaron-m6-reveng | 1 + python/tasks/ble.py | 25 ++++++++++++++++--------- 3 files changed, 20 insertions(+), 9 deletions(-) create mode 160000 deps/rbaron-m6-reveng diff --git a/.gitmodules b/.gitmodules index 499882c..3a68474 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,3 +10,6 @@ [submodule "deps/argrento-huami-token"] path = deps/argrento-huami-token url = https://github.com/argrento/huami-token +[submodule "deps/rbaron-m6-reveng"] + path = deps/rbaron-m6-reveng + url = https://github.com/rbaron/m6-reveng diff --git a/deps/rbaron-m6-reveng b/deps/rbaron-m6-reveng new file mode 160000 index 0000000..08bd1fe --- /dev/null +++ b/deps/rbaron-m6-reveng @@ -0,0 +1 @@ +Subproject commit 08bd1fe346ef402294a371dd565b6a6d3c52b96f diff --git a/python/tasks/ble.py b/python/tasks/ble.py index faa5d3a..8a25a8c 100644 --- a/python/tasks/ble.py +++ b/python/tasks/ble.py @@ -73,6 +73,7 @@ async def f5( async def f4( timeout=None, characteristics=None, + operations=None, name_check=None, ): if isinstance(name_check, str): @@ -104,15 +105,21 @@ async def f4( t4 = await f3(t3) pprint.pprint(t4) - t6 = {} - for o in characteristics: - try: - t7 = await t3.read_gatt_char(o) - except Exception as exception: - print(traceback.format_exc()) - t7 = None - t6[o] = t7 - pprint.pprint(t6) + if not operations is None and inspect.isfunction(operations): + await operations( + client=t3, + t4=t4, + ) + else: + t6 = {} + for o in characteristics: + try: + t7 = await t3.read_gatt_char(o) + except Exception as exception: + print(traceback.format_exc()) + t7 = None + t6[o] = t7 + pprint.pprint(t6) finally: if not t3 is None: await t3.disconnect()