Java Code Examples for android.bluetooth.BluetoothGattCharacteristic#PROPERTY_EXTENDED_PROPS

The following examples show how to use android.bluetooth.BluetoothGattCharacteristic#PROPERTY_EXTENDED_PROPS . 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 File: BleGattCallback.java    From attach with GNU General Public License v3.0 5 votes vote down vote up
private String getProperties(int bitmask) {
    String properties = "";

    if ((bitmask & BluetoothGattCharacteristic.PROPERTY_BROADCAST) != 0) {
        properties += "broadcast, ";
    }
    if ((bitmask & BluetoothGattCharacteristic.PROPERTY_EXTENDED_PROPS) != 0) {
        properties += "extended props, ";
    }
    if ((bitmask & BluetoothGattCharacteristic.PROPERTY_INDICATE) != 0) {
        properties += "indicate, ";
    }
    if ((bitmask & BluetoothGattCharacteristic.PROPERTY_NOTIFY) != 0) {
        properties += "notify, ";
    }
    if ((bitmask & BluetoothGattCharacteristic.PROPERTY_READ) != 0) {
        properties += "read, ";
    }
    if ((bitmask & BluetoothGattCharacteristic.PROPERTY_SIGNED_WRITE) != 0) {
        properties += "signed write, ";
    }
    if ((bitmask & BluetoothGattCharacteristic.PROPERTY_WRITE) != 0) {
        properties += "write, ";
    }
    if ((bitmask & BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE) != 0) {
        properties += "write no response, ";
    }

    return properties.isEmpty() ? "" : properties.substring(0, properties.length() - 2);
}
 
Example 2
Source File: ParserUtils.java    From Android-nRF-Beacon-for-Eddystone with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static String getProperties(final BluetoothGattCharacteristic characteristic) {
    final int properties = characteristic.getProperties();
    final StringBuilder builder = new StringBuilder();
    if ((properties & BluetoothGattCharacteristic.PROPERTY_BROADCAST) > 0)
        builder.append("B ");
    if ((properties & BluetoothGattCharacteristic.PROPERTY_EXTENDED_PROPS) > 0)
        builder.append("E ");
    if ((properties & BluetoothGattCharacteristic.PROPERTY_INDICATE) > 0)
        builder.append("I ");
    if ((properties & BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0)
        builder.append("N ");
    if ((properties & BluetoothGattCharacteristic.PROPERTY_READ) > 0)
        builder.append("R ");
    if ((properties & BluetoothGattCharacteristic.PROPERTY_SIGNED_WRITE) > 0)
        builder.append("SW ");
    if ((properties & BluetoothGattCharacteristic.PROPERTY_WRITE) > 0)
        builder.append("W ");
    if ((properties & BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE) > 0)
        builder.append("WNR ");

    if (builder.length() > 0) {
        builder.setLength(builder.length() - 1);
        builder.insert(0, "[");
        builder.append("]");
    }
    return builder.toString();
}
 
Example 3
Source File: GattPlugin.java    From bitgatt with Mozilla Public License 2.0 4 votes vote down vote up
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
String getStringRepresentationOfPropertiesForCharacteristic(BluetoothGattCharacteristic characteristic) {
    StringBuilder propertyBuilder = new StringBuilder();
    ArrayList<Integer> properties = new ArrayList<>(8);
    int characteristicProperties = characteristic.getProperties();
    if ((characteristicProperties & BluetoothGattCharacteristic.PROPERTY_READ) == BluetoothGattCharacteristic.PROPERTY_READ) {
        properties.add(BluetoothGattCharacteristic.PROPERTY_READ);
    }
    if ((characteristicProperties & BluetoothGattCharacteristic.PROPERTY_WRITE) == BluetoothGattCharacteristic.PROPERTY_WRITE) {
        properties.add(BluetoothGattCharacteristic.PROPERTY_WRITE);
    }
    if ((characteristicProperties & BluetoothGattCharacteristic.PROPERTY_BROADCAST) == BluetoothGattCharacteristic.PROPERTY_BROADCAST) {
        properties.add(BluetoothGattCharacteristic.PROPERTY_BROADCAST);
    }
    if ((characteristicProperties & BluetoothGattCharacteristic.PROPERTY_EXTENDED_PROPS) == BluetoothGattCharacteristic.PROPERTY_EXTENDED_PROPS) {
        properties.add(BluetoothGattCharacteristic.PROPERTY_EXTENDED_PROPS);
    }
    if ((characteristicProperties & BluetoothGattCharacteristic.PROPERTY_INDICATE) == BluetoothGattCharacteristic.PROPERTY_INDICATE) {
        properties.add(BluetoothGattCharacteristic.PROPERTY_INDICATE);
    }
    if ((characteristicProperties & BluetoothGattCharacteristic.PROPERTY_NOTIFY) == BluetoothGattCharacteristic.PROPERTY_NOTIFY) {
        properties.add(BluetoothGattCharacteristic.PROPERTY_NOTIFY);
    }
    if ((characteristicProperties & BluetoothGattCharacteristic.PROPERTY_SIGNED_WRITE) == BluetoothGattCharacteristic.PROPERTY_SIGNED_WRITE) {
        properties.add(BluetoothGattCharacteristic.PROPERTY_SIGNED_WRITE);
    }
    if ((characteristicProperties & BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE) == BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE) {
        properties.add(BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE);
    }
    for (int i = 0; i < properties.size(); i++) {
        int property = properties.get(i);
        switch (property) {
            case BluetoothGattCharacteristic.PROPERTY_READ:
                propertyBuilder.append("read");
                break;
            case BluetoothGattCharacteristic.PROPERTY_WRITE:
                propertyBuilder.append("write");
                break;
            case BluetoothGattCharacteristic.PROPERTY_BROADCAST:
                propertyBuilder.append("broadcast");
                break;
            case BluetoothGattCharacteristic.PROPERTY_EXTENDED_PROPS:
                propertyBuilder.append("extended-props");
                break;
            case BluetoothGattCharacteristic.PROPERTY_NOTIFY:
                propertyBuilder.append("notify");
                break;
            case BluetoothGattCharacteristic.PROPERTY_INDICATE:
                propertyBuilder.append("indicate");
                break;
            case BluetoothGattCharacteristic.PROPERTY_SIGNED_WRITE:
                propertyBuilder.append("write-signed");
                break;
            case BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE:
                propertyBuilder.append("write-no-response");
                break;
            default:
                propertyBuilder.append("unknown");
        }
        if (i < properties.size() - 1) {
            propertyBuilder.append(", ");
        }
    }
    return propertyBuilder.toString();
}
 
Example 4
Source File: GattDatabase.java    From AsteroidOSSync with GNU General Public License v3.0 4 votes vote down vote up
public final Properties extended_props()
{
    m_properties |= BluetoothGattCharacteristic.PROPERTY_EXTENDED_PROPS;
    return this;
}
 
Example 5
Source File: Helper.java    From react-native-ble-manager with Apache License 2.0 4 votes vote down vote up
public static WritableMap decodeProperties(BluetoothGattCharacteristic characteristic) {

		// NOTE: props strings need to be consistent across iOS and Android
		WritableMap props = Arguments.createMap();
		int properties = characteristic.getProperties();

		if ((properties & BluetoothGattCharacteristic.PROPERTY_BROADCAST) != 0x0 ) {
			props.putString("Broadcast", "Broadcast");
		}

		if ((properties & BluetoothGattCharacteristic.PROPERTY_READ) != 0x0 ) {
			props.putString("Read", "Read");
		}

		if ((properties & BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE) != 0x0 ) {
			props.putString("WriteWithoutResponse", "WriteWithoutResponse");
		}

		if ((properties & BluetoothGattCharacteristic.PROPERTY_WRITE) != 0x0 ) {
			props.putString("Write", "Write");
		}

		if ((properties & BluetoothGattCharacteristic.PROPERTY_NOTIFY) != 0x0 ) {
			props.putString("Notify", "Notify");
		}

		if ((properties & BluetoothGattCharacteristic.PROPERTY_INDICATE) != 0x0 ) {
			props.putString("Indicate", "Indicate");
		}

		if ((properties & BluetoothGattCharacteristic.PROPERTY_SIGNED_WRITE) != 0x0 ) {
			// Android calls this "write with signature", using iOS name for now
			props.putString("AuthenticateSignedWrites", "AuthenticateSignedWrites");
		}

		if ((properties & BluetoothGattCharacteristic.PROPERTY_EXTENDED_PROPS) != 0x0 ) {
			props.putString("ExtendedProperties", "ExtendedProperties");
		}

//      iOS only?
//
//            if ((p & CBCharacteristicPropertyNotifyEncryptionRequired) != 0x0) {  // 0x100
//                [props addObject:@"NotifyEncryptionRequired"];
//            }
//
//            if ((p & CBCharacteristicPropertyIndicateEncryptionRequired) != 0x0) { // 0x200
//                [props addObject:@"IndicateEncryptionRequired"];
//            }

		return props;
	}
 
Example 6
Source File: GattDatabase.java    From SweetBlue with GNU General Public License v3.0 4 votes vote down vote up
public final Properties extended_props()
{
    m_properties |= BluetoothGattCharacteristic.PROPERTY_EXTENDED_PROPS;
    return this;
}
 
Example 7
Source File: GattDatabase.java    From SweetBlue with GNU General Public License v3.0 4 votes vote down vote up
public final Properties extended_props()
{
    m_properties |= BluetoothGattCharacteristic.PROPERTY_EXTENDED_PROPS;
    return this;
}