Skip to content
Snippets Groups Projects
Commit 4bd46f05 authored by MAUGEZ Emeline's avatar MAUGEZ Emeline
Browse files

Ajout de la characteristic add cocktail

parent 6c00932b
No related branches found
No related tags found
No related merge requests found
......@@ -74,6 +74,7 @@ public class DeviceControl {
public BluetoothGattCharacteristic BDIngredientsCharacteristic;
public BluetoothGattCharacteristic MajIngredientsCharacteristic;
public BluetoothGattCharacteristic AjouterIngredientCharacteristic;
public BluetoothGattCharacteristic AddCocktailCharacteristic;
DeviceControl(Context c, String deviceName, String deviceAddress) {
......@@ -177,13 +178,24 @@ public class DeviceControl {
}
}
public void writeOnAddCocktail(String data){
if (AddCocktailCharacteristic!=null){
AddCocktailCharacteristic.setValue(data);
mBluetoothLeService.writeCharacteristic(AddCocktailCharacteristic);
}
else{
Log.d("Characteristic", "AddCocktailCharacteristic is nuuuuuuuuuuuuull");
onError();
}
}
public void writeOnMajIngredientsCharacteristic(String data){
if (MajIngredientsCharacteristic !=null){
MajIngredientsCharacteristic.setValue(data);
boolean res =mBluetoothLeService.writeCharacteristic(MajIngredientsCharacteristic);
}
else{
Log.d("RXCharacterisitic", "nuuuuuuuuuuuuull");
Log.d("Characteristic", "MajIngredientsCharacteristic is nuuuuuuuuuuuuull");
onError();
}
}
......@@ -194,7 +206,7 @@ public class DeviceControl {
boolean res =mBluetoothLeService.writeCharacteristic(AjouterIngredientCharacteristic);
}
else{
Log.d("RXCharacterisitic", "nuuuuuuuuuuuuull");
Log.d("Characteristic", "AjouterIngredientCharacteristic is nuuuuuuuuuuuuull");
onError();
}
}
......@@ -212,7 +224,7 @@ public class DeviceControl {
boolean res =mBluetoothLeService.writeCharacteristic(CommanderCocktailCharacterisitic);
}
else{
Log.d("RXCharacterisitic", "nuuuuuuuuuuuuull");
Log.d("Characterisitic", "CommanderCocktailCharacteristic is nuuuuuuuuuuuuull");
onError();
}
}
......@@ -301,6 +313,9 @@ public class DeviceControl {
if(uuid.equals(SampleGattAttributes.AJOUTER_INGREDIENT_CHARACTERISTIC)){
AjouterIngredientCharacteristic = gattCharacteristic;
}
if(uuid.equals(SampleGattAttributes.ADD_COCKTAIL_CHARACTERISTIC)){
AddCocktailCharacteristic = gattCharacteristic;
}
currentCharaData.put(
LIST_NAME, SampleGattAttributes.lookup(uuid, unknownCharaString));
currentCharaData.put(LIST_UUID, uuid);
......
......@@ -32,6 +32,7 @@ public class SampleGattAttributes {
//TODO changer les uuids
public static String AJOUTER_INGREDIENT_CHARACTERISTIC ="6e4a0009-b5a3-f393-e0a9-e50e24dcca9e";
public static String MAJ_INGREDIENT_CHARACTERISTIC ="6e4a0010-b5a3-f393-e0a9-e50e24dcca9e";
public static String ADD_COCKTAIL_CHARACTERISTIC = "6e4a0007-b5a3-f393-e0a9-e50e24dcca9e";
......@@ -50,6 +51,9 @@ public class SampleGattAttributes {
attributes.put(BD_RECETTES_CHARACTERISTIC, "Liste cocktails");
attributes.put(COMMANDER_COCKTAIL_CHARACTERISTIC, "Commander Cocktail");
attributes.put(BD_INGREDIENTS_CHARACTERISTIC, "Liste ingrédients");
attributes.put(AJOUTER_INGREDIENT_CHARACTERISTIC, "Ajouter ingrédient");
attributes.put(MAJ_INGREDIENT_CHARACTERISTIC,"Mis-à-jour des ingrédients");
attributes.put(ADD_COCKTAIL_CHARACTERISTIC, "Ajouter cocktail");
}
......
......@@ -91,7 +91,7 @@ public class Recettes {
msg = msg.substring(0, msg.length() - 1);
Log.d("Ajouter Recette", msg);
DeviceControl dc = DeviceControl.getInstance();
//todo dc. writeOnAddCocktail(msg)
dc.writeOnAddCocktail(msg);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment