conman: Add and fix logging.
Adds some debug logging around wpa_supplicant status requests.
Also fixes some incorrect logging that claimed we were connected to
the ACS on a specific wifi interface whenever connected to the ACS at
all.
Change-Id: I7ab766364e5a287d9020e3c2c0b554c13b7e6efa
diff --git a/conman/connection_manager.py b/conman/connection_manager.py
index a312b2c..91f189d 100755
--- a/conman/connection_manager.py
+++ b/conman/connection_manager.py
@@ -488,14 +488,15 @@
logging.debug('Unable to join WLAN on %s', wifi.name)
self._status.connected_to_wlan = False
if self.acs():
- logging.debug('Connected to ACS on %s', wifi.name)
+ logging.debug('Connected to ACS')
if self._try_to_upload_logs:
self._try_upload_logs()
self._try_to_upload_logs = False
- wifi.last_successful_bss_info = getattr(wifi,
- 'last_attempted_bss_info',
- None)
+ if wifi.acs():
+ wifi.last_successful_bss_info = getattr(wifi,
+ 'last_attempted_bss_info',
+ None)
now = time.time()
if (self._wlan_configuration and
hasattr(wifi, 'waiting_for_acs_since')):
@@ -517,7 +518,7 @@
# If we didn't manage to join the WLAN and we don't have an ACS
# connection, we should try to establish one.
else:
- logging.debug('Not connected to ACS on %s', wifi.name)
+ logging.debug('Not connected to ACS')
self._try_next_bssid(wifi)
time.sleep(max(0, self._run_duration_s - (time.time() - start_time)))
diff --git a/conman/interface.py b/conman/interface.py
index 1b77b18..653f407 100755
--- a/conman/interface.py
+++ b/conman/interface.py
@@ -379,14 +379,17 @@
return True
socket = os.path.join(path, self.name)
+ logging.debug('%s socket is %s', self.name, socket)
try:
self._wpa_control = self.get_wpa_control(socket)
self._wpa_control.attach()
+ logging.debug('%s successfully attached', self.name)
except wpactrl.error as e:
logging.error('Error attaching to wpa_supplicant: %s', e)
return False
status = self.wpa_status()
+ logging.debug('%s status after attaching is %s', self.name, status)
self.wpa_supplicant = status.get('wpa_state') == 'COMPLETED'
if not self._initialized:
self.initial_ssid = status.get('ssid')
@@ -403,17 +406,21 @@
status = {}
if self._wpa_control and self._wpa_control.attached:
+ logging.debug('%s ctrl_iface_path %s',
+ self, self._wpa_control.ctrl_iface_path)
lines = []
try:
lines = self._wpa_control.request('STATUS').splitlines()
- except wpactrl.error:
- logging.error('wpa_control STATUS request failed')
+ except wpactrl.error as e:
+ logging.error('wpa_control STATUS request failed %s args %s',
+ e.message, e.args)
for line in lines:
if '=' not in line:
continue
k, v = line.strip().split('=', 1)
status[k] = v
+ logging.debug('%s wpa status is %s', self.name, status)
return status
def get_wpa_control(self, socket):
@@ -468,7 +475,7 @@
WIFIINFO_PATH = '/tmp/wifi/wifiinfo'
def __init__(self, socket):
- self._interface = os.path.split(socket)[-1]
+ self.ctrl_iface_path, self._interface = os.path.split(socket)
# State from QCSAPI and wifi_files.
self._client_mode = False
diff --git a/conman/interface_test.py b/conman/interface_test.py
index 5b9d431..fb0bb82 100755
--- a/conman/interface_test.py
+++ b/conman/interface_test.py
@@ -114,6 +114,10 @@
else:
raise ValueError('Invalid request_type %s' % request_type)
+ @property
+ def ctrl_iface_path(self):
+ return os.path.split(self._socket)[0]
+
# Below methods are not part of WPACtrl.
def add_event(self, event):