List of usage examples for android.bluetooth BluetoothGattCharacteristic getUuid
public UUID getUuid()
From source file:com.example.emulator.EmulatorFragment.java
@Override public void notificationsEnabled(BluetoothGattCharacteristic characteristic, boolean indicate) { if (characteristic.getUuid() != BATTERY_LEVEL_UUID) { return;/*from w w w. ja v a 2s . c o m*/ } if (indicate) { return; } mCurrentRepetition = 0; mHandler.post(runnable); getActivity().runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(getActivity(), R.string.notificationsEnabled, Toast.LENGTH_SHORT).show(); } }); mDemoPractice.execute(); }
From source file:nodomain.freeyourgadget.gadgetbridge.service.devices.vibratissimo.VibratissimoSupport.java
@Override public boolean onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) { if (super.onCharacteristicChanged(gatt, characteristic)) { return true; }/*w w w . j a v a2 s . com*/ UUID characteristicUUID = characteristic.getUuid(); LOG.info("Unhandled characteristic changed: " + characteristicUUID); return false; }
From source file:com.cypress.cysmart.BLEServiceFragments.RGBFragment.java
/** * Method to get required characteristics from service *//*ww w . j a v a 2 s .c om*/ void getGattData() { List<BluetoothGattCharacteristic> gattCharacteristics = mCurrentservice.getCharacteristics(); for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) { String uuidchara = gattCharacteristic.getUuid().toString(); if (uuidchara.equalsIgnoreCase(GattAttributes.RGB_LED) || uuidchara.equalsIgnoreCase(GattAttributes.RGB_LED_CUSTOM)) { mReadCharacteristic = gattCharacteristic; break; } } }
From source file:com.huiwu.temperaturecontrol.bluetooth.BluetoothService.java
private void broadcastUpdate(final String action, final BluetoothGattCharacteristic characteristic) { final Intent intent = new Intent(action); if (TX_CHAR_UUID.equals(characteristic.getUuid())) { intent.putExtra(EXTRA_DATA, characteristic.getValue()); } else {/* w ww . ja v a 2s . c o m*/ } LocalBroadcastManager.getInstance(this).sendBroadcast(intent); }
From source file:nodomain.freeyourgadget.gadgetbridge.service.devices.vibratissimo.VibratissimoSupport.java
@Override public boolean onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) { if (super.onCharacteristicRead(gatt, characteristic, status)) { return true; }/*from ww w . j a v a 2 s. c om*/ UUID characteristicUUID = characteristic.getUuid(); LOG.info("Unhandled characteristic read: " + characteristicUUID); return false; }
From source file:com.cypress.cysmart.BLEServiceFragments.CapsenseService.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.capsense_main, container, false); mCapsenseProximity = new CapsenseServiceProximity(); mCapsenseSlider = new CapsenseServiceSlider(); mCapsenseButton = new CapsenseServiceButtons(); // Instantiate a ViewPager and a PagerAdapter. mPager = (ViewPager) rootView.findViewById(R.id.capsenseViewpager); mPagerAdapter = new ScreenSlidePagerAdapter(getActivity().getSupportFragmentManager()); mPagerLayout = (LinearLayout) rootView.findViewById(R.id.capsense_page_indicator); mPagerView = new PagerFooterview(getActivity(), mViewpagerCount, mPagerLayout.getWidth()); mPagerLayout.addView(mPagerView);//from ww w . j a v a 2 s . c om if (mViewpagerCount == 1) { mPagerLayout.setVisibility(View.INVISIBLE); } /** * get required characteristics from service */ List<BluetoothGattCharacteristic> gattCharacteristics = mservice.getCharacteristics(); for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) { String uuidchara = gattCharacteristic.getUuid().toString(); if (uuidchara.equalsIgnoreCase(GattAttributes.CAPSENSE_PROXIMITY) || uuidchara.equalsIgnoreCase(GattAttributes.CAPSENSE_PROXIMITY_CUSTOM)) { Logger.i("UUID Charsss proximity" + gattCharacteristic.getUuid().toString()); mNotifyCharacteristicProx = gattCharacteristic; if (!mNotifyset) { mNotifyset = true; prepareBroadcastDataNotify(mNotifyCharacteristicProx); } fragmentsList.add(mCapsenseProximity.create(mservice)); } else if (uuidchara.equalsIgnoreCase(GattAttributes.CAPSENSE_SLIDER) || uuidchara.equalsIgnoreCase(GattAttributes.CAPSENSE_SLIDER_CUSTOM)) { Logger.i("UUID Charsss slid" + gattCharacteristic.getUuid().toString()); mNotifyCharacteristicSlid = gattCharacteristic; if (!mNotifyset) { mNotifyset = true; prepareBroadcastDataNotify(mNotifyCharacteristicSlid); } fragmentsList.add(mCapsenseSlider.create(mservice)); } else if (uuidchara.equalsIgnoreCase(GattAttributes.CAPSENSE_BUTTONS) || uuidchara.equalsIgnoreCase(GattAttributes.CAPSENSE_BUTTONS_CUSTOM)) { Logger.i("UUID Charsss buttons" + gattCharacteristic.getUuid().toString()); mNotifyCharacteristicBut = gattCharacteristic; if (!mNotifyset) { mNotifyset = true; prepareBroadcastDataNotify(mNotifyCharacteristicBut); } fragmentsList.add(mCapsenseButton.create(mservice)); } } mPager.setAdapter(mPagerAdapter); mPager.setPageTransformer(true, new DepthPageTransformer()); mPager.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageSelected(int position) { mPagerView.Update(position); if (position == 0) { prepareBroadcastDataNotify(mNotifyCharacteristicProx); if (mNotifyCharacteristicSlid != null) { stopBroadcastDataNotify(mNotifyCharacteristicSlid); } if (mNotifyCharacteristicBut != null) { stopBroadcastDataNotify(mNotifyCharacteristicBut); } } if (position == 1) { prepareBroadcastDataNotify(mNotifyCharacteristicSlid); if (mNotifyCharacteristicProx != null) { stopBroadcastDataNotify(mNotifyCharacteristicProx); } if (mNotifyCharacteristicBut != null) { stopBroadcastDataNotify(mNotifyCharacteristicBut); } } if (position == 2) { prepareBroadcastDataNotify(mNotifyCharacteristicBut); if (mNotifyCharacteristicSlid != null) { stopBroadcastDataNotify(mNotifyCharacteristicSlid); } if (mNotifyCharacteristicProx != null) { stopBroadcastDataNotify(mNotifyCharacteristicProx); } } } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { //Not needed } @Override public void onPageScrollStateChanged(int arg0) { //Not needed } }); setHasOptionsMenu(true); return rootView; }
From source file:com.cypress.cysmart.BLEServiceFragments.HealthTemperatureService.java
/** * Method to get required characteristics from service *///w ww. j av a2 s . c o m void getGattData() { List<BluetoothGattCharacteristic> gattCharacteristics = mservice.getCharacteristics(); for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) { String uuidchara = gattCharacteristic.getUuid().toString(); if (uuidchara.equalsIgnoreCase(GattAttributes.TEMPERATURE_TYPE)) { mReadCharacteristic = gattCharacteristic; prepareBroadcastDataRead(mReadCharacteristic); } if (uuidchara.equalsIgnoreCase(GattAttributes.HEALTH_TEMP_MEASUREMENT)) { mNotifyCharacteristic = gattCharacteristic; // prepareBroadcastDataIndicate(mNotifyCharacteristic); } } }
From source file:com.cypress.cysmart.BLEServiceFragments.HeartRateService.java
/** * Method to get required characteristics from service *//*w w w .j a v a 2s. c om*/ void getGattData() { List<BluetoothGattCharacteristic> gattCharacteristics = mservice.getCharacteristics(); for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) { String uuidchara = gattCharacteristic.getUuid().toString(); if (uuidchara.equalsIgnoreCase(GattAttributes.BODY_SENSOR_LOCATION)) { mReadCharacteristic = gattCharacteristic; prepareBroadcastDataRead(mReadCharacteristic); } if (uuidchara.equalsIgnoreCase(GattAttributes.HEART_RATE_MEASUREMENT)) { mNotifyCharacteristic = gattCharacteristic; } } }
From source file:edu.stanford.cs.sing.helena.DeviceControlActivity.java
private void checkServices(List<BluetoothGattService> gattServices) { if (gattServices == null) return;//from w ww . j a v a 2s. c om String uuid; // Loops through available GATT Services. for (BluetoothGattService gattService : gattServices) { uuid = gattService.getUuid().toString(); //only interested in helena service if (uuid.equals(HelenaGattAttributes.HELENA_SERVICE)) { mHelenaService = gattService; List<BluetoothGattCharacteristic> gattCharacteristics = gattService.getCharacteristics(); // Loops through available Characteristics. for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) { //only interested in this characteristic if (gattCharacteristic.getUuid().toString().equals(HelenaGattAttributes.UUID_LISTED_DEVICE)) { mNotifyCharacteristic = gattCharacteristic; final int charaProp = gattCharacteristic.getProperties(); if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) { //Initiate notifications mNotifyCharacteristic = gattCharacteristic; mBluetoothLeService.setCharacteristicNotification(mNotifyCharacteristic, true); } } } } else { Log.d(TAG, "Skipping other services"); } } }
From source file:com.lannbox.rfduinotest.RFduinoService.java
private void broadcastUpdate(final String action, final BluetoothGattCharacteristic characteristic) { if (UUID_RECEIVE.equals(characteristic.getUuid())) { final Intent intent = new Intent(action); intent.putExtra(EXTRA_DATA, characteristic.getValue()); sendBroadcast(intent, Manifest.permission.BLUETOOTH); Log.w(TAG, "BTLE Data received and broadcasted"); // Create notification Intent notificationIntent = new Intent(RFduinoService.this, MainActivity.class); notificationIntent.setAction("RFduinoTest_CallToMain"); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); PendingIntent pendingIntent = PendingIntent.getActivity(RFduinoService.this, 0, notificationIntent, 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(RFduinoService.this) .setContentTitle("Bluetooth Data").setTicker("New Bluetooth Data Received") .setContentText("Data:" + HexAsciiHelper.bytesToAsciiMaybe(characteristic.getValue()) + "\nOr: " + HexAsciiHelper.bytesToHex(characteristic.getValue())) .setSmallIcon(R.drawable.ic_launcher) // .setLargeIcon( // Bitmap.createScaledBitmap(icon, 128, 128, false)) .setAutoCancel(true).setContentIntent(pendingIntent); mNotificationManager.notify(110, mBuilder.build()); }// w w w. j ava 2 s .co m }