Skip to content

Commit

Permalink
Stable work of connecting
Browse files Browse the repository at this point in the history
  • Loading branch information
isapozhkov committed Sep 20, 2016
1 parent a6c9c7a commit 496c3fe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='wificontrol',
version='0.0.8',
version='0.0.9',
author='Ivan Sapozhkov',
author_email='ivan.sapozhkov@emlid.com',
py_modules=['wificontrol'],
Expand Down
7 changes: 4 additions & 3 deletions wificontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ def get_network_state(self):
# OLNY FOR THREAD!!!
def try_to_connect(self, mac_ssid):
index_network_for_connect = self.find_network_id_from_ssid(mac_ssid["ssid"])
if self.enable_network(index_network_for_connect):
if (self.reconnect() and
self.enable_network(index_network_for_connect)):
if self.wait_untill_connection_complete():
return True
return False
Expand All @@ -356,12 +357,12 @@ def enable_network(self, network_id):
def wait_untill_connection_complete(self):
while self.network_parameter("wpa_state") != "COMPLETED":
if not self.connection_event.is_set():
print "Can't connect to network"
return False
return True

def check_correct_connection(self, mac_ssid):
if ((self.network_parameter("ssid") != mac_ssid["ssid"]) or
(self.network_parameter("bssid") != mac_ssid["mac address"])):
if ((self.network_parameter("ssid") != mac_ssid["ssid"])):
return False
return True

Expand Down

0 comments on commit 496c3fe

Please sign in to comment.