void OnPeripheralDisconnected(object sender, EventArgs e)
        {
            EventHandler <BLEPeripheralErrorEventArgs> handler = DisconnectedFromPeripheral;

            if (handler != null)
            {
                BLEPeripheralErrorEventArgs args = new BLEPeripheralErrorEventArgs();
                args.Peripheral = sender as BLEPeripheral;

                handler(this, args);
            }
        }
示例#2
0
        void OnDisconnectedPeripheral(object sender, CBPeripheralErrorEventArgs e)
        {
            BLEPeripheral peripheral = null;

            foreach (BLEPeripheral blep in discoveredPeripherals)
            {
                if (blep.UUID.StringValue == e.Peripheral.ToString())
                {
                    peripheral = blep;

                    break;
                }
            }

            EventHandler <BLEPeripheralErrorEventArgs> handler = DisconnectedFromPeripheral;

            if (handler != null)
            {
                BLEPeripheralErrorEventArgs args = new BLEPeripheralErrorEventArgs();
                args.Peripheral = peripheral;
                args.Error      = e.Error?.ToString();
            }
        }