commit 4fda4a877617d5369216322854903c9b027e470c
Author: Toutance <toutance.dev@gmail.com>
Date:   Tue Aug 2 16:44:27 2022 +0200

    junk

diff --git a/.vs/TestBLE/v16/.suo b/.vs/TestBLE/v16/.suo
index 1158501..7873c73 100644
Binary files a/.vs/TestBLE/v16/.suo and b/.vs/TestBLE/v16/.suo differ
diff --git a/TestBLE/TestBLE.Android/Services/BluetoothService.cs b/TestBLE/TestBLE.Android/Services/BluetoothService.cs
index 3ac7ac2..12187ec 100644
--- a/TestBLE/TestBLE.Android/Services/BluetoothService.cs
+++ b/TestBLE/TestBLE.Android/Services/BluetoothService.cs
@@ -125,8 +125,6 @@ namespace TestBLE.Droid.Services
             }
         }
 
-        
-
         public EventHandler<string> DataReceivedEvent { get; set; }
         private string _bufferedData;
 
@@ -170,46 +168,6 @@ namespace TestBLE.Droid.Services
             }
         }
 
-        private void OnDataReceivedP(byte[] noEmptybuffer)
-        {
-            bufferedData += Encoding.UTF8.GetString(noEmptybuffer, 0, noEmptybuffer.Count());
-
-            if (bufferedData.Contains("\r\n"))
-            {
-                if (bufferedData.EndsWith("\r\n"))
-                {
-                    bufferedData = bufferedData.Replace("\r\n", "|");
-                    string[] datas = bufferedData.Split('|');
-                    foreach (var str in datas)
-                    {
-                        str.Replace('\x00'.ToString(), "");
-                        if (!string.IsNullOrWhiteSpace(str) && (str.Length > 0))
-                        {
-                            DataReceivedEvent?.Invoke(this, str);
-                            //FormsMessenger.Send (new TagMessage (str), this);
-                        }
-                    }
-
-                    bufferedData = "";
-                }
-                else
-                {
-                    bufferedData = bufferedData.Replace("\r\n", "|");
-                    string[] datas = bufferedData.Split('|');
-                    for (int i = 0; i < datas.Count() - 1; i++)
-                    {
-                        if (!string.IsNullOrEmpty(datas[i]))
-                        {
-                            DataReceivedEvent?.Invoke(this, datas[i]);
-                            //FormsMessenger.Send (new TagMessage (datas [i]), this);
-                        }
-                    }
-
-                    bufferedData = datas[datas.Count() - 1];
-                }
-            }
-        }
-
         private void ScanFinished(object sender, string e)
         {
             scanCompletionSource?.SetResult(true);
@@ -260,18 +218,15 @@ namespace TestBLE.Droid.Services
             return ret;
         }
 
-        public Task<bool> SendHexValues(string[] hexValues)
+        public Task<bool> SendHexValues(byte[] hexValues)
         {
-            byte[] data = new byte[hexValues.Length];
-
             if (socket.IsConnected == false)
             {
                 return Task.FromResult(false);
             } else
             {
-                data = hexValuesToByteArray(hexValues);
                 // Envoi de la commande
-                socket.OutputStream.Write(data, 0, hexValues.Length);
+                socket.OutputStream.Write(hexValues, 0, hexValues.Length);
                 socket.OutputStream.Flush();
             }
 
diff --git a/TestBLE/TestBLE.Android/bin/Debug/TestBLE.Android.dll b/TestBLE/TestBLE.Android/bin/Debug/TestBLE.Android.dll
index e653701..7e6778d 100644
Binary files a/TestBLE/TestBLE.Android/bin/Debug/TestBLE.Android.dll and b/TestBLE/TestBLE.Android/bin/Debug/TestBLE.Android.dll differ
diff --git a/TestBLE/TestBLE.Android/bin/Debug/TestBLE.Android.pdb b/TestBLE/TestBLE.Android/bin/Debug/TestBLE.Android.pdb
index 05b0383..51abc42 100644
Binary files a/TestBLE/TestBLE.Android/bin/Debug/TestBLE.Android.pdb and b/TestBLE/TestBLE.Android/bin/Debug/TestBLE.Android.pdb differ
diff --git a/TestBLE/TestBLE.Android/bin/Debug/TestBLE.dll b/TestBLE/TestBLE.Android/bin/Debug/TestBLE.dll
index aa6cf12..6f08de0 100644
Binary files a/TestBLE/TestBLE.Android/bin/Debug/TestBLE.dll and b/TestBLE/TestBLE.Android/bin/Debug/TestBLE.dll differ
diff --git a/TestBLE/TestBLE.Android/bin/Debug/TestBLE.pdb b/TestBLE/TestBLE.Android/bin/Debug/TestBLE.pdb
index afe7aab..a08e229 100644
Binary files a/TestBLE/TestBLE.Android/bin/Debug/TestBLE.pdb and b/TestBLE/TestBLE.Android/bin/Debug/TestBLE.pdb differ
diff --git a/TestBLE/TestBLE.Android/bin/Debug/com.companyname.testble.apk b/TestBLE/TestBLE.Android/bin/Debug/com.companyname.testble.apk
deleted file mode 100644
index 534388a..0000000
Binary files a/TestBLE/TestBLE.Android/bin/Debug/com.companyname.testble.apk and /dev/null differ
diff --git a/TestBLE/TestBLE.Android/obj/Debug/110/TestBLE.Android.csproj.AssemblyReference.cache b/TestBLE/TestBLE.Android/obj/Debug/110/TestBLE.Android.csproj.AssemblyReference.cache
index 0a417ad..cbf0f87 100644
Binary files a/TestBLE/TestBLE.Android/obj/Debug/110/TestBLE.Android.csproj.AssemblyReference.cache and b/TestBLE/TestBLE.Android/obj/Debug/110/TestBLE.Android.csproj.AssemblyReference.cache differ
diff --git a/TestBLE/TestBLE.Android/obj/Debug/110/TestBLE.Android.dll b/TestBLE/TestBLE.Android/obj/Debug/110/TestBLE.Android.dll
index e653701..7e6778d 100644
Binary files a/TestBLE/TestBLE.Android/obj/Debug/110/TestBLE.Android.dll and b/TestBLE/TestBLE.Android/obj/Debug/110/TestBLE.Android.dll differ
diff --git a/TestBLE/TestBLE.Android/obj/Debug/110/TestBLE.Android.pdb b/TestBLE/TestBLE.Android/obj/Debug/110/TestBLE.Android.pdb
index 05b0383..51abc42 100644
Binary files a/TestBLE/TestBLE.Android/obj/Debug/110/TestBLE.Android.pdb and b/TestBLE/TestBLE.Android/obj/Debug/110/TestBLE.Android.pdb differ
diff --git a/TestBLE/TestBLE.Android/obj/Debug/110/_TelemetryProps b/TestBLE/TestBLE.Android/obj/Debug/110/_TelemetryProps
index 390d968..463768d 100644
--- a/TestBLE/TestBLE.Android/obj/Debug/110/_TelemetryProps
+++ b/TestBLE/TestBLE.Android/obj/Debug/110/_TelemetryProps
@@ -22,7 +22,7 @@ CodegenTarget=
 AndroidDexTool=d8
 AndroidLinkTool=
 AndroidEnableProfiledAot=
-AndroidInstallAfterBuild=False
-AndroidSessionId=
+AndroidInstallAfterBuild=True
+AndroidSessionId=bd18f6e1-ac31-4cd1-a87a-7f35fc9fe283
 BuildConfiguration=Debug
 TemplateName={c9e5eea5-ca05-42a1-839b-61506e0a37df}
diff --git a/TestBLE/TestBLE.Android/obj/Debug/110/android/assets/TestBLE.Android.dll b/TestBLE/TestBLE.Android/obj/Debug/110/android/assets/TestBLE.Android.dll
index e653701..7e6778d 100644
Binary files a/TestBLE/TestBLE.Android/obj/Debug/110/android/assets/TestBLE.Android.dll and b/TestBLE/TestBLE.Android/obj/Debug/110/android/assets/TestBLE.Android.dll differ
diff --git a/TestBLE/TestBLE.Android/obj/Debug/110/android/assets/TestBLE.Android.pdb b/TestBLE/TestBLE.Android/obj/Debug/110/android/assets/TestBLE.Android.pdb
index 05b0383..51abc42 100644
Binary files a/TestBLE/TestBLE.Android/obj/Debug/110/android/assets/TestBLE.Android.pdb and b/TestBLE/TestBLE.Android/obj/Debug/110/android/assets/TestBLE.Android.pdb differ
diff --git a/TestBLE/TestBLE.Android/obj/Debug/110/android/assets/TestBLE.dll b/TestBLE/TestBLE.Android/obj/Debug/110/android/assets/TestBLE.dll
index aa6cf12..6f08de0 100644
Binary files a/TestBLE/TestBLE.Android/obj/Debug/110/android/assets/TestBLE.dll and b/TestBLE/TestBLE.Android/obj/Debug/110/android/assets/TestBLE.dll differ
diff --git a/TestBLE/TestBLE.Android/obj/Debug/110/android/assets/TestBLE.pdb b/TestBLE/TestBLE.Android/obj/Debug/110/android/assets/TestBLE.pdb
index afe7aab..a08e229 100644
Binary files a/TestBLE/TestBLE.Android/obj/Debug/110/android/assets/TestBLE.pdb and b/TestBLE/TestBLE.Android/obj/Debug/110/android/assets/TestBLE.pdb differ
diff --git a/TestBLE/TestBLE/Models/TeoBluetoothCommands.cs b/TestBLE/TestBLE/Models/TeoBluetoothCommands.cs
index 07f1f9a..bb123fc 100644
--- a/TestBLE/TestBLE/Models/TeoBluetoothCommands.cs
+++ b/TestBLE/TestBLE/Models/TeoBluetoothCommands.cs
@@ -6,7 +6,7 @@ namespace TestBLE.Models
 {
     public static class TeoBluetoothCommand
     {
-        public enum AvailableCommands
+        public enum CommandType
         {
             // Voir documentation TEO INRAE 
             // Codes ASCII
@@ -25,7 +25,8 @@ namespace TestBLE.Models
             EmissionPoids
         }
 
-        public static byte[] GetCommand(AvailableCommands c)
+        // Retourne la chaine d'octets d'une commande Teo (prog INRAE)
+        public static byte[] GetCommandCode(CommandType c)
         {
             // Les commandes envoyées sont sur 3 octets
             byte[] ret = new byte[3];
@@ -37,54 +38,121 @@ namespace TestBLE.Models
             // Commande
             switch (c)
             {
-                case AvailableCommands.ModeOrdre:
+                case CommandType.ModeOrdre:
                     ret[1] = 0x61; 
                     break;
 
-                case AvailableCommands.SortieOrdreGardeBluetooth:
+                case CommandType.SortieOrdreGardeBluetooth:
                     ret[1] = 0x6B; 
                     break;
 
-                case AvailableCommands.SortieOrdreEtBluetooth:
+                case CommandType.SortieOrdreEtBluetooth:
                     ret[1] = 0x67; 
                     break;
 
-                case AvailableCommands.ModePeseeSimple:
+                case CommandType.ModePeseeSimple:
                     ret[1] = 0x62; 
                     break;
 
-                case AvailableCommands.SortiePeseeSimple:
+                case CommandType.SortiePeseeSimple:
                     ret[1] = 0x65; 
                     break;
 
-                case AvailableCommands.TareP1:
+                case CommandType.TareP1:
                     ret[1] = 0x74; 
                     break;
 
-                case AvailableCommands.TareP2:
+                case CommandType.TareP2:
                     ret[1] = 0x6A; 
                     break;
 
-                case AvailableCommands.ZeroP1:
+                case CommandType.ZeroP1:
                     ret[1] = 0x7A; 
                     break;
 
-                case AvailableCommands.ZeroP2:
+                case CommandType.ZeroP2:
                     ret[1] = 0x64; 
                     break;
 
-                case AvailableCommands.InfosMetrologie:
+                case CommandType.InfosMetrologie:
                     ret[1] = 0x73; 
                     break;
 
-                case AvailableCommands.EmissionPoids:
+                case CommandType.EmissionPoids:
                     ret[1] = 0x63; 
                     break;
                 // TODO
-                case AvailableCommands.PeseeStabilisee:
+                case CommandType.PeseeStabilisee:
                     break;
 
-                case AvailableCommands.InterrompPS:
+                case CommandType.InterrompPS:
+                    break;
+
+                default:
+                    break;
+            }
+            return ret;
+        }
+
+        // Retourne le nom d'une commande Teo (prog INRAE)
+        public static string GetCommandName(CommandType c)
+        {
+            // Les commandes envoyées sont sur 3 octets
+            string ret = "";
+
+            // Commande
+            switch (c)
+            {
+                case CommandType.ModeOrdre:
+                    ret = "Mode attente ordre";
+                    break;
+
+                case CommandType.SortieOrdreGardeBluetooth:
+                    ret = "Sortie mode ordre";
+                    break;
+
+                case CommandType.SortieOrdreEtBluetooth:
+                    ret = "Sortie mode ordre & couper bluetooth";
+                    break;
+
+                case CommandType.ModePeseeSimple:
+                    ret = "Mode simple pesage";
+                    break;
+
+                case CommandType.SortiePeseeSimple:
+                    ret = "Sortie mode simple pesage";
+                    break;
+
+                case CommandType.TareP1:
+                    ret = "Tare plateau 1";
+                    break;
+
+                case CommandType.TareP2:
+                    ret = "Tare plateau 2";
+                    break;
+
+                case CommandType.ZeroP1:
+                    ret = "Zero plateau 1";
+                    break;
+
+                case CommandType.ZeroP2:
+                    ret = "Zero plateau 2";
+                    break;
+
+                case CommandType.InfosMetrologie:
+                    ret = "Informations métrologie";
+                    break;
+
+                case CommandType.EmissionPoids:
+                    ret = "Emission poids";
+                    break;
+                // TODO
+                case CommandType.PeseeStabilisee:
+                    ret = "Pesée stabilisée - NON implémenté";
+                    break;
+
+                case CommandType.InterrompPS:
+                    ret = "STOP Pesée stabilisée - NON implémenté";
                     break;
 
                 default:
diff --git a/TestBLE/TestBLE/Services/IBluetoothService.cs b/TestBLE/TestBLE/Services/IBluetoothService.cs
index 32c35ef..a990be4 100644
--- a/TestBLE/TestBLE/Services/IBluetoothService.cs
+++ b/TestBLE/TestBLE/Services/IBluetoothService.cs
@@ -13,7 +13,7 @@ namespace TestBLE.Services
         Task<bool> Pair(BTDevice bluetoothDevice);
         Task<bool> Connect(BTDevice bluetoothDevice);
         Task<bool> Disconnect(BTDevice bluetoothDevice);
-        Task<bool> SendHexValues(string[] hexValues);
+        Task<bool> SendHexValues(byte[] hexValues);
         ICollection<BTDevice> GetBondedDevices();
         EventHandler<string> DataReceivedEvent { get; set; }
         ObservableCollection<BTDevice> DeviceList { get; set; }
diff --git a/TestBLE/TestBLE/ViewModels/CommandItemViewModel.cs b/TestBLE/TestBLE/ViewModels/CommandItemViewModel.cs
index 59caf9f..541fdfa 100644
--- a/TestBLE/TestBLE/ViewModels/CommandItemViewModel.cs
+++ b/TestBLE/TestBLE/ViewModels/CommandItemViewModel.cs
@@ -1,5 +1,6 @@
 ﻿using System.Threading.Tasks;
 using System.Windows.Input;
+using TestBLE.Models;
 using TestBLE.Services;
 using Xamarin.Forms;
 
@@ -10,12 +11,12 @@ namespace TestBLE.ViewModels
         public IBluetoothService BluetoothService { get; set; }
 
         private string name;
-        private string[] values;
+        private TeoBluetoothCommand.CommandType toSendCommand;
 
-        public string[] Values
+        public TeoBluetoothCommand.CommandType ToSendCommand
         {
-            get { return values; }
-            set { SetProperty( ref values, value); }
+            get { return toSendCommand; }
+            set { SetProperty( ref toSendCommand, value); }
         }
 
         public string Name
@@ -26,14 +27,15 @@ namespace TestBLE.ViewModels
 
         private async Task<bool> SendValue()
         {
-            await BluetoothService.SendHexValues(values);
+            await BluetoothService.SendHexValues(TeoBluetoothCommand.GetCommandCode(ToSendCommand));
             return true;
         }
 
         public ICommand SendValueCommand { private set; get; }
 
-        public CommandItemViewModel()
+        public CommandItemViewModel(TeoBluetoothCommand.CommandType cmd)
         {
+            Name = TeoBluetoothCommand.GetCommandName(cmd);
             BluetoothService = DependencyService.Get<IBluetoothService>();
             SendValueCommand = new Command(async () => await SendValue());
         }
diff --git a/TestBLE/TestBLE/ViewModels/DeviceViewModel.cs b/TestBLE/TestBLE/ViewModels/DeviceViewModel.cs
index 56fb89a..185c6ae 100644
--- a/TestBLE/TestBLE/ViewModels/DeviceViewModel.cs
+++ b/TestBLE/TestBLE/ViewModels/DeviceViewModel.cs
@@ -7,6 +7,7 @@ using System.Windows.Input;
 using TestBLE.Models;
 using TestBLE.Services;
 using Xamarin.Forms;
+using static TestBLE.Models.TeoBluetoothCommand;
 
 namespace TestBLE.ViewModels
 {
@@ -24,7 +25,6 @@ namespace TestBLE.ViewModels
             set { SetProperty(ref isVisibleData, value); }
         }
 
-
         public bool IsConnected
         {
             get { return isConnected; }
@@ -37,7 +37,6 @@ namespace TestBLE.ViewModels
             set { SetProperty(ref device, value); }
         }
 
-
         public string Data
         {
             get { return data; }
@@ -67,16 +66,10 @@ namespace TestBLE.ViewModels
 
             // Ajout manuel des commandes
             AvailableCommandsList = new ObservableCollection<CommandItemViewModel>();
-            AvailableCommandsList.Add(new CommandItemViewModel()
+            foreach (CommandType _cmd in Enum.GetValues(typeof(CommandType))
             {
-                Name = "Mode ordre",
-                Values = new string[] { "02", "61", "0D" }
-            });
-            AvailableCommandsList.Add(new CommandItemViewModel()
-            {
-                Name = "Lancer pesée",
-                Values = new string[] { "02", "63", "0D" }
-            });
+
+            }
         }
 
         ~DeviceViewModel()
diff --git a/TestBLE/TestBLE/Views/DeviceView.xaml b/TestBLE/TestBLE/Views/DeviceView.xaml
index 2534918..298c8d1 100644
--- a/TestBLE/TestBLE/Views/DeviceView.xaml
+++ b/TestBLE/TestBLE/Views/DeviceView.xaml
@@ -61,16 +61,17 @@
                             Color="#4f5a64" />
                         <StackLayout
                             x:Name="commandsList"
-                            Padding="0,15"
+                            Margin="0,10"
+                            Padding="0"
                             BindableLayout.ItemsSource="{Binding AvailableCommandsList}"
                             HorizontalOptions="FillAndExpand"
                             IsVisible="{Binding IsConnected}"
                             Orientation="Vertical"
-                            Spacing="10">
+                            Spacing="0">
                             <BindableLayout.ItemTemplate>
                                 <DataTemplate>
                                     <StackLayout
-                                        Margin="0"
+                                        Padding="0,5"
                                         xe:Commands.Tap="{Binding SendValueCommand}"
                                         xe:TouchEffect.Color="#34a9ff"
                                         Spacing="0">
@@ -79,12 +80,6 @@
                                             HorizontalTextAlignment="Center"
                                             Text="{Binding Name}"
                                             TextColor="White" />
-                                        <Label
-                                            FontAttributes="Italic"
-                                            FontSize="12"
-                                            HorizontalTextAlignment="Center"
-                                            Text="{Binding Values}"
-                                            TextColor="DarkGray" />
                                     </StackLayout>
                                 </DataTemplate>
                             </BindableLayout.ItemTemplate>
diff --git a/TestBLE/TestBLE/bin/Debug/netstandard2.0/TestBLE.dll b/TestBLE/TestBLE/bin/Debug/netstandard2.0/TestBLE.dll
index aa6cf12..6f08de0 100644
Binary files a/TestBLE/TestBLE/bin/Debug/netstandard2.0/TestBLE.dll and b/TestBLE/TestBLE/bin/Debug/netstandard2.0/TestBLE.dll differ
diff --git a/TestBLE/TestBLE/bin/Debug/netstandard2.0/TestBLE.pdb b/TestBLE/TestBLE/bin/Debug/netstandard2.0/TestBLE.pdb
index afe7aab..a08e229 100644
Binary files a/TestBLE/TestBLE/bin/Debug/netstandard2.0/TestBLE.pdb and b/TestBLE/TestBLE/bin/Debug/netstandard2.0/TestBLE.pdb differ
diff --git a/TestBLE/TestBLE/bin/Debug/netstandard2.0/ref/TestBLE.dll b/TestBLE/TestBLE/bin/Debug/netstandard2.0/ref/TestBLE.dll
index e49fe7b..b63d368 100644
Binary files a/TestBLE/TestBLE/bin/Debug/netstandard2.0/ref/TestBLE.dll and b/TestBLE/TestBLE/bin/Debug/netstandard2.0/ref/TestBLE.dll differ
diff --git a/TestBLE/TestBLE/obj/Debug/netstandard2.0/TestBLE.dll b/TestBLE/TestBLE/obj/Debug/netstandard2.0/TestBLE.dll
index aa6cf12..6f08de0 100644
Binary files a/TestBLE/TestBLE/obj/Debug/netstandard2.0/TestBLE.dll and b/TestBLE/TestBLE/obj/Debug/netstandard2.0/TestBLE.dll differ
diff --git a/TestBLE/TestBLE/obj/Debug/netstandard2.0/TestBLE.pdb b/TestBLE/TestBLE/obj/Debug/netstandard2.0/TestBLE.pdb
index afe7aab..a08e229 100644
Binary files a/TestBLE/TestBLE/obj/Debug/netstandard2.0/TestBLE.pdb and b/TestBLE/TestBLE/obj/Debug/netstandard2.0/TestBLE.pdb differ
diff --git a/TestBLE/TestBLE/obj/Debug/netstandard2.0/ref/TestBLE.dll b/TestBLE/TestBLE/obj/Debug/netstandard2.0/ref/TestBLE.dll
index e49fe7b..b63d368 100644
Binary files a/TestBLE/TestBLE/obj/Debug/netstandard2.0/ref/TestBLE.dll and b/TestBLE/TestBLE/obj/Debug/netstandard2.0/ref/TestBLE.dll differ
