/// <summary> /// Callback function that MdsLib calls when an exception is thrown during device connection /// </summary> /// <param name="e"></param> public void OnError(Com.Movesense.Mds.MdsException e) { // Unexpected device disconnections come in here if (e.Message.StartsWith("com.polidea.rxandroidble.exceptions.BleDisconnectedException")) { var msgParts = e.Message.Split(" "); string MACaddress = msgParts[msgParts.Length - 1]; var uuid = GetUuidFromMACAddress(MACaddress); Debug.WriteLine($"DISCONNECT MdsConnectionListener OnError callback called for unintended disconnection: MACaddress {MACaddress}"); var serial = string.Empty; this.UuidToSerialMapper.TryGetValue(uuid, out serial); DeviceDisconnected?.Invoke(this, new MdsConnectionListenerEventArgs(serial, uuid)); } else { // Other unexpected error Debug.WriteLine($"ERROR MdsConnectionListener OnError callback called for unexpected error: {e.ToString()}"); DeviceConnectionError?.Invoke(this, new MdsException("MdsConnectionListener unexpected error", e)); } }
/// <summary> /// Creates an MdsException wrapping a Com.Movesense.Mds.MdsException thrown by the native Android MdsLib /// /// </summary> /// <param name="message">message string</param> /// <param name="e">the exception to wrap</param> public MdsException(string message, Com.Movesense.Mds.MdsException e) : base(message, e) { }
/// <summary> /// Error callback called by Mds when an error is encoubntered reading subscription data /// </summary> /// <param name="e"></param> public void OnError(Com.Movesense.Mds.MdsException e) { Debug.WriteLine($"ERROR error = {e.ToString()}"); mTcs.SetException(new MdsException(e.ToString(), e)); }
/// <summary> /// Callback function that MdsLib calls when an exception is thrown during device connection /// </summary> /// <param name="e"></param> public void OnError(Com.Movesense.Mds.MdsException e) { throw new MdsException(e.ToString(), e); }