From 47850a8b145269846a3543405ae04ed3bb234319 Mon Sep 17 00:00:00 2001 From: Gianfranco Cicciomessere Date: Thu, 27 Jul 2023 16:53:38 +0100 Subject: [PATCH] Fixed incorrect rssi calculation Similar to pr #278 but these values work better --- killerbee/dev_cc253x.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/killerbee/dev_cc253x.py b/killerbee/dev_cc253x.py index edc9a12..18bc36a 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) + # Possible fix for incorrect rssi calculation + rssi = struct.unpack('b', framedata[-2:-1])[0] - 73 + if rssi > 127 or rssi < -128: + print(f"Rssi = {rssi}, out of range, setting to 127") + rssi = 127 + rssi = framedata[-2] - 73 # Dirty hack to compensate for possible RSSI overflow if rssi > 255: