Java Code Examples for android.bluetooth.BluetoothGattCharacteristic#PROPERTY_BROADCAST

The following examples show how to use android.bluetooth.BluetoothGattCharacteristic#PROPERTY_BROADCAST . 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: DeviceControlActivity.java    From AndroidBleManager with Apache License 2.0 6 votes vote down vote up
/**
 * get property,http://blog.csdn.net/chenxh515/article/details/45723299
 * @param property
 * @return
 */
private String getPropertyString(int property){
    StringBuilder sb = new StringBuilder("(");
    //Read
    if ((property & BluetoothGattCharacteristic.PROPERTY_READ) > 0) {
        sb.append("Read ");
    }
    //Write
    if ((property & BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE) > 0
            || (property & BluetoothGattCharacteristic.PROPERTY_WRITE) > 0) {
        sb.append("Write ");
    }
    //Notify
    if ((property & BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0
            || (property & BluetoothGattCharacteristic.PROPERTY_INDICATE) > 0) {
        sb.append("Notity Indicate ");
    }
    //Broadcast
    if ((property & BluetoothGattCharacteristic.PROPERTY_BROADCAST) > 0){
        sb.append("Broadcast ");
    }
    sb.deleteCharAt(sb.length() - 1);
    sb.append(")");
    return sb.toString();
}
 
Example 2
Source File: CharacteristicDetailActivity.java    From AndroidBleManager with Apache License 2.0 6 votes vote down vote up
private String getPropertyString(int property){
    StringBuilder sb = new StringBuilder();
    // 可读
    if ((property & BluetoothGattCharacteristic.PROPERTY_READ) > 0) {
        sb.append("Read ");
    }
    // 可写,注:要 & 其可写的两个属性
    if ((property & BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE) > 0
            || (property & BluetoothGattCharacteristic.PROPERTY_WRITE) > 0) {
        sb.append("Write ");
    }
    // 可通知,可指示
    if ((property & BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0
            || (property & BluetoothGattCharacteristic.PROPERTY_INDICATE) > 0) {
        sb.append("Notity Indicate ");
    }
    // 广播
    if ((property & BluetoothGattCharacteristic.PROPERTY_BROADCAST) > 0){
        sb.append("Broadcast ");
    }
    sb.deleteCharAt(sb.length() - 1);
    return sb.toString();
}
 
Example 3
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 4
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 5
Source File: ConnectionModule.java    From RxAndroidBle with Apache License 2.0 5 votes vote down vote up
@Provides
static CharacteristicPropertiesParser provideCharacteristicPropertiesParser() {
    return new CharacteristicPropertiesParser(BluetoothGattCharacteristic.PROPERTY_BROADCAST,
            BluetoothGattCharacteristic.PROPERTY_READ,
            BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE,
            BluetoothGattCharacteristic.PROPERTY_WRITE,
            BluetoothGattCharacteristic.PROPERTY_NOTIFY,
            BluetoothGattCharacteristic.PROPERTY_INDICATE,
            BluetoothGattCharacteristic.PROPERTY_SIGNED_WRITE);
}
 
Example 6
Source File: CharacteristicDetailActivity.java    From AndroidBleManager with Apache License 2.0 5 votes vote down vote up
private void checkProperty(int property){
    writeView.setVisibility(View.GONE);
    readView.setVisibility(View.GONE);
    notifyView.setVisibility(View.GONE);
    // 可读
    if ((property & BluetoothGattCharacteristic.PROPERTY_READ) > 0) {
        readView.setVisibility(View.VISIBLE);
    }
    // 可写,注:要 & 其可写的两个属性
    if ((property & BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE) > 0
            || (property & BluetoothGattCharacteristic.PROPERTY_WRITE) > 0) {
        writeView.setVisibility(View.VISIBLE);
    }
    // 可通知,可指示
    if ((property & BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0
            || (property & BluetoothGattCharacteristic.PROPERTY_INDICATE) > 0) {
        readView.setVisibility(View.VISIBLE);
        notifyView.setVisibility(View.VISIBLE);
        mNotifyList.setVisibility(View.VISIBLE);
        if ((property & BluetoothGattCharacteristic.PROPERTY_READ) > 0) {
            mTvNotifyAndRead.setText("READ/NOTIFY VALUES");
        }
    }
    // 广播
    if ((property & BluetoothGattCharacteristic.PROPERTY_BROADCAST) > 0){
    }
}
 
Example 7
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 8
Source File: GattDatabase.java    From AsteroidOSSync with GNU General Public License v3.0 4 votes vote down vote up
public final Properties broadcast()
{
    m_properties |= BluetoothGattCharacteristic.PROPERTY_BROADCAST;
    return this;
}
 
Example 9
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 10
Source File: BluetoothUtils.java    From AndroidBleManager with Apache License 2.0 4 votes vote down vote up
public static boolean isCharacteristicBroadcast(int property){
    if ((property & BluetoothGattCharacteristic.PROPERTY_BROADCAST) > 0){
        return true;
    }
    return false;
}
 
Example 11
Source File: GattDatabase.java    From SweetBlue with GNU General Public License v3.0 4 votes vote down vote up
public final Properties broadcast()
{
    m_properties |= BluetoothGattCharacteristic.PROPERTY_BROADCAST;
    return this;
}
 
Example 12
Source File: GattDatabase.java    From SweetBlue with GNU General Public License v3.0 4 votes vote down vote up
public final Properties broadcast()
{
    m_properties |= BluetoothGattCharacteristic.PROPERTY_BROADCAST;
    return this;
}