Skip to content

Instantly share code, notes, and snippets.

@ElectricImpSampleCode
Created September 12, 2018 10:36
Show Gist options
  • Save ElectricImpSampleCode/f9891dea9f50e86b6813dc00a0074cb6 to your computer and use it in GitHub Desktop.
Save ElectricImpSampleCode/f9891dea9f50e86b6813dc00a0074cb6 to your computer and use it in GitHub Desktop.
Electric Imp imp API imp.net.counters() example
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