Buenas
after the resounding success of the post from yesterday on how to create a camera with GT, today I leave you a couple of lines to work with Wifi adapter.
For this example I’ve used the following items
- Fez Spider Mainboard
http://www.ghielectronics.com/catalog/product/269 - USB Client DP
http://www.netmf.com/showcase.aspx?ShowcaseID=1 & id = 110 - RS21 WiFi Module
http://www.ghielectronics.com/catalog/product/282
And connected in the following way
Then the following code shows the following:
- Line 12, listing all the free WIFI network that the sensor captures
- Line 19, how to connect to an open WIFI network
- Line 27, how to connect to a secure WIFI network with WAP
- Line 36, show the current connected network information
1: using GHI.Premium.Net;
2: using Microsoft.SPOT;
3:
4: namespace GadgeteerApp4
5: {
6: public partial class Program
7: {
8: void ProgramStarted()
9: {
10: wifi_RS21.Interface.NetworkAddressChanged += InterfaceNetworkAddressChanged;
11:
12: // Lista de todas las wifis disponibles
13: var wifis = wifi_RS21.Interface.Scan();
14: foreach (var wiFiNetworkInfo in wifis)
15: {
16: Debug.Print("Wifi - SSID:" + wiFiNetworkInfo.SSID + "- Sec Mode:" + wiFiNetworkInfo.SecMode);
17: }
18:
19: // connect to OPEN wifi network
20: var hostingNetwork = new WiFiNetworkInfo
21: {
22: SSID = "SSID_WifiOpen",
23: SecMode = SecurityMode.Open
24: };
25: wifi_RS21.Interface.Join(hostingNetwork, "");
26:
27: // connect to WPA wifi network
28: hostingNetwork = new WiFiNetworkInfo
29: {
30: SSID = "SSID_WifiWap",
31: SecMode = SecurityMode.WPA
32: };
33: wifi_RS21.Interface.Join(hostingNetwork, "Password goes here");
34: }
35:
36: void InterfaceNetworkAddressChanged(object sender, EventArgs e)
37: {
38: var message = "IPAddress: " + wifi_RS21.Interface.NetworkInterface.IPAddress;
39: Debug.Print("Current network information\r\n" + message);
40: }
41: }
42: }
In the next posts, he will play to show how to upload information from sensors to WebSites of AZURE.
Saludos @ La Finca
El Bruno
Leave a comment