public HttpResponseMessage GetActionRelay(string number, string value)
        {
            Console.WriteLine($"received number:'{value}' -> value: {value}");
            if ((number != "0" && number != "1") || (value != "0" && value != "1"))
            {
                Console.WriteLine($"Error received values =>  number:{value}, value: {value}");
                return(new HttpResponseMessage(HttpStatusCode.ExpectationFailed));
            }

            IoTFactory.Get <IoTRelay> ()
            .EnablePin(int.Parse(number), value == "1");
            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            var port     = "8085";
            var actualIp = GetLocalIPAddress();
            var config   = new HttpSelfHostConfiguration($"http://{actualIp}:{port}");

            config.MapHttpAttributeRoutes();

            IoTFactory.CreateBlind(false, Connectors.GPIO27, Connectors.GPIO17);

            using (HttpSelfHostServer server = new HttpSelfHostServer(config))
            {
                Thread.Sleep(delayTime);
                server.OpenAsync().Wait();
                Console.WriteLine($"Started host server: {actualIp}:{port}");
                while (true)
                {
                    Thread.Sleep(delayTime);
                }
            }
        }
        public HttpResponseMessage GetActionBlind(string up)
        {
            Console.WriteLine($"Received: '{up}'");
            var blindInstance = IoTFactory.Get <IoTBlind> ();

            switch (up)
            {
            case "0":
                blindInstance.Stop();
                return(new HttpResponseMessage(HttpStatusCode.OK));

            case "1":
                blindInstance.Up();
                return(new HttpResponseMessage(HttpStatusCode.OK));

            case "2":
                blindInstance.Down();
                return(new HttpResponseMessage(HttpStatusCode.OK));

            default:
                return(new HttpResponseMessage(HttpStatusCode.ExpectationFailed));
            }
        }