WiFly Shield Hookup Guide

Pages
Contributors: Joel_E_B, CTaylor
Favorited Favorite 3

Communicating with the Network

Now that the WiFly is connected, we’d like to communicate with the network. But how? What do we send? Where do we send it? The WiFly will transmit anything it’s sent, the trick to successful networking is knowing where the data is going and how to package it.

When the WiFly connects to an access point, it communicates through a port. Ports are like sub-addresses, they indicate what type of information is being sent or received so that devices know how to use the sent data. For example, when trying to reach a website, a browser communicates on port 80, which is the HTTP port (hence the “http://” at the beginning of most URLs). The server “listens” on port 80, and when a browser request comes in, it sends the requested information back on port 80. There are thousands of port numbers, each with a different standardized protocol.

By default, the WiFly transmits and listens on port 2000. We can change the port by sending the command

set ip local <port>

Where <port> is the port on which the WiFly will listen. To listen for HTTP requests from a browser, we send the command

set ip local 80

Now, any computer that is also connected to the same access point as the WiFly can query the WiFly through a browser. Simply open a browser and attempt to navigate to

http://<IP of WiFly>

The IP address of the WiFly is always printed when it joins a network, and you can always find it by sending the command

get ip

when the device is in command mode.

When the WiFly receives a request from a browser, it will print the incoming data to the terminal. For example:

alt text

The browser is now waiting for data, the WiFly can send sensor values, serve web pages, or any other data straight back to the browser! In this case, the browser is waiting for a web page. If the WiFly responds with an HTML-formatted page, the browser will display it. The next section will show you exactly how to do that.