Java Code Examples for com.welie.blessed.BluetoothCentral

The following examples show how to use com.welie.blessed.BluetoothCentral. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: blessed-android   Source File: BluetoothHandler.java    License: MIT License 5 votes vote down vote up
private BluetoothHandler(Context context) {
    this.context = context;

    // Plant a tree
    Timber.plant(new Timber.DebugTree());

    // Create BluetoothCentral
    central = new BluetoothCentral(context, bluetoothCentralCallback, new Handler());

    // Scan for peripherals with a certain service UUIDs
    central.startPairingPopupHack();
    central.scanForPeripheralsWithServices(new UUID[]{BLP_SERVICE_UUID, HTS_SERVICE_UUID, HRS_SERVICE_UUID});
}
 
Example 2
Source Project: PHONK   Source File: PBluetoothLEClient.java    License: GNU General Public License v3.0 5 votes vote down vote up
public PBluetoothLEClient(AppRunner appRunner, BluetoothAdapter bleAdapter) {
    super(appRunner);
    mAppRunner = appRunner;
    mContext = appRunner.getAppContext();
    mBleAdapter = bleAdapter;
    mConnectionStatus = DISCONNECTED;

    central = new BluetoothCentral(appRunner.getAppContext(), bluetoothCentralCallback, new Handler());
    // central.startPairingPopupHack();
    // central.scanForPeripherals();
    mAppRunner.whatIsRunning.add(this);
}
 
Example 3
private void startBluetoothDiscovery() {
    deviceListView.removeAllViews();
    foundDevices.clear();

    central = new BluetoothCentral(getContext(), bluetoothCentralCallback, new Handler(Looper.getMainLooper()));
    central.scanForPeripherals();

    txtSearching.setVisibility(View.VISIBLE);
    txtSearching.setText(R.string.label_bluetooth_searching);
    progressBar.setVisibility(View.VISIBLE);

    progressHandler = new Handler();

    // Don't let the BLE discovery run forever
    progressHandler.postDelayed(new Runnable() {
        @Override
        public void run() {
            stopBluetoothDiscovery();

            txtSearching.setText(R.string.label_bluetooth_searching_finished);
            progressBar.setVisibility(View.GONE);

            BluetoothDeviceView notSupported = new BluetoothDeviceView(context);
            notSupported.setDeviceName(getString(R.string.label_scale_not_supported));
            notSupported.setSummaryText(getString(R.string.label_click_to_help_add_support));
            notSupported.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent notSupportedIntent = new Intent(Intent.ACTION_VIEW);
                    notSupportedIntent.setData(
                            Uri.parse("https://github.com/oliexdev/openScale/wiki/Supported-scales-in-openScale"));

                    startActivity(notSupportedIntent);
                }
            });
            deviceListView.addView(notSupported);
        }
    }, 20 * 1000);
}
 
Example 4
public BluetoothCommunication(Context context)
{
    this.context = context;
    this.disconnectHandler = new Handler();
    this.stepNr = 0;
    this.stopped = false;
    this.central = new BluetoothCentral(context, bluetoothCentralCallback, new Handler(Looper.getMainLooper()));
}