Search in sources :

Example 1 with BooleanAttributeProperty

use of org.eclipse.vorto.repository.api.content.BooleanAttributeProperty in project vorto by eclipse.

the class BleGattDeviceBuilder method buildCharacteristic.

private BleGattCharacteristic buildCharacteristic(ModelProperty property) {
    BleGattCharacteristic ch = new BleGattCharacteristic();
    // Determine if a characteristic uses notification (derived from "eventable" attribute)
    for (IPropertyAttribute attr : property.getAttributes()) {
        if (attr instanceof BooleanAttributeProperty) {
            BooleanAttributeProperty attrprop = (BooleanAttributeProperty) attr;
            if ((attrprop.getType() == BooleanAttributePropertyType.EVENTABLE) && (attrprop.isValue())) {
                ch.setNotified(true);
            }
        }
    }
    // Get the relevant information for BLE GATT Characteristics
    Optional<Stereotype> sourceSt = property.getStereotype("source");
    if (sourceSt.isPresent()) {
        Stereotype source = sourceSt.get();
        if (source.getAttributes().containsKey("uuid")) {
            ch.setUuid(UUID.fromString(source.getAttributes().get("uuid").toString()));
        }
        if (source.getAttributes().containsKey("onConnect")) {
            BleGattInitSequenceElement elt = new BleGattInitSequenceElement(ch, source.getAttributes().get("onConnect"));
            device.addInitSequenceElement(elt);
        }
        if (source.getAttributes().containsKey("handle")) {
            ch.setHandle(source.getAttributes().get("handle"));
        }
    }
    return ch;
}
Also used : IPropertyAttribute(org.eclipse.vorto.repository.api.content.IPropertyAttribute) BooleanAttributeProperty(org.eclipse.vorto.repository.api.content.BooleanAttributeProperty) Stereotype(org.eclipse.vorto.repository.api.content.Stereotype)

Aggregations

BooleanAttributeProperty (org.eclipse.vorto.repository.api.content.BooleanAttributeProperty)1 IPropertyAttribute (org.eclipse.vorto.repository.api.content.IPropertyAttribute)1 Stereotype (org.eclipse.vorto.repository.api.content.Stereotype)1