[ul]I am always watching: 85 messages from a search on “RN171” GHI forum[/ul]
[ul]https://www.ghielectronics.com/community/forum/topic?id=13516 “RN171 Send response not working?” by D.Helfenstein THANK YOU![/ul]
[ul]https://www.ghielectronics.com/community/forum/topic?id=12286&page=2 “WiFi RN171 - Default settings” by erwin1973@ gmail.com THANK YOU![/ul]
[ul]https://www.ghielectronics.com/docs/178/wifi-rn171-module @ GUS Think of all those people who tried this example! Doomed to fail.[/ul]
[ul]https://www.ghielectronics.com/community/forum/topic?id=13177 “RN171 module not working?” by KG1[/ul]
[ul]http://121.73.22.247/drupal/content/best-wifi-wifly The Best Wifi Wifly? by KG1 All about RN171.[/ul]
using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Presentation.Shapes;
using Microsoft.SPOT.Touch;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
namespace GadgeteerController
{
public partial class Program
{
// This method is run when the mainboard is powered up or reset.
void ProgramStarted()
{
/*******************************************************************************************
Modules added in the Program.gadgeteer designer view are used by typing
their name followed by a period, e.g. button. or camera.
Many modules generate useful events. Type +=<tab><tab> to add a handler to an event, e.g.:
button.ButtonPressed +=<tab><tab>
If you want to do something periodically, use a GT.Timer and handle its Tick event, e.g.:
GT.Timer timer = new GT.Timer(1000); // every second (1000ms)
timer.Tick +=<tab><tab>
timer.Start();
*******************************************************************************************/
// Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
Debug.Print("Program Started");
wifi_RN171.Initialize(GTM.GHIElectronics.WiFi_RN171.SocketProtocol.TCP_Server); //Init as TCP Server
wifi_RN171._Command_Mode_Start();
wifi_RN171._Command_Execute("get ip");
wifi_RN171._Command_Execute("set comm remote 0");
wifi_RN171._Command_Mode_Exit();
wifi_RN171.EnableHttpServer(); //Enable HTTP Parsing
wifi_RN171.HttpRequestReceived += new GTM.GHIElectronics.WiFi_RN171.HttpRequestReceivedHandler(wifi_RN171_HttpRequestReceived);
}
void wifi_RN171_HttpRequestReceived(GTM.GHIElectronics.HttpStream request)
{
string requestedURL = request.Request.URL;
if (requestedURL == "/index.html")
{
//HeaderData["Content-Length"] = document.Length.ToString();
string document = "<html><head></head><body>HELLO! KG1 KG1 KG1 KG1 KG1 KG1 KG1 KG1 KG1</body></html>";
request.Response.HeaderData["Content-type"] = "text/html";
request.Response.HeaderData["Content-Length"] = document.Length.ToString();
request.Response.HeaderData["Connection"] = "close";
request.Response.HeaderData["Cache-Control"] = "no-cache";
request.Response.StatusCode = GTM.GHIElectronics.HttpResponse.ResponseStatus.OK;
//All you have to do is send the document data through the response object.
//Header data is automatically applied for you when you chose to send.
request.Response.Send(System.Text.Encoding.UTF8.GetBytes(document));
}
}
}
}
[ol]Replace the code on https://www.ghielectronics.com/docs/178/wifi-rn171-module with the code above.[/ol]
[ol]Check the IP address at your access point with telnet. See photo[/ol]
[ol]Study the Visual Studio environment. The Gadgeteer source code is unmodified. See photo.[/ol]
[ol]The browser output! Note the full address. See photo.[/ol]
Next find a way to use sockets.
Next RN171 to RN171 communication.
Best regards,
Kevin.