diff --git a/killerbee/__init__.py b/killerbee/__init__.py index ac4febf..63c3099 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) diff --git a/killerbee/dev_cc253x.py b/killerbee/dev_cc253x.py index edc9a12..4707d73 100644 --- a/killerbee/dev_cc253x.py +++ b/killerbee/dev_cc253x.py @@ -241,11 +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 = framedata[-2] - 73 + rssi = struct.unpack('b', framedata[-2:-1])[0] - 73 # Dirty hack to compensate for possible RSSI overflow - if rssi > 255: - rssi = 255 # assumed to be max, could also report error/0 - + 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 + fcsx = framedata[-1] # validcrc is the bit 7 in fcsx validcrc = (fcsx & 0x80) == 0x80