Пример #1
0
 public void ConnectBluetooth()
 {
     _bluetoothDevice.Connect();
 }
Пример #2
0
        void testConnect(BluetoothDevice btdev)
        {
            byte[] bta = new byte[8];
            bta[0] = 0x00;
            bta[1] = 0x00;
            bta[2] = 0x00;
            bta[3] = 0x06;
            bta[4] = 0x66;
            bta[5] = 0x03;
            bta[6] = 0x09;
            bta[7] = 0xE8;

            BluetoothDevice btd = btdev;// new BluetoothDevice("test", bta);

            System.Net.Sockets.NetworkStream nws;
            //first download the layout program
            byte[] buf;
            try
            {
                ddump("connecting to " + btd.AddressStr);
                nws = btd.Connect(StandardServices.SerialPortServiceGuid);
                if (nws == null)
                {
                    ddump("Connect failed!");
                    return;
                }
                buf = null;
                if (radioFP.Checked)
                {
                    buf = Encoding.Unicode.GetBytes(Intermec.Printer.Language.Fingerprint.Demo.FP_2_WalmartLabel());
                }
                else if (radioIPL.Checked)
                {
                    buf = Encoding.Unicode.GetBytes(Intermec.Printer.Language.Fingerprint.Demo.IPL_2_WalmartLabel());
                }
                if (buf == null)
                {
                    return;
                }
                ddump("writing 1...");
                nws.Write(buf, 0, buf.Length);
                ddump("...writing 1 done");

                if (nws.DataAvailable)
                {
                    ddump("reading...");
                    readData(nws);
                    ddump("...reading done");
                }

                ddump("closing net stream...");
                nws.Close();
                ddump("... net stream closed");
            }
            catch (System.IO.IOException ex)
            {
                ddump("Exception: " + ex.Message);
            }
            catch (System.Net.Sockets.SocketException ex)
            {
                ddump("Exception: " + ex.Message);
            }
            catch (Exception ex)
            {
                ddump("Exception: " + ex.Message);
            }
        }