private async void Instance_ValueChangeCompleted(UARTElement UARTElementValue)
 {
     // Serialize UI update to the the main UI thread.
     await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         statusTextBlock.Text = "Received: " +
                                UARTElementValue.ToString();
         outputListBox.Items.Insert(0, UARTElementValue);
     });
 }
Beispiel #2
0
        /// <summary>
        /// Invoked when Windows receives data from your Bluetooth device.
        /// </summary>
        /// <param name="sender">The GattCharacteristic object whose value is received.</param>
        /// <param name="args">The new characteristic value sent by the device.</param>
        private void Characteristic_ValueChanged(GattCharacteristic sender, GattValueChangedEventArgs args)
        {
            var data = new byte[args.CharacteristicValue.Length];

            DataReader.FromBuffer(args.CharacteristicValue).ReadBytes(data);

            // Process the raw data received from the device.
            var astring = UART_Data_Converter.RX(data);

            var value = new UARTElement
            {
                sent_text = astring
            };

            lock (datapoints)
            {
                datapoints.Add(value);
            }

            if (ValueChangeCompleted != null)
            {
                ValueChangeCompleted(value);
            }
        }