So I have managed to get my hands on a Iot Labs WF121 based WiFi module long enough to do some interesting tests
First off - big thanks to @ munderhill for writing the driver - Mike has done an excellent job on the driver and it’s very simple to use.
In my test I am calling a RESTful API and sending a random number every 5 seconds across the interweb to one of my servers sitting in a data centre and sticking it in a SQL DB.
No dramas, no fuss and I stopped the test after > 6000 calls - Mint ;D
Here’s the code I am running:
using System;
using System.Threading;
using IotLabs.Hardware.Bluegiga;
using IotLabs.Net;
using Microsoft.SPOT;
namespace OctopusApp
{
public partial class Program
{
private GadgeteerWifi _wifi;
private Random _rnd;
private Timer _timer;
private WifiSocket _wifiSocket;
void ProgramStarted()
{
_rnd = new Random();
_wifi = new GadgeteerWifi(3);
_wifi.StateChanged += new EventHandler(OnStateChanged);
_wifi.AccessPointFound += new WifiBase.AccessPointFoundEventDelegate(OnAccessPointFound);
_wifi.AddressChanged += new EventHandler(OnAddressChanged);
_wifi.WifiStateChanged += new WifiBase.WifiStateChangedDelegate(OnWifiStateChanged);
_wifi.ConnectionStateChanged += new EventHandler(OnConnectionStateChanged);
_wifi.CommandFailed += new WifiBase.CommandFailedDelegate(OnCommandFailed);
_wifi.Start();
}
void OnWifiStateChanged(object sender, WifiStateChangedEventArgs e)
{
if (e.NewState == WifiStates.On)
{
_wifi.Connect("xxxx", "xxxx");
}
}
void OnCommandFailed(object sender, CommandFailedEventArgs e)
{
Debug.Print("ERROR = " + e.ErrorDescription);
}
void OnConnectionStateChanged(object sender, EventArgs e)
{
_wifiSocket = new WifiSocket(_wifi, "netmf.ingenuitymicro.com");
Thread spamThread = new Thread(Spam);
spamThread.Start();
}
void Spam()
{
for (;;)
{
HttpClient httpClient = new HttpClient(_wifiSocket);
httpClient.Put("/api/values?value=" + _rnd.Next(100));
Thread.Sleep(5000);
}
}
void OnAddressChanged(object sender, EventArgs e)
{
Debug.Print(_wifi.MacAddress.ToString());
Debug.Print(_wifi.IpAddress.ToString());
Debug.Print(_wifi.NetMask.ToString());
Debug.Print(_wifi.Gateway.ToString());
}
void OnAccessPointFound(object sender, AccessPointFoundEventArgs e)
{
if (e.SSID != null)
{
Debug.Print("Found AccessPoint - " + e.SSID);
}
}
void OnStateChanged(object sender, EventArgs e)
{
Debug.Print("State = " + _wifi.State.ToString());
}
}
}
@ kiwi_stu - I have not run any power consumption test. I’d appreciate help in devising a plan though The module will be available in both a chip antenna version and one with a U.FL connector. Price has not been set yet, but should be ~$60-65 (US).
Looking forward to turning one of those modules over to Dr. Evil for some testing as I think there is something special lined up for it. Looks like a gotta have module in the Gadgeteer tool box, nice API.
@ munderhill ask @ Justin as Dr. Evil has kept him up maybe more then a few nights Some of the tests aren’t spoken of outside of the lab but Dr. Evil has a unique ability to break things in interesting ways.
Another milestone towards production has been made! The module now supports OTA updates to it’s firmware! Very simple API. Board will be updated to use 2 Gadgeteer sockets (K and S) and 4 mounting holes.
private void UpdateFirmware()
{
var wifiSocket = new WifiSocket(_wifi, "iotlabs.azurewebsites.net");
_updater = new FirmwareUpdater(wifiSocket);
_updater.UpdateCompleted += new EventHandler(OnUpdateCompleted);
_updater.UpdateFailed += new EventHandler(OnUpdateFailed);
_updater.Update("/iot-labs.bin");
}
void OnUpdateFailed(object sender, EventArgs e)
{
Debug.Print("Update Failed!!");
}
void OnUpdateCompleted(object sender, EventArgs e)
{
_wifi.LoadPersistentStoreKey(PersistentStoreKeys.IotLabsFirmwareVersion);
}
Another important feature just added to the IoT Labs IL-G-WF121 driver is support for WPS! Now your IoT Labs enabled project can connect to an access point without knowing the SSID or password.
void ProgramStarted()
{
_wifi = new GadgeteerWifi();
_wifi.WifiStateChanged += new WifiBase.WifiStateChangedDelegate(OnWifiStateChanged);
_wifi.WpsCompleted += new EventHandler(OnWpsCompleted);
_wifi.WifiOn();
}
void OnWifiStateChanged(object sender, WifiStateChangedEventArgs e)
{
if (e.NewState == WifiStates.On)
{
_wifi.StartWPS();
}
}
void OnWpsCompleted(object sender, EventArgs e)
{
_wifi.ConnectWPS();
}
So, I’m back from vacation with version 2 of the IoT Labs IL-G-WF121 WiFi module! The board now includes a Flash memory chip to support OTA updates of the firmware. When not being used for updates it may be used by an application as we also provide a driver. The board now requires a K (wifi) and S (flash) socket. It can be used without the S socket connected, but OTA updates will not be supported then.