private void Start() { setBeaconPropertiesAtStart(); // please keep here! _bluetoothButton.onClick.AddListener(delegate() { BluetoothState.EnableBluetooth(); }); _bluetoothText = _bluetoothButton.GetComponentInChildren <Text>(); BluetoothState.BluetoothStateChangedEvent += delegate(BluetoothLowEnergyState state) { switch (state) { case BluetoothLowEnergyState.TURNING_OFF: case BluetoothLowEnergyState.TURNING_ON: break; case BluetoothLowEnergyState.UNKNOWN: case BluetoothLowEnergyState.RESETTING: SwitchToStatus(); _statusText.text = "Checking Device…"; break; case BluetoothLowEnergyState.UNAUTHORIZED: SwitchToStatus(); _statusText.text = "You don't have the permission to use beacons."; break; case BluetoothLowEnergyState.UNSUPPORTED: SwitchToStatus(); _statusText.text = "Your device doesn't support beacons."; break; case BluetoothLowEnergyState.POWERED_OFF: SwitchToMenu(); _bluetoothButton.interactable = true; _bluetoothText.text = "Enable Bluetooth"; break; case BluetoothLowEnergyState.POWERED_ON: SwitchToMenu(); _bluetoothButton.interactable = false; _bluetoothText.text = "Bluetooth already enabled"; break; case BluetoothLowEnergyState.IBEACON_ONLY: SwitchToMenu(); _bluetoothButton.interactable = false; _bluetoothText.text = "iBeacon only"; break; default: SwitchToStatus(); _statusText.text = "Unknown Error"; break; } }; f_ScrollViewContentRectWidth = ((RectTransform)go_FoundBeacon.transform).rect.width; f_ScrollViewContentRectHeight = ((RectTransform)go_FoundBeacon.transform).rect.height; BluetoothState.Init(); }
private static void InternInit(bool shouldLog) { if (initialized) { Scan(); return; } if (m_instance == null) { m_instance = FindObjectOfType <iBeaconReceiver>(); if (m_instance == null) { BluetoothState.Init(); m_instance = GameObject.Find(BluetoothState.NAME).AddComponent <iBeaconReceiver>(); } } Stop(); var state = BluetoothState.GetBluetoothLEStatus(); if (state == BluetoothLowEnergyState.IBEACON_ONLY) { if (regions.Any(region => region.beacon.type == BeaconType.iBeacon)) { Debug.LogWarning(MessageiBeaconOnly); } else { throw new iBeaconException(MessageiBeaconOnly); } } else if (state != BluetoothLowEnergyState.POWERED_ON) { BluetoothState.EnableBluetooth(); if (BluetoothState.GetBluetoothLEStatus() != BluetoothLowEnergyState.POWERED_ON) { throw new iBeaconException("Bluetooth is off and could not be enabled."); } } #if !UNITY_EDITOR #if UNITY_IOS if (!InitReceiver(iBeaconRegion.regionsToString(m_instance._regions), shouldLog)) { throw new iBeaconException("Receiver initialization failed."); } #elif UNITY_ANDROID GetPlugin().Call( "Init", iBeaconRegion.regionsToString(m_instance._regions), Mathf.FloorToInt(m_instance._detectionTimespan * 1000), Mathf.FloorToInt(m_instance._scanPeriod * 1000), Mathf.FloorToInt(m_instance._betweenScanPeriod * 1000), shouldLog); #endif #endif initialized = true; Scan(); }
private void Start() { _bluetoothButton.onClick.AddListener(delegate() { BluetoothState.EnableBluetooth(); }); _bluetoothText = _bluetoothButton.GetComponentInChildren <Text> (); BluetoothState.BluetoothStateChangedEvent += delegate(BluetoothLowEnergyState state) { switch (state) { case BluetoothLowEnergyState.TURNING_OFF: case BluetoothLowEnergyState.TURNING_ON: break; case BluetoothLowEnergyState.UNKNOWN: case BluetoothLowEnergyState.RESETTING: break; case BluetoothLowEnergyState.UNAUTHORIZED: break; case BluetoothLowEnergyState.UNSUPPORTED: break; case BluetoothLowEnergyState.POWERED_OFF: _bluetoothButton.interactable = true; break; case BluetoothLowEnergyState.POWERED_ON: _bluetoothButton.interactable = false; break; default: break; } }; BluetoothState.Init(); _camera = GameObject.FindGameObjectWithTag("MainCamera");// posCamera = new Vector3(0, 0, -9); MapImage = GameObject.Find("Map").transform.Find("Map_Image").gameObject; btnGetYokai.transform.GetChild(0).GetComponent <Text>().text = ApplicationData.GetLocaleText(LocaleType.ButtonToSeal); btnGetYokai.transform.GetChild(0).GetComponent <Text>().fontSize = ApplicationData.SetFontSize(LocaleType.ButtonToSeal); btnSuccess.transform.GetChild(0).GetComponent <Text>().text = ApplicationData.GetLocaleText(LocaleType.ButtonGetSuccessful); btnSuccess.transform.GetChild(0).GetComponent <Text>().fontSize = ApplicationData.SetFontSize(LocaleType.ButtonGetSuccessful); if (ApplicationData.SelectedLanguage == LanguageType.Thai) { btnGetYokai.transform.GetChild(0).GetComponent <Text> ().font = ApplicationData.GetFont(4); btnSuccess.transform.GetChild(0).GetComponent <Text>().font = ApplicationData.GetFont(4); } else { btnGetYokai.transform.GetChild(0).GetComponent <Text> ().font = ApplicationData.GetFont(2); btnSuccess.transform.GetChild(0).GetComponent <Text>().font = ApplicationData.GetFont(2); } }
private static void InternInit(bool shouldLog) { if (initialized) { Transmit(); return; } if (m_instance == null) { m_instance = FindObjectOfType <iBeaconServer>(); if (m_instance == null) { BluetoothState.Init(); m_instance = GameObject.Find(BluetoothState.NAME).AddComponent <iBeaconServer>(); } } StopTransmit(); if (BluetoothState.GetBluetoothLEStatus() != BluetoothLowEnergyState.POWERED_ON) { BluetoothState.EnableBluetooth(); if (BluetoothState.GetBluetoothLEStatus() != BluetoothLowEnergyState.POWERED_ON) { throw new iBeaconException("Bluetooth is off and could not be enabled."); } } if (!checkTransmissionSupported(shouldLog)) { throw new iBeaconException("This device does not support transmitting as a beacon."); } #if !UNITY_EDITOR var sb = new StringBuilder(JsonUtility.ToJson(m_instance._region)); sb.Insert(sb.Length - 1, ",\"_txPower\":"); sb.Insert(sb.Length - 1, m_instance._txPower); #if UNITY_IOS if (!InitBeaconServer(sb.ToString(), shouldLog)) { throw new iBeaconException("Server initialization failed."); } #elif UNITY_ANDROID sb.Insert(sb.Length - 1, ",\"_powerLevel\":"); sb.Insert(sb.Length - 1, (int)m_instance._powerLevel); sb.Insert(sb.Length - 1, ",\"_mode\":"); sb.Insert(sb.Length - 1, (int)m_instance._mode); if (!GetPlugin().Call <bool>("Init", sb.ToString(), shouldLog)) { throw new iBeaconException("Server initialization failed."); } #endif #endif initialized = true; Transmit(); }
void Start() { // Enable Bluetooth BluetoothState.Init(); BluetoothState.EnableBluetooth(); //Init Pop Up PopUpDetected.active = false; PopUpLoading.active = false; // Auto Region s_Region = "Indonesia"; // Button Listener ScanBtn.onClick.AddListener(startScan); }
private static void InternInit(bool shouldLog) { if (initialized) { Scan(); return; } if (m_instance == null) { m_instance = FindObjectOfType <iBeaconReceiver>(); if (m_instance == null) { BluetoothState.Init(); m_instance = GameObject.Find(BluetoothState.NAME).AddComponent <iBeaconReceiver>(); } } Stop(); if (BluetoothState.GetBluetoothLEStatus() != BluetoothLowEnergyState.POWERED_ON) { BluetoothState.EnableBluetooth(); if (BluetoothState.GetBluetoothLEStatus() != BluetoothLowEnergyState.POWERED_ON) { throw new iBeaconException("Bluetooth is off and could not be enabled."); } } #if !UNITY_EDITOR #if UNITY_IOS if (!InitReceiver(iBeaconRegion.regionsToString(m_instance._regions), shouldLog)) { throw new iBeaconException("Receiver initialization failed."); } #elif UNITY_ANDROID GetPlugin().Call( "Init", iBeaconRegion.regionsToString(m_instance._regions), Mathf.FloorToInt(m_instance._androidDetectionTimespan * 1000), shouldLog); #endif #endif initialized = true; Scan(); }
private void StateChangeEvent(BluetoothLowEnergyState state) { Diglbug.Log("State changed: " + state, PrintStream.SIGNALS); canSend = iBeaconServer.checkTransmissionSupported(); validateReady = state == BluetoothLowEnergyState.POWERED_ON; if (state == BluetoothLowEnergyState.POWERED_OFF) { if (!hasAsked) { Diglbug.Log("BLE OFF. Asking the user to switch it back on.", PrintStream.SIGNALS); BluetoothState.EnableBluetooth(); hasAsked = true; } } if (state != BluetoothLowEnergyState.POWERED_ON && state != BluetoothLowEnergyState.TURNING_ON) { Diglbug.Log("BLE OFF. Asking the user to switch it back on.", PrintStream.SIGNALS); if (validating == false) { StartCoroutine(ValidateBluetooth()); } } }
public void EnableBluetooth() { BluetoothState.EnableBluetooth(); }
void Awake() { bs_State = BroadcastState.inactive; BluetoothState.EnableBluetooth(); }
public void RequestBluetoothEnable() { BluetoothState.EnableBluetooth(); }