private async Task DoReadMicrophone() { SetStatusActive(true); // the false happens in the bluetooth status handler. ncommand++; try { var valueList = await bleDevice.ReadMicrophone(); if (valueList == null) { SetStatus($"Error: unable to read Microphone"); return; } var record = new MicrophoneRecord(); var Audio = valueList.GetValue("Audio"); if (Audio.CurrentType == BCBasic.BCValue.ValueType.IsDouble || Audio.CurrentType == BCBasic.BCValue.ValueType.IsString) { record.Audio = (string)Audio.AsString; Microphone_Audio.Text = record.Audio.ToString(); // "N0"); // either N or F3 based on DEC HEX FIXED. hex needs conversion to int first? } MicrophoneRecordData.Add(record); } catch (Exception ex) { SetStatus($"Error: exception: {ex.Message}"); } }
private async void BleDevice_MicrophoneEvent(BleEditor.ValueParserResult data) { if (data.Result == BleEditor.ValueParserResult.ResultValues.Ok) { await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { var valueList = data.ValueList; var record = new MicrophoneRecord(); var Audio = valueList.GetValue("Audio"); if (Audio.CurrentType == BCBasic.BCValue.ValueType.IsDouble || Audio.CurrentType == BCBasic.BCValue.ValueType.IsString) { record.Audio = (string)Audio.AsString; Microphone_Audio.Text = record.Audio.ToString(); // "N0"); // either N or F3 based on DEC HEX FIXED. hex needs conversion to int first? } var addResult = MicrophoneRecordData.AddRecord(record); }); } }