Esempio n. 1
0
        public static void Main()
        {
            // Creates a new web session
            HTTP_Client WebSession = new HTTP_Client(new IntegratedSocket("www.netmftoolbox.com", 80));

            // Requests the latest source
            HTTP_Client.HTTP_Response Response = WebSession.Get("/helloworld/");

            // Did we get the expected response? (a "200 OK")
            if (Response.ResponseCode != 200)
            {
                throw new ApplicationException("Unexpected HTTP response code: " + Response.ResponseCode.ToString());
            }

            // Fetches a response header
            Debug.Print("Current date according to www.netmftoolbox.com: " + Response.ResponseHeader("date"));

            // Gets the response as a string
            Debug.Print(Response.ToString());

            Trace.Print("Current date according to www.netmftoolbox.com: " + Response.ResponseHeader("date"));
            Trace.Print(Response.ToString());

            Thread.Sleep(Timeout.Infinite);
        }
Esempio n. 2
0
 private string NapkinGet(string path)
 {
     try
     {
         WiFlySocket socket = new WiFlySocket(NapkinServerName, NapkinServerPort, _wifly);
         HTTP_Client client = new HTTP_Client(socket);
         client.Authenticate(DeviceId, DeviceId);
         HTTP_Client.HTTP_Response response = client.Get(path);
         return(response.ResponseBody);
     }
     catch (Exception ex)
     {
         Debug.Print("Exception in PingServer: " + ex.Message);
         return(null);
     }
 }
        public static void Main()
        {
            try
            {
                // Creates a new web session
                HTTP_Client WebSession = new HTTP_Client(new IntegratedSocket("127.0.0.1", 80));
                int         index      = 1;
                while (true)
                {
                    // Requests the latest source
                    HTTP_Client.HTTP_Response Response = WebSession.Post(string.Concat("/restfulsignalrservice/messagebroadcast/broadcast?message=Hello_From_Netdunio.Index", index.ToString()));

                    // Did we get the expected response ? (a "200 OK")
                    if (Response.ResponseCode != 200)
                    {
                        AnimateLed(100);
                        Debug.Print(string.Concat("Unexpected HTTP response code : ", Response.ResponseCode.ToString()));
                        Debug.Print(Response.ToString());
                    }
                    else
                    {
                        AnimateLed(250);
                        Debug.Print("Successful response ");
                        Debug.Print(Response.ToString());
                    }
                    if (index == Int32.MaxValue)
                    {
                        index = 1;
                    }
                    else
                    {
                        index++;
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message);
            }
        }
Esempio n. 4
0
        public static void Main()
        {
            // There's a 8x8 matrix (64 LEDs) connected to the first SPI bus on the Netduino
            RgbMatrix matrix = new AdafruitNeoPixel32x8();

            matrix.Test0();

            NetworkInitializer.NetworkConnected += NetworkConnected;

            int delayCon = 0;

            IsConnecting = true;

            OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);

            while (IsConnecting)
            {
                led.Write(false);  // turn on the LED
                Thread.Sleep(250); // sleep for 250ms
                led.Write(true);   // turn off the LED
                Thread.Sleep(250); // sleep for 250ms

                if (delayCon++ == 10)
                {
                    NetworkInitializer.InitializeNetwork();
                }
            }

            Debug.Print("Network connected!");

            // Creates a new web session
            HTTP_Client WebSession = new HTTP_Client(new IntegratedSocket("www.netmftoolbox.com", 80));

            // Requests the latest source
            HTTP_Client.HTTP_Response Response = WebSession.Get("/helloworld/");

            // Did we get the expected response? (a "200 OK")
            if (Response.ResponseCode != 200)
            {
                throw new ApplicationException("Unexpected HTTP response code: " + Response.ResponseCode.ToString());
            }

            var dateString = Response.ResponseHeader("date");

            //Pin1Irq = new IntegratedIRQ(Pins.GPIO_PIN_D1);
            //Pin1Irq.ID = "D1";
            //Pin1Irq.OnStateChange += OnStateChangeHandler;
            //Pin2Irq = new IntegratedIRQ(Pins.GPIO_PIN_D2);
            //Pin2Irq.ID = "D2";
            //Pin2Irq.OnStateChange += OnStateChangeHandler;

            var ethernetPower = new OutputPort((Cpu.Pin) 47, false);

            ethernetPower.Write(false);

            while (true)
            {
                matrix.ScrollToLeftText(1, 0, dateString, 0x130000, 100);
                Thread.Sleep(500);
            }
        }