From 976bb7ceb1d16824560d297ebafb98285d6c994c Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Tue, 9 Feb 2016 17:08:43 -0600 Subject: [PATCH] network: Update network_connected implementation --- src/network.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/network.c b/src/network.c index a940a68f..aa025bd3 100644 --- a/src/network.c +++ b/src/network.c @@ -109,6 +109,7 @@ bool network_connected(uint32_t type, const char *ssid) int err; struct network_info *info; struct network_info search; + const char *strtype; search.type = type; strncpy(search.ssid, ssid, 32); @@ -118,15 +119,15 @@ bool network_connected(uint32_t type, const char *ssid) if (!info) return false; - switch(type) { - case SCAN_SSID_SECURITY_PSK: - err = storage_network_get_mtime("psk", ssid, - &info->connected_time); - break; - default: + strtype = scan_ssid_security_to_str(type); + if (!strtype) goto fail; - } + err = storage_network_touch(strtype, ssid); + if (err < 0) + goto fail; + + err = storage_network_get_mtime(strtype, ssid, &info->connected_time); if (err < 0) goto fail;