void OnAirGesturesDataValueChanged(GattCharacteristic sender, GattValueChangedEventArgs args)
        {
            byte[]     value  = new byte[args.CharacteristicValue.Length];
            DataReader reader = DataReader.FromBuffer(args.CharacteristicValue);

            reader.ReadBytes(value);
            if (value.Length > 0)
            {
                byte first = value[0];
                if (first != 20)
                {
                    // Air Gestured
                    TAPAirGesture airGesture = TAPAirGestureHelper.intToAirGesture(first);
                    if (this.OnAirGestured != null && airGesture != TAPAirGesture.Undefined)
                    {
                        this.OnAirGestured(this.Identifier, airGesture);
                    }
                }
                else if (value.Length > 1)
                {
                    // State
                    this.isInAirGestureState = value[1] == 1;
                    if (this.OnTapChangedAirGesturesState != null)
                    {
                        this.OnTapChangedAirGesturesState(this.Identifier, value[1] == 1);
                    }
                }
            }
        }
 void OnTapDataValueChanged(GattCharacteristic sender, GattValueChangedEventArgs args)
 {
     if (this.isInAirGestureState)
     {
         if (this.OnAirGestured != null)
         {
             byte[]     value  = new byte[args.CharacteristicValue.Length];
             DataReader reader = DataReader.FromBuffer(args.CharacteristicValue);
             reader.ReadBytes(value);
             TAPAirGesture airGesture = TAPAirGestureHelper.tapToAirGesture(value[0]);
             if (airGesture != TAPAirGesture.Undefined)
             {
                 this.OnAirGestured(this.Identifier, airGesture);
             }
         }
     }
     else
     {
         if (this.OnTapped != null)
         {
             byte[]     value  = new byte[args.CharacteristicValue.Length];
             DataReader reader = DataReader.FromBuffer(args.CharacteristicValue);
             reader.ReadBytes(value);
             Debug.WriteLine("TAPPED " + value[0]);
             this.OnTapped(this.Identifier, value[0]);
         }
     }
 }
Beispiel #3
0
 private void OnTapAirGestured(string identifier, TAPAirGesture airGesture)
 {
     if (!this.activated)
     {
         return;
     }
     if (this.OnAirGestured != null)
     {
         this.OnAirGestured(identifier, airGesture);
     }
 }
Beispiel #4
0
        // private void button1_Click(object sender, EventArgs e)
        // {
        //    TAPManager.Instance.Vibrate(new int[] { 100, 300, 100 });
        //}

        private void OnAirGestured(string identifier, TAPAirGesture airGesture)
        {
            Console.WriteLine("AirGestured " + identifier + ", code: " + (int)airGesture);
        }
 private void OnAirGestured(string identifier, TAPAirGesture airGesture)
 {
     Console.WriteLine("AirGestured " + identifier + ", code: " + (int)airGesture);
     PortWrite(((int)airGesture).ToString() + "\n");
 }