Last active
May 20, 2021 13:46
-
-
Save ElectricImpSampleCode/a9825d7ff02bbfaa84e62360f05ab4cb to your computer and use it in GitHub Desktop.
Electric Imp imp API example code for imp.scanwifinetworks()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Scan for local WLANs using imp.scanwifinetworks() asynchronously | |
try { | |
imp.scanwifinetworks(function(networks) { | |
if (networks.len() > 0) { | |
foreach (index, network in networks) { | |
server.log(format("%d. %s on channel %d", (index + 1), (network.ssid.len() > 0 ? network.ssid : "<Hidden>"), network.channel)); | |
} | |
} else { | |
server.log("No nearby WiFi networks found"); | |
} | |
}); | |
} catch (err) { | |
server.error("Could not scan for networks (Error: " + err + ")"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment