Main Site Documentation

IoT Labs WiFi module


#1

So I have managed to get my hands on a Iot Labs WF121 based WiFi module long enough to do some interesting tests :slight_smile:

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());
		}
	}
}


#2

@ Justin - Thanks, glad your tests are yielding satisfactory result! Getting closer to releasing this to all the Gadgeteers who want one. ;D


#3

@ munderhil - looks great work and nice module Mike. Any power consumption figures? Will you be able to connect an antenna? Any idea of cost yet?


#4

@ kiwi_stu - I have not run any power consumption test. I’d appreciate help in devising a plan though :wink: 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).


#5

@ Justin - That code is beautiful in it’s simplicity. Love it!

@ munderhil - Nice looking API!


#6

@ Valkyrie-MT - yes, Mike has done an excellent job on the driver :slight_smile:


#7

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.


#8

@ Duke Nukem - Should I be scared? Dr. Evil?
:open_mouth:


#9

@ munderhill ask @ Justin as Dr. Evil has kept him up maybe more then a few nights :wink: 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.


#10

love the strategically placed caffeine holder too.

Can I request - 4 holes for mounting ? I know it costs board space, but to be able to securely mount it is a good thing…


#11

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);
}


#12

Nice work Mike!


#13

excellent. Where’s that “take my money” button ? :slight_smile:


#14

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();
}


#15

Mint.


#16

Very nice

Any ETA ??


#17

New boards are on order, should be in September if all goes well! :wink:


#18

Let me know when you accept orders :slight_smile:


#19

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.


#20

Another shot…