//device Id information is processed when the message is received //this will request the device Id and return true it was set successfully public override async Task <bool> SetDeviceInfo(int timeoutInMs = 5000) { var timeOutTask = Task.Delay(timeoutInMs); bool isDeviceIdSet = false; EventHandler <MeadowMessageEventArgs> handler = null; var tcs = new TaskCompletionSource <bool>(); handler = (s, e) => { if (e.MessageType == MeadowMessageType.DeviceInfo) { isDeviceIdSet = true; tcs.SetResult(true); } }; dataProcessor.OnReceiveData += handler; MeadowDeviceManager.GetDeviceInfo(this); await Task.WhenAny(new Task[] { timeOutTask, tcs.Task }); dataProcessor.OnReceiveData -= handler; return(isDeviceIdSet); }
//device Id information is processed when the message is received //this will request the device Id and return true it was set successfully public override async Task GetDeviceInfo(int timeoutInMs = 1000) { var result = await MeadowDeviceManager.GetDeviceInfo(this, timeoutInMs); if (!result.isSuccessful) { throw new DeviceInfoException(); } }