Example #1
0
 void ClearLog_WebEventReceived(string path, WebServer.HttpMethod method, Responder responder)
 {
     if (VerifySDCard())
     {
         lock (LockObject)
         {
             using (StreamWriter sw = new StreamWriter(rootDir + fileName))
             {
                 sw.WriteLine(string.Empty);
             }
         }
     }
     responder.Respond("Log cleared.");
 }
Example #2
0
        void seePicture_WebEventReceived(string path, WebServer.HttpMethod method, Responder responder)
        {
            if (pic != null)
            {
                Bitmap b = new Bitmap(320, 240);
                b.DrawLine(Colors.Red, 20, 0, 0, 319, 239);
                byte[] buff = new byte[320 * 240 * 3 + 54];
                GHIElectronics.NETMF.System.Util.BitmapToBMPFile(b.GetBitmap(), 320, 240, buff);

                GT.Picture picture = new GT.Picture(buff, GT.Picture.PictureEncoding.BMP);

                responder.Respond(picture);
            }
            else
                responder.Respond("Take picture first");
        }
Example #3
0
 void GetReading_WebEventReceived(string path, WebServer.HttpMethod method, Responder responder)
 {
     responder.Respond(GetNewReadings());
 }
Example #4
0
        void toggleCapture_WebEventReceived(string path, WebServer.HttpMethod method, Responder responder)
        {
            captureOn = !(captureOn);

            string content = "<html><body><h1>" + getCaptureMode() + "</h1></body></html>";
            byte[] bytes = new System.Text.UTF8Encoding().GetBytes(content);
            responder.Respond(bytes, "text/html");

            if (captureOn) multicolorLed.BlinkRepeatedly(GT.Color.Red);
            else           multicolorLed.BlinkRepeatedly(GT.Color.Green);
        }
Example #5
0
 void getVersion_WebEventReceived(string path, WebServer.HttpMethod method, Responder responder)
 {
     string content = "<html><body><h1>Version 1.0!</h1>"+getCaptureMode() + "</body></html>";
     byte[] bytes = new System.Text.UTF8Encoding().GetBytes(content);
     responder.Respond(bytes, "text/html");
 }
Example #6
0
        /// <summary>
        /// Raises the <see cref="WebEventReceived"/> event.
        /// </summary>
        /// <param name="responder">Contains request data sent by the the client and functionality to respond to the request.</param>
        /// <param name="method">The incoming http method. </param>
        /// <param name="path">The path of the requested resource.</param>
        internal virtual void OnWebEventReceived(string path, WebServer.HttpMethod method, Responder responder)
        {
            if (onWebEventReceived == null) onWebEventReceived = new ReceivedWebEventHandler(OnWebEventReceived);

            if (_WebEventReceived == null || noHandlerSet)
            {
                responder.SendResponse();
            }
            else if (Program.CheckAndInvoke(_WebEventReceived, onWebEventReceived, path, method, responder))
            {
                _WebEventReceived(path, method, responder);
            }
        }
Example #7
0
 void empty_WebEventReceived(string path, WebServer.HttpMethod method, Responder responder)
 {
     responder.Respond("This is a RoboHome module and should be accessed using the API");
 }
Example #8
0
 void hello_WebEventReceived(string path, WebServer.HttpMethod method, Responder responder)
 {
     Debug.Print("Hello world");
     responder.Respond("Hello world");
 }
Example #9
0
 void sayHello_WebEventReceived(string path, WebServer.HttpMethod method, Responder responder)
 {
     string content = "<html><body><h1>Hello World!!</h1></body></html>";
     byte[] bytes = new System.Text.UTF8Encoding().GetBytes(content);
     responder.Respond(bytes, "text/html");
 }
Example #10
0
 void authenticatesystem_WebEventReceived(string path, WebServer.HttpMethod method, Responder responder)
 {
     string content = "<html><body><h1>connectionsuccessfulrunprogram</h1></body></html>";
     byte[] bytes = new System.Text.UTF8Encoding().GetBytes(content);
     responder.Respond(bytes, "text/html");
 }
Example #11
0
 void webEventtemperature_WebEventReceived(string path, WebServer.HttpMethod method, Responder responder)
 {
     string content = "<html><body><h1>" + temperature + "</h1></body></html>";
     byte[] bytes = new System.Text.UTF8Encoding().GetBytes(content);
     responder.Respond(bytes, "text/html");
 }
Example #12
0
        void view_WebEventReceived(string path, WebServer.HttpMethod method, Responder responder)
        {
            led.TurnWhite();
            Thread.Sleep(2000);
            led.TurnOff();

            Debug.Print("View page requested");
            TimeSpan time = GetMachineTime;
            new DateTime(time.Ticks).ToString("HH:mm:ss");
               string content = "<html><title>Web Access</title><center><h1>Room Climate Monitor Web Access</center></h1><body></br></br></br>This is the web page for the Room Climate Control Monitor on IP" + systemip  + ".</br></br>Currently the following values are detected: </br></br>Temperature: " + temperature.ToString() + "'c</br></br>Humidity: " + relativeHumidity + "</br></br>Percentage Light(Higher is Lighter): "+ lightpercentage + "%</br></br>Values change every few seconds but require the page to be refreshed for them to be updated.</br></br>Time: " + DateTime.Now + " </br></br></br>IP: " + systemip + "</br>Subnet Mask: " + ethernet.Interface.NetworkInterface.SubnetMask + "</br>Gateway: " + ethernet.Interface.NetworkInterface.GatewayAddress + "</br></br></br></br><center>Hosted on the .Net Gadgeteer Platform</center></body></html>" ;
            byte[] bytes = new System.Text.UTF8Encoding().GetBytes(content);
            responder.Respond(bytes, "text/html");
        }
Example #13
0
 void takePicture_WebEventReceived(string path, WebServer.HttpMethod method, Responder responder)
 {
     responder.Respond("Taking picture");
     camera.TakePicture();
 }
Example #14
0
 void GetLog_WebEventReceived(string path, WebServer.HttpMethod method, Responder responder)
 {
     if (VerifySDCard())
     {
         using (StreamReader sr = new StreamReader(rootDir + fileName))
         {
             string text = sr.ReadToEnd();
             responder.Respond(text);
         }
     }
     else
         responder.Respond("No SD card detected.");
 }
Example #15
0
 void state_WebEventReceived(string path, WebServer.HttpMethod method, Responder responder)
 {
     responder.Respond(sensorState);
 }
Example #16
0
 /// <summary>
 /// The response event for http://192.168.1.22:80/bio,
 /// Serialisese the bpm from the latest reading to a string, converts it to a byte array and passes it to the responder
 /// </summary>
 /// <param name="path">http://192.168.1.22:80/bio</param>
 /// <param name="method">Enum that represents the supported http methods, i.e. post, get, delete, put</param>
 /// <param name="responder">An object which responds to the request</param>
 void SendBioFeedback_WebEventReceived(string path, WebServer.HttpMethod method, Responder responder)
 {
     string content = CurrentReading.SerialiseBpm();
     byte[] bytes = new System.Text.UTF8Encoding().GetBytes(content);
     responder.Respond(bytes, "text/html");
 }
Example #17
0
        void sketch_WebEventReceived(string path, WebServer.HttpMethod method, Responder responder)
        {
            Bitmap bitmap = background.Bitmap;
            byte[] buff = new byte[bitmap.Width * bitmap.Height * 3 + 54];
            Util.BitmapToBMPFile(bitmap.GetBitmap(), bitmap.Width, bitmap.Height, buff);

            GT.Picture picture = new GT.Picture(buff, GT.Picture.PictureEncoding.BMP);
            responder.Respond(picture);
        }