예제 #1
0
        async void AggiornaStato()
        {
            bool connesso = false;

            if (GattServer != null)
            {
                connesso = GattServer.State == ConnectionState.Connected;

                // Aggiorna visualizzazione stato connessione;
                GestioneStatoConnessione(connesso);

                if (connesso)
                {
                    try
                    {
                        int sliderValore = Convert.ToInt32(slValore.Value);

                        if (sliderValore != oldSliderValue)
                        {
                            oldSliderValue = sliderValore;

                            // Spedisce il valore dello slider
                            byte[] bufferDaSpedire = BitConverter.GetBytes(sliderValore);

                            var result = await GattServer.WriteCharacteristicValue(
                                serviceGuid, sliderGuid,
                                bufferDaSpedire
                                );
                        }
                    }
                    catch (Exception errore)
                    {
                        Debug.WriteLine(errore.ToString());
                    }
                }
            }
        }
예제 #2
0
 async void OnSuClicked(object sender, System.EventArgs e)
        {

            potenza = potenza + 1;

            try
            {
                int sliderValore = Convert.ToInt32(77777777);



                // Spedisce il valore dello slider
                byte[] bufferDaSpedire = BitConverter.GetBytes(sliderValore);

                var result = await GattServer.WriteCharacteristicValue(
                    serviceGuid, sliderGuid,
                    bufferDaSpedire
                );

            }
            catch (Exception errore)
            {
                Debug.WriteLine(errore.ToString());
            }
        }

        async void OnGiuClicked(object sender, System.EventArgs e)
        {

            potenza = potenza - 1;

            try
            {
                int sliderValore = Convert.ToInt32(44444444);



                // Spedisce il valore dello slider
                byte[] bufferDaSpedire = BitConverter.GetBytes(sliderValore);

                var result = await GattServer.WriteCharacteristicValue(
                    serviceGuid, sliderGuid,
                    bufferDaSpedire
                );

            }
            catch (Exception errore)
            {
                Debug.WriteLine(errore.ToString());
            }
        }