C# - Bluetooth

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • LitaOsiris
    New Member
    • Jan 2008
    • 16

    C# - Bluetooth

    Hey everyone,

    Have a tough problem here I'm trying to solve but to no avail. Basically a program I'm doing on a handheld requires a connection to a printer via bluetooth. When everything is set up, it's all fine, everything works. However, when the handheld is switched off and switched back on, it loses the connection to the printer and so the only way to resolve this as I've found is to disable and then re-enable bluetooth. Obviously, customers do not want to be doing this.

    I have the printer being recognised by the bluetooth manager and the bluetooth printer option has the printer running on a port.

    So my question is, is there anyway to write something into my program to check for this?
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    Something like a try catch block might be easier. HTH.

    Comment

    • LitaOsiris
      New Member
      • Jan 2008
      • 16

      #3
      Hey everyone,

      The good news is that I found a solution to this problem.

      It requires using the Microsoft Embedded Source Tools found here and the InTheHand.Net library found here.

      This prompts the header: 'using Microsoft.Windo wsMobile.Shared Source.Bluetoot h;' which unfortunately disallows 'using InTheHand.Net.B luetooth;' but it allows the use of BluetoothRadio without the need for that bthutil.dll if you're using WinCE. The BluetoothRadio is all I needed to get this program working. The Microsoft.Windo wsMobile library does not support the Ports and Sockets feature that InTheHand.Net does so I am using a combination of both.

      Comment

      • LitaOsiris
        New Member
        • Jan 2008
        • 16

        #4
        The InTheHand library is actually found here.

        The InTheHand.Net.P ersonal.dll is needed.

        Comment

        • Block
          New Member
          • Mar 2008
          • 1

          #5
          Originally posted by LitaOsiris
          The InTheHand library is actually found here.

          The InTheHand.Net.P ersonal.dll is needed.

          Hi, I had try with the Microsoft mobile library in a Pocket PC with Windows CE 5.0 and I get the same error that you get with the InTheHand Library, here is my code:

          using Microsoft.Windo wsMobile.Shared Source.Bluetoot h;
          -----------------------------
          private BluetoothRadio PrimaryBTRadio = new BluetoothRadio( );

          private void button1_Click(o bject sender, EventArgs e)
          {

          PrimaryBTRadio. BluetoothRadioM ode = BluetoothRadioM ode.On;
          PrimaryBTRadio. BluetoothRadioM ode = BluetoothRadioM ode.Discoverabl e;

          }

          private void button3_Click(o bject sender, EventArgs e)
          {

          switch (PrimaryBTRadio .BluetoothRadio Mode)
          {

          case BluetoothRadioM ode.Off:

          this.textBox1.T ext = "Off";
          break;

          case BluetoothRadioM ode.On:

          this.textBox1.T ext = "On";
          break;

          case BluetoothRadioM ode.Discoverabl e:

          this.textBox1.T ext = "Discoverab le";
          break;

          }

          }

          private void button2_Click(o bject sender, EventArgs e)
          {

          PrimaryBTRadio. BluetoothRadioM ode = BluetoothRadioM ode.Off;

          }

          I hope that you can help with this problem: Can't find PInvoke DLL 'bthutil.dll'.

          Comment

          Working...