Parse the output of iwlist scan to get the name, address, quality, channel, and encryption type of all networks broadcasting within your Wireless NIC's reach.
>>> get_interfaces()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pi/smartcar-app-v1/lib/iw_parse.py", line 336, in get_interfaces
return get_parsed_cells(call_iwlist(interface).split('\n'))
TypeError: a bytes-like object is required, not 'str'
apparently the underlying call_iwlist is returning a byte object
So to fix the issue I just updated the get_interfaces to decode the call_iwlist as following,
def get_interfaces(interface="wlan0"):
""" Get parsed iwlist output
@param string interface
interface to scan
default is wlan0
@param list columns
default data attributes to return
@return dict
properties: dictionary of iwlist attributes
"""
return get_parsed_cells(call_iwlist(interface).decode().split('\n'))
On RPI 4, I am getting following error,
apparently the underlying
call_iwlist
is returning a byte objectSo to fix the issue I just updated the
get_interfaces
todecode
thecall_iwlist
as following,