Exemplo n.º 1
0
    void Start()
    {
        DiscoveredPeripherals = new Dictionary <string, string>();
        Input.location.Start();

        if (!Application.isEditor)
        {
            bool initAsCentral    = true;
            bool initAsPeripheral = false;
            BluetoothLEHardwareInterface.Initialize(initAsCentral, initAsPeripheral,
                                                    () =>
            {
                UpdateState(States.Scan);
                BluetoothLEHardwareInterface.BluetoothScanMode(BluetoothLEHardwareInterface.ScanMode.LowLatency);
                BluetoothLEHardwareInterface.BluetoothConnectionPriority(BluetoothLEHardwareInterface.ConnectionPriority.High);
            },
                                                    (error) =>
            {
                Debug.Log(">>>>>>>>>>> [BLE ERROR] " + error);
                CurState = States.Error;
                HandleDisconnected();
            });
        }
        else
        {
            UpdateState(States.Connected);
        }
    }
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        _iBeaconItems = new Dictionary <string, iBeaconItemScript> ();

        BluetoothLEHardwareInterface.Initialize(true, false, () => {
            _timeout = _startScanDelay;

            BluetoothLEHardwareInterface.BluetoothScanMode(BluetoothLEHardwareInterface.ScanMode.LowLatency);
            BluetoothLEHardwareInterface.BluetoothConnectionPriority(BluetoothLEHardwareInterface.ConnectionPriority.High);
        },
                                                (error) => {
            BluetoothLEHardwareInterface.Log("Error: " + error);

            if (error.Contains("Bluetooth LE Not Enabled"))
            {
                BluetoothLEHardwareInterface.BluetoothEnable(true);
            }
        });
    }