Exemplo n.º 1
0
        private async void BtnSend_Click(object sender, RoutedEventArgs e)
        {
            var item = new DeviceCommand()
            {
                Command = TxtCommand.Text, Data = TxtData.Text
            };

            await SendCloudToDeviceMessageAsync(item);
        }
Exemplo n.º 2
0
        private async Task SendCloudToDeviceMessageAsync(DeviceCommand item)
        {
            if (String.IsNullOrEmpty(TxtDevice.Text))
            {
                return;
            }
            var json           = JsonConvert.SerializeObject(item);
            var commandMessage = new Message(Encoding.ASCII.GetBytes(json));

            commandMessage.Ack = DeliveryAcknowledgement.Full;

            await serviceClient.SendAsync(TxtDevice.Text, commandMessage);
        }