void HandleReceiveValueUpdated (object sender, CharacteristicReadEventArgs e) { var bytes = e.Characteristic.Value; if (bytes == null || bytes.Length == 0) return; // Debug.WriteLine ("Receive.Value: " + string.Join (" ", bytes.Select (x => x.ToString ("X2")))); lock (readBuffer) { if (readBuffer.Count + bytes.Length > ReadBufferSize) { readBuffer.RemoveRange (0, ReadBufferSize / 2); } readBuffer.AddRange (bytes); } reset.Write (new byte[] { 1 }); dataReceived.Set (); }
void HandleReceiveValueUpdated(object sender, CharacteristicReadEventArgs e) { var bytes = e.Characteristic.Value; if (bytes == null || bytes.Length == 0) { return; } // Debug.WriteLine ("Receive.Value: " + string.Join (" ", bytes.Select (x => x.ToString ("X2")))); lock (readBuffer) { if (readBuffer.Count + bytes.Length > ReadBufferSize) { readBuffer.RemoveRange(0, ReadBufferSize / 2); } readBuffer.AddRange(bytes); } reset.Write(new byte[] { 1 }); dataReceived.Set(); }