diff --git a/src/bin/network/ifconfig/ifconfig.cpp b/src/bin/network/ifconfig/ifconfig.cpp index 8bf9375a1a..99f21eaad4 100644 --- a/src/bin/network/ifconfig/ifconfig.cpp +++ b/src/bin/network/ifconfig/ifconfig.cpp @@ -281,6 +281,7 @@ configure_wireless(const char* name, char* const* args, int32 argCount) { enum { NONE, + SCAN, LIST, JOIN, LEAVE, @@ -290,7 +291,9 @@ configure_wireless(const char* name, char* const* args, int32 argCount) int controlOption = -1; int controlValue = -1; - if (!strcmp(args[0], "list") || !strcmp(args[0], "scan")) + if (!strcmp(args[0], "scan")) + mode = SCAN; + else if (!strcmp(args[0], "list")) mode = LIST; else if (!strcmp(args[0], "join")) mode = JOIN; @@ -324,6 +327,16 @@ configure_wireless(const char* name, char* const* args, int32 argCount) argCount--; switch (mode) { + case SCAN: + { + status_t status = device.Scan(true, true); + if (status != B_OK) { + fprintf(stderr, "%s: Scan on \"%s\" failed: %s\n", kProgramName, + name, strerror(status)); + exit(1); + } + // fall through + } case LIST: { // list wireless network(s) diff --git a/src/preferences/network/InterfaceView.cpp b/src/preferences/network/InterfaceView.cpp index 58ca818d0d..71e7c6901b 100644 --- a/src/preferences/network/InterfaceView.cpp +++ b/src/preferences/network/InterfaceView.cpp @@ -262,6 +262,23 @@ InterfaceView::_Update(bool updateWirelessNetworks) wireless_network network; int32 count = 0; + cookie = 0; + if ((fPulseCount % 15) == 0 + && device.GetNextNetwork(cookie, network) != B_OK) { + // We don't seem to know of any networks, and it's been long + // enough since the last scan, so trigger one to try and + // find some networks. + device.Scan(false, false); + + // We don't want to block for the full length of the scan, but + // 50ms is often more than enough to find at least one network, + // and the increase in perceived QoS to the user of not seeing + // "no wireless networks" if we can avoid it is great enough + // to merit such a wait. It's only just over ~4 vertical + // retraces, anyway. + snooze(50 * 1000); + } + cookie = 0; while (device.GetNextNetwork(cookie, network) == B_OK) { BMessage* message = new BMessage(kMsgJoinNetwork);