Implementation of the WifiPlusClick hardware module.

Dependents:   WifiPlusKlickExample

WifiPlusClick Libary

Overview

http://www.mikroe.com/img/development-tools/accessory-boards/click/wifi-plus/wifi_plus_click_main.png

This library implements the functionality exposed by a WifiPlusClick module from MikroElektronika (http://www.mikroe.com/click/wifi-plus/).

The WifiPlusClick module is an easy to handle module which provides access to up to 8 simultaneous socket objects - which is an an important aspect when you want to implement your own web server.

When I first started with the more commonly used Wifly module, I found out that the Wifly module does not reliably serve webpages which include other resources like images, JavaScript files or CSS files. The root cause seems to be the limitation that Wifly is only able to handle a single socket at this time. So I searched for an alternative and found this (actually cheaper) alternative :

WifiPlusClick HW Module

This module comes with its own limitations. The WifiPlusClick Module interface does not allow to use broadcasting or multicasting on UDP sockets. There are some additional limitations, but I think these are not so important. The following functionality is provided by the module and my library implementation :

  1. Wifi functionality
    1. Connections using AD-HOC or INFRASTRUCTURE mode
    2. List all available Wifi beacons
    3. WEP and WPA/WPA2 security modes including binary and ASCII keys
    4. reading binary WPA key after successfull Connection to speed up connection time
  2. Socket functionality
    1. UDP sockets
    2. TCP sockets

Limitations

I found the following limitations:

  1. UDP sockets cannot use multicasting or broadcasting
  2. set_option functionality is not provided by the HW
  3. 8 sockets can be configured with 1024 bytes of buffer each or 1 socket with 8192 bytes of buffer.

Sample application

Here is my sample application which you can use as a starting point.

Import programWifiPlusKlickExample

Example application of the WifiPlusClick library for use of WifiPlusClick HW Module from Mikroe.com

NOTE

The implementation of the Sockets in this library is still not completely tested. I only tested the TCP part of the sockets. Please let me know what your experiences are when using the library. I will be working on a multithreaded version of this library...

Committer:
leihen
Date:
Mon Jul 29 15:15:21 2013 +0000
Revision:
0:2a179bd4cc02
Initial Version of the WifiPlusClick Library.
; Tested in INFRASTRUCTURE mode only.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
leihen 0:2a179bd4cc02 1 #include "mbed.h"
leihen 0:2a179bd4cc02 2 #include "WifiPlusClick.h"
leihen 0:2a179bd4cc02 3
leihen 0:2a179bd4cc02 4
leihen 0:2a179bd4cc02 5
leihen 0:2a179bd4cc02 6 WifiPlusClick::WifiPlusClick(PinName tx, PinName rx, PinName rst, bool dhcp, const char * ssid, WPA_SECURITY_t sec, const char* passphrase, int plen)
leihen 0:2a179bd4cc02 7 : Wifi(tx, rx, rst)
leihen 0:2a179bd4cc02 8 {
leihen 0:2a179bd4cc02 9 char ChannelList[11] = {1,2,5,6,7,8,9,10,11, 12, 13};
leihen 0:2a179bd4cc02 10 Reset();
leihen 0:2a179bd4cc02 11 wait(.8);
leihen 0:2a179bd4cc02 12
leihen 0:2a179bd4cc02 13 // Set to european domain
leihen 0:2a179bd4cc02 14 SetRegionalDomain(ETSI);
leihen 0:2a179bd4cc02 15 SetChannelList(5, ChannelList);
leihen 0:2a179bd4cc02 16 SetARPTime(1);
leihen 0:2a179bd4cc02 17 SetRetryCount(20,20);
leihen 0:2a179bd4cc02 18
leihen 0:2a179bd4cc02 19 SetSSID(1, ssid);
leihen 0:2a179bd4cc02 20 SetSecurityWPA(1, sec, plen, passphrase);
leihen 0:2a179bd4cc02 21 }
leihen 0:2a179bd4cc02 22
leihen 0:2a179bd4cc02 23 bool WifiPlusClick::connect()
leihen 0:2a179bd4cc02 24 {
leihen 0:2a179bd4cc02 25 SetNetworkMode(1, INFRASTRUCTURE);
leihen 0:2a179bd4cc02 26 SetIpAddress(true, NULL);
leihen 0:2a179bd4cc02 27
leihen 0:2a179bd4cc02 28 Connect(1);
leihen 0:2a179bd4cc02 29
leihen 0:2a179bd4cc02 30 return AwaitConnected(60);
leihen 0:2a179bd4cc02 31 }
leihen 0:2a179bd4cc02 32
leihen 0:2a179bd4cc02 33 bool WifiPlusClick::connect(IPADDRESS_t *ipAddress, IPADDRESS_t *subnetMask, IPADDRESS_t *ipGateway)
leihen 0:2a179bd4cc02 34 {
leihen 0:2a179bd4cc02 35 if ((ipAddress == NULL) || (subnetMask == NULL) || (ipGateway == NULL))
leihen 0:2a179bd4cc02 36 return false;
leihen 0:2a179bd4cc02 37
leihen 0:2a179bd4cc02 38 SetNetworkMode(1, ADHOC);
leihen 0:2a179bd4cc02 39 SetIpAddress(false, ipAddress);
leihen 0:2a179bd4cc02 40 SetSubnetMask(subnetMask);
leihen 0:2a179bd4cc02 41 SetGatewayIpAddress(ipGateway);
leihen 0:2a179bd4cc02 42
leihen 0:2a179bd4cc02 43 Connect(1);
leihen 0:2a179bd4cc02 44
leihen 0:2a179bd4cc02 45 return AwaitConnected(60);
leihen 0:2a179bd4cc02 46 }
leihen 0:2a179bd4cc02 47
leihen 0:2a179bd4cc02 48 bool WifiPlusClick::disconnect()
leihen 0:2a179bd4cc02 49 {
leihen 0:2a179bd4cc02 50 Disconnect();
leihen 0:2a179bd4cc02 51
leihen 0:2a179bd4cc02 52 return AwaitDisconnected(60);
leihen 0:2a179bd4cc02 53 }