bowdentheo/BLE-Beacon-Scanner

Python3 TypeError: a bytes-like object is required, not 'int'

Closed this issue · 2 comments

File "BeaconScanner.py", line 19, in
returnedList = ScanUtility.parse_events(sock, 10)
File "/home/pi/BLE-Beacon-Scanner/ScanUtility.py", line 107, in parse_events
rssi, = struct.unpack("b", packet[packetOffset -1])
TypeError: a bytes-like object is required, not 'int'

(The same happens also at line 72)

This is acceptable only in Python 2. If you are running it in Python 3, use bytes().
Eg: struct.unpack("b", bytes(packet[packetOffset -1]))