From 548d07cc09eb9e4da176e92a5d9200c0005bf499 Mon Sep 17 00:00:00 2001 From: Steve Date: Fri, 7 Jul 2023 09:45:03 -0400 Subject: [PATCH 1/4] converting 'device' string to usb object if 'hardware' and 'device' are specified --- killerbee/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/killerbee/__init__.py b/killerbee/__init__.py index ac4febf..e657bb0 100644 --- a/killerbee/__init__.py +++ b/killerbee/__init__.py @@ -66,6 +66,13 @@ def __init__(self, device: Optional[str]=None, hardware: Optional[str]=None, dat gps_devstring = gps if hardware is not None and device is not None: + if ":" in device: + result = search_usb(None) + if result is not None: + device = result + else: + raise KBInterfaceError("Did not find a USB device matching %s." % device) + if hardware == "apimote": from .dev_apimote import APIMOTE self.driver = APIMOTE(device) @@ -118,6 +125,7 @@ def __init__(self, device: Optional[str]=None, hardware: Optional[str]=None, dat elif ":" in device: result = search_usb(None) if result is not None: + print(f"Found device: {result}") self.dev = result else: raise KBInterfaceError("Did not find a USB device matching %s." % device) From db88df11594d88c111437c7dcc069ddc3566999f Mon Sep 17 00:00:00 2001 From: Steve Date: Fri, 7 Jul 2023 10:38:34 -0400 Subject: [PATCH 2/4] converting cc2531 rssi as signed 8 bit integer --- killerbee/dev_cc253x.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/killerbee/dev_cc253x.py b/killerbee/dev_cc253x.py index edc9a12..ba24513 100644 --- a/killerbee/dev_cc253x.py +++ b/killerbee/dev_cc253x.py @@ -241,6 +241,12 @@ def pnext(self, timeout=100): # in last two bytes of framedata. Note that we remove these before return of the frame. # RSSI is signed value, offset by 73 (see CC2530 data sheet for offset) + rssi = struct.unpack('b', framedata[-2:-1])[0] - 73 + # Dirty hack to compensate for possible RSSI overflow + if rssi > 127 or rssi < -127: + print(f"Rssi = {rssi}, out of range, setting to invalid valuei (-128)") + rssi = -128 # invalid value according to PPI spec + rssi = framedata[-2] - 73 # Dirty hack to compensate for possible RSSI overflow if rssi > 255: From 70b4993eddfad3bc062be57576d772b467192651 Mon Sep 17 00:00:00 2001 From: Steve Date: Fri, 7 Jul 2023 10:56:10 -0400 Subject: [PATCH 3/4] removed debug prints --- killerbee/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/killerbee/__init__.py b/killerbee/__init__.py index e657bb0..63c3099 100644 --- a/killerbee/__init__.py +++ b/killerbee/__init__.py @@ -125,7 +125,6 @@ def __init__(self, device: Optional[str]=None, hardware: Optional[str]=None, dat elif ":" in device: result = search_usb(None) if result is not None: - print(f"Found device: {result}") self.dev = result else: raise KBInterfaceError("Did not find a USB device matching %s." % device) From 96e2d75e963f46ce7d64080a96c2e28fb3693466 Mon Sep 17 00:00:00 2001 From: Steve Date: Thu, 31 Aug 2023 13:30:36 -0400 Subject: [PATCH 4/4] removed original RSSI calculation code --- killerbee/dev_cc253x.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/killerbee/dev_cc253x.py b/killerbee/dev_cc253x.py index ba24513..4707d73 100644 --- a/killerbee/dev_cc253x.py +++ b/killerbee/dev_cc253x.py @@ -247,11 +247,6 @@ def pnext(self, timeout=100): print(f"Rssi = {rssi}, out of range, setting to invalid valuei (-128)") rssi = -128 # invalid value according to PPI spec - rssi = framedata[-2] - 73 - # Dirty hack to compensate for possible RSSI overflow - if rssi > 255: - rssi = 255 # assumed to be max, could also report error/0 - fcsx = framedata[-1] # validcrc is the bit 7 in fcsx validcrc = (fcsx & 0x80) == 0x80