if(!feature.isEnabled()) return false; final BluetoothGattCharacteristic characteristic = getCorrespondingChar(feature); if(!charCanBeRead(characteristic)) return false;
public boolean writeFeatureData(Feature feature,byte data[], Runnable onWriteComplete){ final BluetoothGattCharacteristic characteristic = getCorrespondingChar(feature); //not enable or not exist or not in write mode -> return false if(!charCanBeWrite(characteristic) || !feature.isEnabled()) return false; enqueueCharacteristicsWrite(new WriteCharCommand(characteristic, data ,onWriteComplete)); return true; }//writeFeatureData
/** * ask to the node to notify when the feature change its value * @param feature feature to look * @return false if the feature is not handle by this node or disabled */ public boolean enableNotification(Feature feature){ if(!feature.isEnabled() || feature.getParentNode()!=this) return false; if(isEnableNotification(feature)) return true; BluetoothGattCharacteristic featureChar = getCorrespondingChar(feature); if(charCanBeNotify(featureChar)) { mNotifyFeature.add(feature); return changeNotificationStatus(featureChar, true); } return false; }//enableNotification
/** * unsubscribe the notification for the node update of the feature * @param feature feature that you want stop to be notify * @return false if the feature is not handle by this node or disabled */ public boolean disableNotification(Feature feature){ if(!feature.isEnabled() || feature.getParentNode()!=this) return false; BluetoothGattCharacteristic featureChar =getCorrespondingChar(feature); if(charCanBeNotify(featureChar)) { mNotifyFeature.remove(feature); //other things are send using that characateristic, so we don't have to //disable it if(characteristicsHasOtherEnabledFeatures(featureChar,feature)) return true; return changeNotificationStatus(featureChar,false); }// return false; }//disableNotification
return false; final BluetoothGattCharacteristic characteristic = getCorrespondingChar(feature); final BluetoothGattCharacteristic writeTo = mFeatureCommand != null ? mFeatureCommand : characteristic;