This project is read-only.

Toolbox.NETMF.Hardware.WiFlyGSX


Toolbox.NETMF.Hardware.WiFlyGSX(PortName, BaudRate, CommandChar)
  • PortName The serial port the module is connected to (default: COM1)
  • BaudRate The speed of the module (default: 9600)
  • CommandChar The character required to enter command mode (default: $)

Methods

  • JoinNetwork(SSID, Channel, Authentication, Key, KeyIndex) Joins a wireless network
  • EnableDHCP() Enables DHCP
  • EnableStaticIP(IPAddress, SubnetMask, Gateway, DNS) Enables a static IP
  • DnsLookup(Hostname) Returns the IP address matching the hostname
  • NtpLookup(IpAddress, Port) Returns the timestamp of an NTP server
  • OpenSocket(Hostname, Port, Timeout) Opens a TCP socket
  • SocketRead(Length, UntilReached) Reads from a TCP socket
  • SocketWrite(WriteBuffer) Writes to a TCP socket
  • CloseSocket() Closes an active TCP socket
  • Dispose() Releases the serial port and disposes this object

Properties

  • LocalIP Returns the local IP address
  • MacAddress Returns the devices MAC address
  • ModuleVersion Returns the firmware version of the module
  • Online Returns wether we're online or not
  • SocketConnected Returns true when we're connected to a socket
  • RemoteHostname Returns the hostname to which our TCP socket is connected
  • RemotePort Returns the TCP port we're connected to
  • SocketBufferLength Returns the amount of bytes waiting in the socket buffer

Sample code in C#

// Declares the WiFly module, configures the IP address and joins a wireless network
WiFlyGSX WifiModule = new WiFlyGSX();
WifiModule.EnableDHCP();
WifiModule.JoinNetwork("Netduino");

// Showing some interesting output
Debug.Print("Local IP: " + WifiModule.LocalIP);
Debug.Print("MAC address: " + WifiModule.MacAddress);

// Creates a socket
SimpleSocket Socket = new WiFlySocket("www.netmftoolbox.com", 80, WifiModule);

// Connects to the socket
Socket.Connect();

// Does a plain HTTP request
Socket.Send("GET /helloworld/ HTTP/1.1\r\n");
Socket.Send("Host: " + Socket.Hostname + "\r\n");
Socket.Send("Connection: Close\r\n");
Socket.Send("\r\n");

// Prints all received data to the debug window, until the connection is terminated
while (Socket.IsConnected)
{
    Debug.Print(Socket.Receive());
}

// Closes down the socket
Socket.Close();

Sample code in VB

' Declares the WiFly module, configures the IP address and joins a wireless network
Dim WifiModule As WiFlyGSX = New WiFlyGSX()
WifiModule.EnableDHCP()
WifiModule.JoinNetwork("Netduino")

' Showing some interesting output
Debug.Print("Local IP: " + WifiModule.LocalIP)
Debug.Print("MAC address: " + WifiModule.MacAddress)

' Creates a socket
Dim Socket As SimpleSocket = New WiFlySocket("www.netmftoolbox.com", 80, WifiModule)

' Connects to the socket
Socket.Connect()

' Does a plain HTTP request
Socket.Send("GET /helloworld/ HTTP/1.1" + Constants.vbCrLf)
Socket.Send("Host: " + Socket.Hostname + Constants.vbCrLf)
Socket.Send("Connection: Close" + Constants.vbCrLf)
Socket.Send(Constants.vbCrLf)

' Prints all received data to the debug window, until the connection is terminated
Do While Socket.IsConnected
    Debug.Print(Socket.Receive())
Loop

' Closes down the socket
Socket.Close()

Related documents

Last edited Jan 1, 2013 at 9:22 PM by Garrcomm, version 3