Skip to content

Commit

Permalink
optimize beaconDecoder
Browse files Browse the repository at this point in the history
  • Loading branch information
PointlessUser committed Oct 21, 2023
1 parent de67991 commit ba42d0f
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/beaconDecoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,15 @@ def beaconBase64Decode(self):
def beaconParseData(self):
packet_num_offset = 4
beacon_ID = 99
beacon_port = 1
beacon_port = 1

try:
if self.decoded_data[packet_num_offset] == 1:
self.decoded_data[:0] = (1).to_bytes(1,'big')
return self.parser.parseReturnValue(beacon_ID, beacon_port, self.decoded_data)
elif self.decoded_data[packet_num_offset] == 2:
self.decoded_data[:0] = (2).to_bytes(1,'big')
if self.decoded_data[packet_num_offset] in {1, 2}:
self.decoded_data[:0] = self.decoded_data[packet_num_offset].to_bytes(1,'big')
return self.parser.parseReturnValue(beacon_ID, beacon_port, self.decoded_data)
else:
print("Invalid beacon packet number")
except:
except Exception:
print("Unable to parse packet data")
return None

Expand Down

0 comments on commit ba42d0f

Please sign in to comment.