Exemplo n.º 1
0
		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 ();
		}
Exemplo n.º 2
0
        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();
        }