Ejemplo n.º 1
0
        private async void mainFrame_Loaded(object sender, RoutedEventArgs e)
        {
            if (App.IsMobile.Equals("IoT"))
            {
                spHome.Visibility     = Visibility.Collapsed;
                spAccount.Visibility  = Visibility.Collapsed;
                spLive.Visibility     = Visibility.Collapsed;
                spSettings.Visibility = Visibility.Collapsed;
                spFeedback.Visibility = Visibility.Collapsed;
                spAlert.Visibility    = Visibility.Collapsed;
            }

            while (true)
            {
                deviceClient = DeviceClient.Create(App.IOTUrl, new DeviceAuthenticationWithRegistrySymmetricKey(App.deviceIDMobile, App.deviceKeyMobile));

                Microsoft.Azure.Devices.Client.Message receivedMessage = await deviceClient.ReceiveAsync();

                if (receivedMessage == null)
                {
                    continue;
                }

                if (App.IsMobile.Equals("IoT"))
                {
                    txtMainMessages.Text = txtMainMessages.Text + "\n" + Encoding.ASCII.GetString(receivedMessage.GetBytes());
                }
                else
                {
                    alertDialog(Encoding.ASCII.GetString(receivedMessage.GetBytes()));
                }

                if (App.IsMobile.Equals("IoT"))
                {
                    await IOTMessages.SendCloudToDeviceMessageAsync("Windows10Desktop", "SPYCameraIOT > Ping received from " + App.deviceIDMobile + " on " + System.DateTime.Now.ToString());
                }

                await deviceClient.CompleteAsync(receivedMessage);
            }
        }
Ejemplo n.º 2
0
 private async void btnPing_Click(object sender, RoutedEventArgs e)
 {
     await IOTMessages.SendCloudToDeviceMessageAsync(((Button)sender).Tag.ToString(), "SPYCameraIOT > Ping test from " + App.deviceIDMobile + " requested on " + System.DateTime.Now.ToString() + ".");
 }