Exemple #1
0
        /// <summary>
        /// Event called when beacon 3 data read
        /// </summary>
        /// <param name="sender">Sender</param>
        /// <param name="e">Event args indicating success and containing data</param>
        private void Beacon3ReadEvent(object sender, CharacteristicReadEventArgs e)
        {
            if (e.Success && e.Data.Length > 0)
            {
                Debug.WriteLine("Length of Uri Beacon Data: {0}", e.Data[0]);

                // Try writing to the Eddystone data
                //
                string testData      = "Test Write";
                char[] testDataChars = testData.ToCharArray();
                byte[] testDataBytes = Encoding.ASCII.GetBytes(testDataChars);

                var writeResult = _ble.WriteCharacteristic(SERVICE_FOR_EDDYSTONE, CHARACTERISTIC_FOR_URI_BEACON1, testDataBytes, EddystoneWriteEvent);
            }
            else
            {
                Application.Current.MainPage.DisplayAlert("ERROR", string.Format("Error reading beacon 3: {0}", e.Message), "Close");
                _ = DisconnectDevice();
            }
        }