public async Task <bool> SendMessage(UplinkMessage msg) { var stream = new MemoryStream(); msg.WriteDelimitedTo(stream); if (stream.Position > 0) { byte[] buf = stream.ToArray(); GattCommunicationStatus status = await _busRxChar.WriteValueAsync(stream.ToArray().AsBuffer()); return((status == GattCommunicationStatus.Success) ? true : false); } else { throw new ArgumentException("Invalid UplinkMessage"); } }
public Task <bool> SendMessage(UplinkMessage msg) { var stream = new MemoryStream(); msg.WriteDelimitedTo(stream); if (stream.Position > 0) { byte[] buf = stream.ToArray(); return(Task.Factory.StartNew(() => { NativeSdkWrapper.StatusCode status = NativeSdkWrapper.Write(Address, buf, (ushort)buf.Length); return (status == NativeSdkWrapper.StatusCode.Success); })); } else { throw new ArgumentException("Invalid UplinkMessage"); } }