mirror of
https://github.com/smittix/intercept.git
synced 2026-07-19 23:08:10 -07:00
Fix is_known_tracker to handle hex string manufacturer data
The function now accepts both bytes and hex string formats for manufacturer_data, converting hex strings to bytes before processing. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -365,10 +365,14 @@ def get_all_sweep_presets() -> dict:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def is_known_tracker(device_name: str | None, manufacturer_data: bytes | None = None) -> dict | None:
|
def is_known_tracker(device_name: str | None, manufacturer_data: bytes | str | None = None) -> dict | None:
|
||||||
"""
|
"""
|
||||||
Check if a BLE device matches known tracker signatures.
|
Check if a BLE device matches known tracker signatures.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
device_name: Device name to check against patterns
|
||||||
|
manufacturer_data: Manufacturer data as bytes or hex string
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Tracker info dict if match found, None otherwise
|
Tracker info dict if match found, None otherwise
|
||||||
"""
|
"""
|
||||||
@@ -379,11 +383,20 @@ def is_known_tracker(device_name: str | None, manufacturer_data: bytes | None =
|
|||||||
if pattern in name_lower:
|
if pattern in name_lower:
|
||||||
return tracker_info
|
return tracker_info
|
||||||
|
|
||||||
if manufacturer_data and len(manufacturer_data) >= 2:
|
if manufacturer_data:
|
||||||
company_id = int.from_bytes(manufacturer_data[:2], 'little')
|
# Convert hex string to bytes if needed
|
||||||
for tracker_id, tracker_info in BLE_TRACKER_SIGNATURES.items():
|
mfr_bytes = manufacturer_data
|
||||||
if tracker_info.get('company_id') == company_id:
|
if isinstance(manufacturer_data, str):
|
||||||
return tracker_info
|
try:
|
||||||
|
mfr_bytes = bytes.fromhex(manufacturer_data)
|
||||||
|
except ValueError:
|
||||||
|
return None
|
||||||
|
|
||||||
|
if len(mfr_bytes) >= 2:
|
||||||
|
company_id = int.from_bytes(mfr_bytes[:2], 'little')
|
||||||
|
for tracker_id, tracker_info in BLE_TRACKER_SIGNATURES.items():
|
||||||
|
if tracker_info.get('company_id') == company_id:
|
||||||
|
return tracker_info
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user