/** Search for the TrueTouch device. */ private void handleBleScanning() { BleApi.DeviceUpdate device = new BleApi.DeviceUpdate(); BleApi.ScanStatus status; do { status = BleApi.PollDevice(ref device, false); if (status == BleApi.ScanStatus.AVAILABLE) { Debug.Log("Found device: " + device.name + " | " + device.id); if (device.name.Equals(DEVICE_NAME, StringComparison.OrdinalIgnoreCase)) { /* TrueTouch found, scan for the desired service UUID */ BleApi.StopDeviceScan(); truetouchDevice = device; BleApi.ScanServices(truetouchDevice.id); state = BleState.CONNECTING; Debug.Log("Scanning TrueTouch's services"); return; } } else if (status == BleApi.ScanStatus.FINISHED) { /* Ran out of devices without finding target device */ errorString = "Could not find TrueTouch"; state = BleState.ERROR; } } while (status == BleApi.ScanStatus.AVAILABLE); }
public void StartServiceScan() { if (!isScanningServices) { // start new scan serviceDropdown.ClearOptions(); BleApi.ScanServices(selectedDeviceId); isScanningServices = true; serviceScanStatusText.text = "scanning"; serviceScanButton.interactable = false; } }