Created
September 12, 2018 10:36
-
-
Save ElectricImpSampleCode/f9891dea9f50e86b6813dc00a0074cb6 to your computer and use it in GitHub Desktop.
Electric Imp imp API imp.net.counters() example
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
local debug = true; | |
local infoTable = {}; | |
local wifiData = imp.net.counters(); | |
if ("wwd_wifi" in wifiData) { | |
// Get the raw WiFi data from the WICED WiFi profile and use it | |
// to populate a Squirrel table of WiFi information | |
local dataBlob = wifiData.wwd_wifi; | |
infoTable.version <- dataBlob.readn('w'); | |
infoTable.length <- dataBlob.readn('w'); | |
infoTable.txframe <- dataBlob.readn('l'); | |
infoTable.txbyte <- dataBlob.readn('l'); | |
infoTable.txretrans <- dataBlob.readn('l'); | |
infoTable.txerror <- dataBlob.readn('l'); | |
// Output the WiFi information for debugging | |
if (debug) { | |
foreach (key, value in infoTable) { | |
server.log(key + ": " + value); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment