void _characteristic_ValueUpdated(object sender, CharacteristicReadEventArgs e)
        {
            _packetCount++;
            //RunOnUiThread(() => _button.Text = e.Characteristic.StringValue);

            if (_packetCount >= 1000 && _sw.IsRunning)
            {
                _sw.Stop();
                Console.WriteLine("Received # {0} notifcations. Total kb:{2}. Time {3}(s). Throughput {1} bytes/s", _packetCount,
                    _packetCount * 20.0f / _sw.Elapsed.TotalSeconds, _packetCount * 20 / 1000, _sw.Elapsed.TotalSeconds);

                RunOnUiThread(() => _button.Text = string.Format("Throughput {0} bytes/s", _packetCount * 20.0f / _sw.Elapsed.TotalSeconds));

                _sw = new Stopwatch();
            }
        }
Esempio 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 ();
		}
Esempio n. 3
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();
        }