From dbfa10263bd4f8202ccae4e8313cfc45c733fc8b Mon Sep 17 00:00:00 2001 From: Koen Vervloesem Date: Sun, 16 Jul 2023 16:14:31 +0200 Subject: [PATCH] Publish encrypted properties when PUBLISH_ADVDATA is 1 --- TheengsGateway/ble_gateway.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/TheengsGateway/ble_gateway.py b/TheengsGateway/ble_gateway.py index e886a10f..fc894b41 100644 --- a/TheengsGateway/ble_gateway.py +++ b/TheengsGateway/ble_gateway.py @@ -379,6 +379,11 @@ def detection_callback( decrypted_data, data_json, decoded_json ) + # Keep encrypted properties + cipher = decoded_json["cipher"] + mic = decoded_json["mic"] + ctr = decoded_json["ctr"] + # Re-decode advertisement, this time unencrypted decoded_json = decodeBLE(json.dumps(data_json)) if decoded_json: @@ -389,6 +394,11 @@ def detection_callback( data_json["servicedata"], ) + # Re-add encrypted properties + decoded_json["cipher"] = cipher + decoded_json["mic"] = mic + decoded_json["ctr"] = ctr + except KeyError: logger.exception( "Can't find bindkey for %s.", device.address @@ -413,6 +423,9 @@ def detection_callback( "cont", "track", "encr", + "cipher", + "mic", + "ctr", ): decoded_json.pop(key, None)