Пример #1
0
        /// <summary>
        /// Connection to BT Device
        /// </summary>
        /// <param name="MacAddress"></param>
        /// <returns></returns>
        private async Task connectionTest(string MacAddress)
        {
            try
            {
                Bluetooth.BTConnection btpd = new Bluetooth.BTConnection();
                await btpd.ConnectToDevice(MacAddress);

                ///Test data t send Waiting for datasheet
                //byte[] data_to_send = new byte[] { 0X01, 0X02, 0X03 };
                //await btpd.Send_Data(data_to_send, 1, this.txtblkAddress.Text);
            }
            catch (BluetoothDeviceException ex)
            {
                MessageBox.Show(ex.Message.ToString() + "  " +  ex.HResult + "  " +ex.Message);
            }
        } 
Пример #2
0
        private async void Connection()
        {
            try
            {
                btpd = new BTConnection();
                await btpd.ConnectToDevice(Code.Stuff._MACADDRESS);
            }

            catch (Bluetooth.BluetoothDeviceException ex)
            {
                MessageBox.Show(ex.Message);
                Debug.WriteLine(ex.ToString());
                connected = false;
            }
            catch (Exception exxx)
            {
                Debug.WriteLine(exxx.ToString());
            }
            connected = true;
        }