コード例 #1
0
ファイル: LEStream.cs プロジェクト: Ehryk/RocketLauncher
		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 ();
		}
コード例 #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();
        }