Skip to content

Commit

Permalink
process_prmacs in separate method
Browse files Browse the repository at this point in the history
  • Loading branch information
DigiH committed Dec 18, 2023
1 parent 0faf830 commit bf89de1
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions TheengsGateway/ble_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,9 @@ def decode_advertisement(
decoded_json = json.loads(decoded_json)

if "prmac" in decoded_json:
address = decoded_json.get("id")
if address in self.configuration["identities"]:
decoded_json.pop("prmac", None)
else:
decoded_json["type"] = "RMAC"
decoded_json = self.process_prmacs(
decoded_json,
)

# Only process if the device is not a random mac address
if decoded_json["type"] != "RMAC":
Expand Down Expand Up @@ -501,6 +499,19 @@ def decode_advertisement(
add_manufacturer(data_json, company_id)
self.publish_json(data_json, decoded=False)

def process_prmacs(
self,
decoded_json: DataJSONType,
) -> DataJSONType:
"""Process potential RMACs."""
address = decoded_json.get("id")
if address in self.configuration["identities"]:
decoded_json.pop("prmac", None)
else:
decoded_json["type"] = "RMAC"

return decoded_json

def publish_json(
self,
data_json: DataJSONType,
Expand Down

0 comments on commit bf89de1

Please sign in to comment.