Example usage for android.bluetooth BluetoothDevice DEVICE_TYPE_LE

List of usage examples for android.bluetooth BluetoothDevice DEVICE_TYPE_LE

Introduction

In this page you can find the example usage for android.bluetooth BluetoothDevice DEVICE_TYPE_LE.

Prototype

int DEVICE_TYPE_LE

To view the source code for android.bluetooth BluetoothDevice DEVICE_TYPE_LE.

Click Source Link

Document

Bluetooth device type, Low Energy - LE-only

Usage

From source file:Main.java

public static String formatDeviceType(int type) {
    switch (type) {
    case BluetoothDevice.DEVICE_TYPE_CLASSIC:
        return "Bluetooth Classic";
    case BluetoothDevice.DEVICE_TYPE_LE:
        return "Low Energy";
    case BluetoothDevice.DEVICE_TYPE_DUAL:
        return "Dual";
    case BluetoothDevice.DEVICE_TYPE_UNKNOWN:
    default:/*from   www  .j a v  a2 s. c  o  m*/
        return "Unknown";
    }
}

From source file:Main.java

public static String getDeviceType(int type) {
    switch (type) {
    case BluetoothDevice.DEVICE_TYPE_CLASSIC:
        return "CLASSIC";
    case BluetoothDevice.DEVICE_TYPE_DUAL:
        return "DUAL";
    case BluetoothDevice.DEVICE_TYPE_LE:
        return "LE";
    default://from w  ww.j ava 2  s. com
        return "Unknown";
    }
}

From source file:nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebblePairingActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_pebble_pairing);

    message = (TextView) findViewById(R.id.pebble_pair_message);
    Intent intent = getIntent();/*from  w ww .j a  v a 2  s . c  o m*/
    GBDeviceCandidate candidate = intent.getParcelableExtra(DeviceCoordinator.EXTRA_DEVICE_CANDIDATE);
    if (candidate != null) {
        macAddress = candidate.getMacAddress();
    }
    if (macAddress == null) {
        Toast.makeText(this, getString(R.string.message_cannot_pair_no_mac), Toast.LENGTH_SHORT).show();
        returnToPairingActivity();
        return;
    }

    mBtDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(macAddress);
    if (mBtDevice == null) {
        GB.toast(this, "No such Bluetooth Device: " + macAddress, Toast.LENGTH_LONG, GB.ERROR);
        returnToPairingActivity();
        return;
    }

    isLEPebble = mBtDevice.getType() == BluetoothDevice.DEVICE_TYPE_LE;

    GBDevice gbDevice = null;
    if (isLEPebble) {
        if (mBtDevice.getName().startsWith("Pebble-LE ") || mBtDevice.getName().startsWith("Pebble Time LE ")) {
            if (!GBApplication.getPrefs().getBoolean("pebble_force_le", false)) {
                GB.toast(this,
                        "Please switch on \"Always prefer BLE\" option in Pebble settings before pairing you Pebble LE",
                        Toast.LENGTH_LONG, GB.ERROR);
                returnToPairingActivity();
                return;
            }
            gbDevice = getMatchingParentDeviceFromDB(mBtDevice);
            if (gbDevice == null) {
                return;
            }
        }
    }
    startPairing(gbDevice);
}