List of usage examples for android.bluetooth BluetoothGattCharacteristic PERMISSION_READ
int PERMISSION_READ
To view the source code for android.bluetooth BluetoothGattCharacteristic PERMISSION_READ.
Click Source Link
From source file:Main.java
public static JSONArray decodePermissions(BluetoothGattCharacteristic characteristic) { // NOTE: props strings need to be consistent across iOS and Android JSONArray props = new JSONArray(); int permissions = characteristic.getPermissions(); if ((permissions & BluetoothGattCharacteristic.PERMISSION_READ) != 0x0) { props.put("Read"); }//from w ww . j ava 2s.c om if ((permissions & BluetoothGattCharacteristic.PERMISSION_WRITE) != 0x0) { props.put("Write"); } if ((permissions & BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED) != 0x0) { props.put("ReadEncrypted"); } if ((permissions & BluetoothGattCharacteristic.PERMISSION_WRITE_ENCRYPTED) != 0x0) { props.put("WriteEncrypted"); } if ((permissions & BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED_MITM) != 0x0) { props.put("ReadEncryptedMITM"); } if ((permissions & BluetoothGattCharacteristic.PERMISSION_WRITE_ENCRYPTED_MITM) != 0x0) { props.put("WriteEncryptedMITM"); } if ((permissions & BluetoothGattCharacteristic.PERMISSION_WRITE_SIGNED) != 0x0) { props.put("WriteSigned"); } if ((permissions & BluetoothGattCharacteristic.PERMISSION_WRITE_SIGNED_MITM) != 0x0) { props.put("WriteSignedMITM"); } return props; }
From source file:com.example.emulator.EmulatorFragment.java
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) public EmulatorFragment() { mBatteryLevelCharacteristic = new BluetoothGattCharacteristic(BATTERY_LEVEL_UUID, BluetoothGattCharacteristic.PROPERTY_READ | BluetoothGattCharacteristic.PROPERTY_NOTIFY, BluetoothGattCharacteristic.PERMISSION_READ); mBatteryLevelCharacteristic.addDescriptor(Peripheral.getClientCharacteristicConfigurationDescriptor()); mBatteryLevelCharacteristic//from w w w . j a va2 s . co m .addDescriptor(Peripheral.getCharacteristicUserDescriptionDescriptor(BATTERY_LEVEL_DESCRIPTION)); mBatteryService = new BluetoothGattService(BATTERY_SERVICE_UUID, BluetoothGattService.SERVICE_TYPE_PRIMARY); mBatteryService.addCharacteristic(mBatteryLevelCharacteristic); }
From source file:io.v.android.impl.google.discovery.plugins.ble.Driver.java
public void addService(final String uuid, Map<String, byte[]> characteristics) { BluetoothGattService service = new BluetoothGattService(UUID.fromString(uuid), BluetoothGattService.SERVICE_TYPE_PRIMARY); for (Map.Entry<String, byte[]> entry : characteristics.entrySet()) { BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic( UUID.fromString(entry.getKey()), BluetoothGattCharacteristic.PROPERTY_READ, BluetoothGattCharacteristic.PERMISSION_READ); characteristic.setValue(entry.getValue()); service.addCharacteristic(characteristic); }// w w w . j a v a 2 s .c om synchronized (this) { if (mServices.put(uuid, service) != null) { throw new IllegalStateException("already being advertised: " + uuid); } if (mEnabled) { startAdvertising(service); } } }
From source file:io.v.android.libs.discovery.ble.BlePlugin.java
private BluetoothGattService convertToService(Advertisement adv) throws IOException { Map<UUID, byte[]> attributes = BleAdvertisementConverter.vAdvertismentToBleAttr(adv); BluetoothGattService service = new BluetoothGattService(UUIDUtil.UuidToUUID(adv.getServiceUuid()), BluetoothGattService.SERVICE_TYPE_PRIMARY); for (Map.Entry<UUID, byte[]> entry : attributes.entrySet()) { BluetoothGattCharacteristic ch = new BluetoothGattCharacteristic(entry.getKey(), 0, BluetoothGattCharacteristic.PERMISSION_READ); ch.setValue(entry.getValue());/*w ww . j a v a 2 s . com*/ service.addCharacteristic(ch); } return service; }
From source file:org.physical_web.physicalweb.FatBeaconBroadcastService.java
private void initGattServer() { mGattServer = mBluetoothManager.openGattServer(this, mGattServerCallback); BluetoothGattService service = new BluetoothGattService(UUID.fromString(SERVICE_UUID), BluetoothGattService.SERVICE_TYPE_PRIMARY); BluetoothGattCharacteristic webpage = new BluetoothGattCharacteristic(CHARACTERISTIC_WEBPAGE_UUID, BluetoothGattCharacteristic.PROPERTY_READ, BluetoothGattCharacteristic.PERMISSION_READ); service.addCharacteristic(webpage);//w ww . j a v a2 s . c o m mGattServer.addService(service); }
From source file:edu.umich.eecs.lab11.camera.CameraFragment.java
private void initServer() { BluetoothGattService service = new BluetoothGattService(DeviceProfile.SERVICE_UUID, BluetoothGattService.SERVICE_TYPE_PRIMARY); BluetoothGattCharacteristic offsetCharacteristic = new BluetoothGattCharacteristic( DeviceProfile.CHARACTERISTIC_UUID, //Read+write permissions BluetoothGattCharacteristic.PROPERTY_READ | BluetoothGattCharacteristic.PROPERTY_WRITE, BluetoothGattCharacteristic.PERMISSION_READ | BluetoothGattCharacteristic.PERMISSION_WRITE); service.addCharacteristic(offsetCharacteristic); mGattServer.addService(service);/*from w w w. j ava 2 s .c om*/ }