test Console app - widcomm BT stack

Topics: Bluetooth - Other, Bluetooth - Widcomm/Broadcom
Feb 20, 2012 at 9:48 AM

Below is code I have cut and pasted to see if I can get a connection to the BT scanner I wish to capture scanned barcodes from.

I am now at a bit of a loss as to where to go/ what to do.

Also note the OBLEX lines are commented out due to them giving me errors otherwise I don't believe I need to use OBLEX but then I'm walking blind with BT at present.

My ultimate aim is to...

Have this program loop every N minutes or seconds looking for a connection (this I believe I can do with code I have here by including a sleep N statement.

Once a connection has been established to pass commands across to the scanner to draw down the data residing on the scanner.

I have got this exact program working against a USB version of this scanner - Opticon 2001and I am now wanting to access the Opticon 2002 version. I believe I', not too far away from success.

any help would be great, In the mean time I shall go a have a fiddle to see if I can get this to display some details (I see when I'm stepping through the details of Mfg name etc).






using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using InTheHand.Net.Bluetooth;
using InTheHand.Net.Sockets;

namespace ConsoleApplication1
    class Program
        static void Main(string[] args)

         static void Test3()
                    if (!BluetoothRadio.IsSupported)

                        Console.WriteLine("No Bluetooth Available... did you forget the dongle?");Console.ReadKey();


                    if (BluetoothRadio.PrimaryRadio.Mode == RadioMode.PowerOff)
                        BluetoothRadio.PrimaryRadio.Mode = RadioMode.Connectable;

                    Console.WriteLine("------------ My Information ------------");
                    Console.WriteLine("Radio Name: {0}", BluetoothRadio.PrimaryRadio.Name.ToString());

                    Console.WriteLine("Radio Mode: {0}", BluetoothRadio.PrimaryRadio.Mode.ToString());

                    BluetoothClient me = new BluetoothClient();
                    BluetoothDeviceInfo[] devices = me.DiscoverDevices();foreach (BluetoothDeviceInfo device in devices)


at device.update i get thrown to the catch part of code.

I do have the scanner connected, com port 13 is for incoming data and comm 15 is for outgoing traffic.

I'd like to know WHY I'm being chucked down - is it because of the WIDCOMM BT stack and not having the library referenced?


                        Console.WriteLine("---------- Device Found -------------");

                        Console.WriteLine("Device Name: {0}", device.DeviceName);
                        Console.WriteLine("Last Used: {0}", device.LastUsed);

                            // Authenticate with the device
                        if (!device.Authenticated)

                               // Use pin "0000" for authentication
                            if (!BluetoothSecurity.PairRequest(device.DeviceAddress, "0000"))
                                Console.WriteLine("Request failed");

                        device.SetServiceState(BluetoothService.ObexObjectPush, true);

                        Uri uri = new Uri("obex://" + device.DeviceAddress + "/test.jpg");

                  //      ObexWebRequest req = new ObexWebRequest(uri);
                  //      req.ReadFile(@"C:\Users\paniza\Pictures\text.jpg");

                 //       ObexWebResponse rsp = (ObexWebResponse)req.GetResponse();
                 //       Console.WriteLine("-------------------------------------");



                catch (Exception ex)


Feb 24, 2012 at 12:44 AM

So is this a different situation to your other question thread or the same?

Feb 24, 2012 at 6:57 AM

Hi Alan,

My initial issue was related to trying to get trying to get a sample from the downloaded zip file to actually work after converting them to VS2010.

So this is now an entiry new matter

Now after copying the Broadcomm/Widcomm DLL's from the Broadcomm directory into the project directory I was able to get the SDP Desktop browser to run.

Now I've copied a console app and am now trying to read & write to console data but the code I've posted crashes at drive.update.

As another issue I will be needing to communicate with the scanner with the Opticon .net DLL which works on a comport numbers.


Now as an aside I have just read another posting - http://32feet.codeplex.com/discussions/341045 and have had a look in my registry and see this....

\Device\BtPort0    REG_SZ     COM13

\Device\BtPort1    REG_SZ     COM15

So I'm wanting to know now if i search the registry for the text could i pull out the com ports that I could try and make connection on?

I will ultimately be making the connections via the scanner (making it the master) and my app would be running a continuous loop.

what I'm thinking of is something similar to what I do with the USB scanner version and that is...

every 45 seconds I scan all com ports, Loop round looking for the word Opticon, If it's found I then drop to the code to enable me to download the stored barcodes, saving that data to text a file.

So what I'd do is to access the registry, looking for the \Device\BtPort text and then trying those ports to see if i get a connection with the Opticon code I have.

But would like you're input on this. It is my belief that their would be only ONE scanner linked to the PC at any given time but how would my approach work if their was suddenly two or three attached at the same time?

appreciate you're thoughts on this. also on the matter of the Opticon code needing a port address eg com3 so it can communicate with the scanner.



Mar 2, 2012 at 6:46 AM
Edited Mar 2, 2012 at 6:52 AM

As an update to my previous post.

I have been able to weed out all NON Bluetooth enteries found in the registry settings on my PC via HKEY_LOCAL_MACHINE\\HARDWARE\\DEVICEMAP\\SERIALCOMM.

using the code I look for text that has Device\BtPort I then call a method that passes the port Nos.

I then search for BT devices (only one connected at present being the Scanner) via InTheHand Library, Know I need to get the  BT serial port connected (so how do I do this programatically?). All things being equal when that gets connected then I see no reason why the opticon code won't work.

Has anyone done what I'm attempting before what calls do I need to do to replace the Registry stuff ?

I'm using c# and finding the VB code some what confusing (being awhile since I touch VB).

any all tips welcome.



Sep 21, 2012 at 9:22 PM

Dave: Hello I am sorry to dig into such an old topic. Did you find a solution for your problem. I kinda in the middle of the same problem.

I am desperatly looking open a connection between two WIDCOMM stacks. However I am still getting this damn PortLookup_Zero error.

Any help?

Sep 23, 2012 at 9:07 AM
Bit of a dead end for me :(

as you can see from this posting... http://32feet.codeplex.com/discussions/393030

I had hit a problem with not being able to open the com port.

I'm kinda steering away from widcomm and sticking with the MS stack as I don't know what stack will be on other machines *IF* i can get past this hurdle.

failing that it'll be a case of going to C but as I don't know it I'm reluctant to do it myself.

hope the link above helps.

Think one has to admit defeat and sue Compact framework 5.0 or something like it.



On 22 September 2012 08:22, engaso <notifications@codeplex.com> wrote:

From: engaso

Dave: Hello I am sorry to dig into such an old topic. Did you find a solution for your problem. I kinda in the middle of the same problem.

I am desperatly looking open a connection between two WIDCOMM stacks. However I am still getting this damn PortLookup_Zero error.

Any help?

Read the full discussion online.

To add a post to this discussion, reply to this email (32feet@discussions.codeplex.com)

To start a new discussion for this project, email 32feet@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com

Sep 23, 2012 at 7:22 PM

Thank you very much for the reply I truly appreciate it. I will look into that topic for sure.

The reason I am interested in this because I need the Rssi which is only provided by the Widcomm stack and after a successful connection link.