O'Reilly logo

Getting Started with the Internet of Things by Cuno Pfister

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

LedController

The structure of LedController (Example 12-1) is very similar to that of Example 11-1.

Example 12-1. LedController

using Gsiot.Server;
using SecretLabs.NETMF.Hardware.NetduinoPlus;

public class LedController
{
    public static void Main()
    {
        var ledActuator = new DigitalActuator
        {
            OutputPin = Pins.ONBOARD_LED
        };

        var webServer = new HttpServer
        {
            RelayDomain = "gsiot-FFMQ-TTD5",
            RelaySecretKey =
                "o5fIIZS5tpD2A4Zp87CoKNUsSpIEJZrV5rNjpg89",
            RequestRouting =
            {
                {
                    "PUT /led/target",
                    new ManipulatedVariable
                    {
                        FromHttpRequest =
                            CSharpRepresentation.TryDeserializeBool,
                        ToActuator = ledActuator.HandlePut
                    }.HandleRequest
                }
            }
        };

        webServer.Run();
    }
}

The main differences between the two examples are that Example 12-1 uses an instance of DigitalActuator ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required