Ejemplo n.º 1
0
        static void Main()
        {
            led = GpioController.GetDefault().OpenPin(FEZ.GpioPin.Led1);
            led.SetDriveMode(GpioPinDriveMode.Output);

            string host = "ghi-test-iot.azure-devices.net"; //"192.168.1.152" "ghi-test-iot.azure-devices.net" "a1uyw4e5ps7wof.iot.us-east-2.amazonaws.com"
            int    port = 8883;                             // 1883 8883

            var serial = SerialDevice.FromId(FEZ.UartPort.Usart1);

            serial.BaudRate    = 115200;
            serial.ReadTimeout = TimeSpan.Zero;

            wifi = new AMW007Interface(serial);

            mqtt = new MQTT();
            wifi.Run();

            //wifi.SetTlsServerRootCertificate("azure.pem"); //aws.pem

            mqtt.Connect(wifi, host, port, clientID, 60, true);
            mqtt.Publish("devices/FEZ/messages/events/", "HELLO!");       //devices/FEZ/messages/events/    $aws/things/FEZ/shadow/update

            mqtt.Subscribe("devices/FEZ/messages/devicebound/#", "test"); // devices/FEZ/messages/devicebound/# $aws/things/FEZ/shadow/update

            Thread reader = new Thread(ReadStream);

            reader.Start();

            while (true)
            {
                wifi.ReadSocket(0, 500);
                Thread.Sleep(200);
            }
        }