Ejemplo 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 ();
		}
Ejemplo n.º 2
0
		public void NotifyStateUpdateDone(object sender, CharacteristicReadEventArgs e)
		{
			Debug.WriteLine("SyncHandlerDevice961: Notification State Updated: " + e.Characteristic.ID);
			switch (Command)
			{
				case Constants.SyncHandlerSequence.EnableFF07:
					Debug.WriteLine("Done enabling FF07");
					break;
				case Constants.SyncHandlerSequence.EnableFF08:
					Debug.WriteLine("Done enabling FF08");
					this.Adapter.CommandResponse += ReceiveResponse;
					break;
				default:
					Debug.WriteLine("Unknown response!");
					break;

			}
			this.ProcessCommands();
		}
Ejemplo n.º 3
0
        public void GetValueFromChar(object sender, CharacteristicReadEventArgs e)
        {
            switch (command)
            {
                case Constants.SyncHandlerSequence.ReadModel:
                    Debug.WriteLine("Model: " + System.Text.Encoding.UTF8.GetString(e.Characteristic.Value, 0, e.Characteristic.Value.Length));
                    break;
                case Constants.SyncHandlerSequence.ReadSerial:
                    Debug.WriteLine("Serial: " + System.Text.Encoding.UTF8.GetString(e.Characteristic.Value, 0, e.Characteristic.Value.Length));
                    break;
                case Constants.SyncHandlerSequence.ReadFwVersion:
                    Debug.WriteLine("Fw Version: " + System.Text.Encoding.UTF8.GetString(e.Characteristic.Value, 0, e.Characteristic.Value.Length));
                    break;
                case Constants.SyncHandlerSequence.ReadManufacturer:
                    Debug.WriteLine("Manufacturer: " + System.Text.Encoding.UTF8.GetString(e.Characteristic.Value, 0, e.Characteristic.Value.Length));
                    break;
                case Constants.SyncHandlerSequence.ReadBatteryLevel:
                    Debug.WriteLine("Battery: " + (int) e.Characteristic.Value[0]);
                    break;
                default:
                    Debug.WriteLine("SyncDeviceHandler961: Unable to identify command.");
                    break;
            }

            this.ProcessCommands();
        }
Ejemplo n.º 4
0
		void Handle_ValueUpdated (object sender, CharacteristicReadEventArgs e)
		{
			CommandResponse (this, new CommandResponseEventArgs () { Data = e.Characteristic.Value });
		}
Ejemplo n.º 5
0
		void Handle_ValueUpdated (object sender, CharacteristicReadEventArgs e)
		{
			Debug.WriteLine("Adapter: Receiving command response...");
			CommandResponse (this, new CommandResponseEventArgs () { Data = e.Characteristic.Value });
		}
Ejemplo n.º 6
0
 public void GetValueFromChar(object sender, CharacteristicReadEventArgs e)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 7
0
		void UpdatedNotificationState(object sender, CharacteristicReadEventArgs e)
		{
			Console.WriteLine("Notification state event " + e.Characteristic.ID);
		}