NetDuino PortDriver on HTTP web server:

this project provides code for HTTP webserver and application called port driver.

Port driver helps to read /write GPIO pins using HTTP request ( over the network using HTTP via web server)

ex:  http://<NetDuinoIP>/GPIO?pin=1  // Read PIN 1

      http://<NetDuinoIP>/GPIO?pin=1&value=1  // Write Value 1( Turn On )  to  PIN 1



Code Walk Thru and detailed explanation

 Starting HTTP Server :

 public static void Main()HTTPListener.kickOffThreadHttp(); }

 

//    HTTP Server /Listener Utility Class  

public  class HTTPListener

{

 

   public static void kickOffThreadHttp()

      {  

      Thread t = newThread(HTTPListener.KickOffHttpService);

           t.Start();

      }

 

   public static void KickOffHttpService()

      {

       var config = newEmbeddedWebapplicationConfiguration();

     //config.ReadConfiguration();

         Microsoft.SPOT.Net.NetworkInformation.NetworkInterface[] networkInterfaces= rosoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces();

 

      foreach (var networkInterface in networkInterfaces)

          {

          DebugHelper.Print(" My Device Ip adress: " + networkInterface.IPAddress);

           }

 

      using (var server = newWebserver(config))

           {

                server.RegisterHandler( "/", typeof(Status));

                server.RegisterHandler("Status", typeof(Status));

                server.RegisterHandler("GPIO", typeof(GpioDriver));

                server.StartListening(); 

    // Go to Sleep , Another thread was created to peroform the job

        Thread.Sleep(System.Threading.Timeout.Infinite);

           }

 }

}

 

GpioDriver code :   C:\<Path>\HttpIntfLib\GPIODriver.cs

 

Last edited Jan 8, 2014 at 10:10 PM by nspreddy, version 9