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

On recoit cocktail finit à la fin de chaque commande

parent f24f334c
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,7 @@ package com.example.robotise.ble;
import static com.example.robotise.ble.SampleGattAttributes.BD_INGREDIENTS_CHARACTERISTIC;
import static com.example.robotise.ble.SampleGattAttributes.BD_RECETTES_CHARACTERISTIC;
import static com.example.robotise.ble.SampleGattAttributes.COMMANDER_COCKTAIL_CHARACTERISTIC;
import android.Manifest;
......@@ -374,7 +375,8 @@ public class BluetoothLeService extends Service {
Log.d("CharacNotif", "here");
// This is specific to Heart Rate Measurement.
if (BD_RECETTES_CHARACTERISTIC.equals(characteristic.getUuid().toString())||
BD_INGREDIENTS_CHARACTERISTIC.equals(characteristic.getUuid().toString())) {
BD_INGREDIENTS_CHARACTERISTIC.equals(characteristic.getUuid().toString()) ||
COMMANDER_COCKTAIL_CHARACTERISTIC.equals(characteristic.getUuid().toString())) {
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(
UUID.fromString(SampleGattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
......
......@@ -38,6 +38,7 @@ import androidx.core.app.ActivityCompat;
import com.example.robotise.control.AdminActivity;
import com.example.robotise.control.AdminMajListIngredientActivity;
import com.example.robotise.model.Ingredients;
import com.example.robotise.model.Recettes;
import java.util.ArrayList;
......@@ -181,6 +182,16 @@ public class DeviceControl {
mBluetoothLeService.setCharacteristicNotification(
BDIngredientsCharacteristic, false);
}
else if (uuid.equals(CommanderCocktailCharacterisitic.getUuid().toString())){
//Ingredients.getInstance().MiseAJour(data, mContext);
mNotifyCharacteristic = null;
mBluetoothLeService.setCharacteristicNotification(
CommanderCocktailCharacterisitic, false);
Toast.makeText(mContext, "Votre cocktail est terminé", Toast.LENGTH_LONG).show();
Log.d("Cocktail", "Bien Recu");
}
}
public void writeOnAddCocktail(String data){
......@@ -225,8 +236,19 @@ public class DeviceControl {
}
mBluetoothLeService.readCharacteristic(RXCharacterisitic);*/
if (CommanderCocktailCharacterisitic !=null){
mNotifyCharacteristic = CommanderCocktailCharacterisitic;
mBluetoothLeService.setCharacteristicNotification(
CommanderCocktailCharacterisitic, true);
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
e.printStackTrace();
}
CommanderCocktailCharacterisitic.setValue(data);
boolean res =mBluetoothLeService.writeCharacteristic(CommanderCocktailCharacterisitic);
Log.d("Réponse au write", String.valueOf(res));
}
else{
Log.d("Characterisitic", "CommanderCocktailCharacteristic is nuuuuuuuuuuuuull");
......
......@@ -26,7 +26,7 @@ public class SampleGattAttributes {
public static String HEART_RATE_MEASUREMENT = "00002a37-0000-1000-8000-00805f9b34fb";
public static String CLIENT_CHARACTERISTIC_CONFIG = "00002902-0000-1000-8000-00805f9b34fb";
public static String BD_RECETTES_CHARACTERISTIC ="6e4a0004-b5a3-f393-e0a9-e50e24dcca9e";
public static String COMMANDER_COCKTAIL_CHARACTERISTIC ="6e4a0007-b5a3-f393-e0a9-e50e24dcca9e";
public static String OLD_COMMANDER_COCKTAIL_CHARACTERISTIC ="6e4a0007-b5a3-f393-e0a9-e50e24dcca9e";
public static String BD_INGREDIENTS_CHARACTERISTIC = "6e4a0002-b5a3-f393-e0a9-e50e24dcca9e";
public static String BD_QUANTITE_MACHINE_CHARACTERISTIC = "6e4a0003-b5a3-f393-e0a9-e50e24dcca9e";
//TODO changer les uuids
......@@ -34,6 +34,8 @@ public class SampleGattAttributes {
public static String MAJ_INGREDIENT_CHARACTERISTIC ="6e4a0010-b5a3-f393-e0a9-e50e24dcca9e";
public static String ADD_COCKTAIL_CHARACTERISTIC = "6e4a0011-b5a3-f393-e0a9-e50e24dcca9e";
public static String COMMANDER_COCKTAIL_CHARACTERISTIC ="6e4a0012-b5a3-f393-e0a9-e50e24dcca9e";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment