Exemplo n.º 1
0
        public MainPage()
        {
            this.InitializeComponent();
#pragma warning disable 4014
            IoTClient.Start(this);
#pragma warning restore 4014
        }
Exemplo n.º 2
0
        private void buttonClicked(object sender, RoutedEventArgs e)
        {
            SensorEvent sEvent = new SensorEvent();

            sEvent.deviceid    = "Heater1";
            sEvent.currenttemp = Int32.Parse(tempval.Text);
            sEvent.gassense    = Int32.Parse(gasval.Text);
            sEvent.flamesense  = Int32.Parse(flameval.Text);
            sEvent.humidity    = Int32.Parse(humidityval.Text);
            sEvent.status      = statustext.Text;
            String jsongString = JsonConvert.SerializeObject(sEvent);

            IoTClient.SendEvent(jsongString);
        }
Exemplo n.º 3
0
        private async void OnProtocolSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            TransportType protocol = GetProtocolIdFromName(this.protocolComboBox.SelectedValue.ToString());

            if (protocol != client.Protocol)
            {
                if (this.client != null)
                {
                    this.client.CloseAsync();
                }
                this.client = new IoTClient(protocol, CallMeLogger, GetDeviceNameLogger, ErrorHandler);
                this.client.Start();
            }
        }
Exemplo n.º 4
0
        public MainPage()
        {
            this.InitializeComponent();

            var defaultProtocol = TransportType.Mqtt;

            this.client = new IoTClient(defaultProtocol, CallMeLogger, GetDeviceNameLogger, ErrorHandler);

            protocolLookup.ForEach(_ =>
            {
                this.protocolComboBox.Items.Add(_.Name);
            });

            this.protocolComboBox.SelectedIndex = protocolLookup.IndexOf(new ProtocolNameToIdLookupEntry {
                Id = defaultProtocol, Name = GetProtocolNameFromId(defaultProtocol)
            });

#pragma warning disable 4014
            client.Start();
#pragma warning restore 4014
        }
Exemplo n.º 5
0
        private async void OnProtocolSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            TransportType protocol = GetProtocolIdFromName(this.protocolComboBox.SelectedValue.ToString());

            if (protocol != client.Protocol)
            {
                if (this.client != null)
                {
                    try
                    {
                        await this.client.CloseAsync();
                    }
                    catch (Exception ex)
                    {
                        var err = string.Format("Error {0} while closing the client", ex.Message);
                        Debug.WriteLine(err);
                    }
                }
                this.client = new IoTClient(protocol, CallMeLogger, GetDeviceNameLogger, ErrorHandler);
                this.client.Start();
            }
        }