예제 #1
0
        public void EnableGattConnection()
        {
            if (GattServiceEnabled)
            {
                Log("GATT Service is already Started");
                return;
            }

            GattServiceEnabled = true;

            Log($"EnableGattConnection({BleID})");

            GattConnectTimer = new Timer()
            {
                Interval  = GATT_RECONNECT_TIMER_INTERVAL,
                Enabled   = false,
                AutoReset = true
            };

            GattQpService = new BleDeviceGattService();
            ConnectQpService();
        }
예제 #2
0
        public void DisableGattConnection()
        {
            GattServiceEnabled = false;

            Log($"DisableGattConnection({BleID})");

            if (GattConnectTimer != null)
            {
                GattConnectTimer.Stop();
                GattConnectTimer.Dispose();
                GattConnectTimer = null;
            }

            if (GattQpService != null)
            {
                GattQpService.Disconnect();
                GattQpService = null;
            }

            ReleaseBleDevice();
            Log($"DisableGattConnection({BleID}, ReleaseBleDevice)");
            // bool result = await ObtainBleDevice();
            // Log($"DisableGattConnection({BleID}, Retry ObtainBleDevice={result})");
        }