Ejemplo n.º 1
0
    public static void Main()
    {
        var thdLed = new Thread(HandleLed);
        thdLed.Start();

        var digitalSensor = new DigitalSensor { InputPin = Pins.GPIO_PIN_D12 };
        var analogSensor = new AnalogSensor { InputPin = Pins.GPIO_PIN_A1, MinValue = 0.0, MaxValue = 3.3 };
        var lowPort = new OutputPort(Pins.GPIO_PIN_A0, false);
        var highPort = new OutputPort(Pins.GPIO_PIN_A2, true);

        var ledActuator = new DigitalActuator { OutputPin = Pins.GPIO_PIN_D13 };
        //need to create HTTP PUTs!

        var webServer = new HttpServer
        {
            RelayDomain = "gsiot-bcjp-yj88",
            RelaySecretKey = "HDMvyM11hAu6H6cxIaT50dL9ALWc81MYB8H/UFhV",
            RequestRouting =
            {
                { "GET /hello*", HandleHello }, //This accepts a lot of URLs
                { "GET /on", HandleOn },
                { "GET /off", HandleOff },
                { "POST /on", HandlePostOn },
                { "POST /off", HandlePostOff },
                { "GET /d12", new MeasuredVariable{ FromSensor=digitalSensor.HandleGet}.HandleRequest},
                { "GET /a1", new MeasuredVariable{ FromSensor=analogSensor.HandleGet}.HandleRequest},
                { "PUT /d13", new ManipulatedVariable{ FromHttpRequest=CSharpRepresentation.TryDeserializeBool,ToActuator=ledActuator.HandlePut}.HandleRequest},
            }
        };
        webServer.Run();
    }
Ejemplo n.º 2
0
    static void Main()
    {
        var ledActuator = new DigitalActuator
        {
            OutputPin = Parameters.LedPin
        };

        var webServer = new HttpServer
        {
            // RelayDomain = Parameters.RelayDomain,
            // RelaySecretKey = Parameters.RelaySecretKey,
            RequestRouting =
            {
                {
                    "PUT /led/target",
                    new ManipulatedVariable
                    {
                        FromHttpRequest =
                            CSharpRepresentation.TryDeserializeBool,
                        ToActuator = ledActuator.HandlePut
                    }.HandleRequest
                },
                {
                    "GET /led/target.html",
                    HandleLedTargetHtml
                }
            }
        };

        webServer.Run();
    }
Ejemplo n.º 3
0
    static void Main()
    {
        var lowPort = new OutputPort(Parameters.LowPin, false);
        var highPort = new OutputPort(Parameters.HighPin, true);

        var voltageSensor = new AnalogSensor
        {
            InputPin = Parameters.AnalogPin,
            MinValue = 0.0,
            MaxValue = 3.3
        };

        var webServer = new HttpServer
        {
            RelayDomain = Parameters.RelayDomain,
            RelaySecretKey = Parameters.RelaySecretKey,
            RequestRouting =
            {
                {
                    "GET /voltage/actual",
                    new MeasuredVariable
                    {
                        FromSensor = voltageSensor.HandleGet
                    }.HandleRequest
                }
            }
        };

        webServer.Run();
    }
Ejemplo n.º 4
0
 public static void Main()
 {
     var webServer = new HttpServer
     {
         //RelayDomain = "<insert your relay domain here>",
         //RelaySecretKey = "<insert your secret key here>",
         RequestRouting =
         {
             { "GET /hello.html", HandleGetHelloHtml }
         }
     };
     webServer.Run();
 }
Ejemplo n.º 5
0
 static void Main()
 {
     // PowerShell PS> Invoke-WebRequest -Uri "http://try.yaler.net/gsiot-8a3m-5w8t/hello.html" -Method Get
     // or
     var webServer = new HttpServer
     {
         // RelayDomain = Parameters.RelayDomain,
         // RelaySecretKey = Parameters.RelaySecretKey,
         RequestRouting =
         {
             { "GET /hello.html", HandleGetHelloHtml },
             { "GET /about.html", HandleGetAboutHtml }
         }
     };
     webServer.Run();
 }
Ejemplo n.º 6
0
        public static void Main()
        {
            var t = new Thread(blink);
            t.Start();

            var webServer = new HttpServer();
            webServer.RelayDomain = "gsiot-bcjp-yj88";
            webServer.RelaySecretKey = "HDMvyM11hAu6H6cxIaT50dL9ALWc81MYB8H/UFhV";
            webServer.RequestRouting.Add("GET /hello", HandleHello);
            webServer.RequestRouting.Add("GET /temp", HandleTemp);
            webServer.RequestRouting.Add("GET /on", HandleOn);
            webServer.RequestRouting.Add("GET /off", HandleOff);
            // allow on off to send via POST (xively) ...
            webServer.RequestRouting.Add("POST /on", HandlePostOn);
            webServer.RequestRouting.Add("POST /off", HandlePostOff);

            webServer.RequestRouting.Add("GET /toggle", HandleToggle);
            webServer.Run();
        }
Ejemplo n.º 7
0
    static void Main()
    {
        var webServer = new HttpServer
        {
            RelayDomain = Parameters.RelayDomain,
            RelaySecretKey = Parameters.RelaySecretKey,

            RequestRouting =
            {
                { "GET /hello", context =>
                      { context.SetResponse("Hello Web", "text/plain"); }
                },

                { "GET /about", context =>
                      { context.SetResponse("Netduino Plus 2 running .net micro framework", "text/plain"); }
                }

            }
        };
        webServer.Run();
    }
Ejemplo n.º 8
0
    static void Main()
    {
        var buffer = new Buffer { };

        var blinker = new Blinker { SourceBuffer = buffer };

        // PowerShell PS> Invoke-WebRequest -Uri "http://try.yaler.net/gsiot-8a3m-5w8t/blinkingPeriod/target" -Method Put -Body 100 -TimeoutSec 2
        var webServer = new HttpServer
        {
            RelayDomain = Parameters.RelayDomain,
            RelaySecretKey = Parameters.RelaySecretKey,
            RequestRouting =
            {
                {
                    "PUT /blinkingPeriod/target",
                    new ManipulatedVariable
                    {
                        FromHttpRequest =
                            CSharpRepresentation.TryDeserializeInt,
                        ToActuator = buffer.HandlePut
                    }.HandleRequest
                },
                {
                    "GET /blinkingPeriod/target.html",
                    HandleBlinkTargetHtml
                }
            }
        };

        var blinkerThread = new Thread(blinker.Run);
        blinkerThread.Start();
        webServer.Run();
    }