howto link to the Serial port of BT device??

Topics: Bluetooth - Widcomm/Broadcom
Aug 25, 2012 at 8:42 AM

Okay in c# I have code that loops round looking for a NAMED device - Namely a OPTICON barcode scanner - It's name is OPN2002-ABCD.

code below shows where I chack for the name of the current device, if it's a match but not known (ie no pairing done previously then do the pairing but using the ABCD numeric value as the pairing code - show pair!

 

So now we've paired the device and got a link, HOW the HELL can I get the serial port connection to work?

I've spent off and on months trying to, posted to this list at least 3 times seeking help and not getting it (or at least not understanding what I've been told) Yes I've googled and googled to no avail on how to do it in C#.

I know it's to do with socket programming but is Oblex the same thing??

What I want to do is to be able to us the OPN usb .net library to communicate with the scanner but it works with a com port only.

I suppose the com port could be changed but I want to be able to get the SPP link up.

Please some put me out of my misery?

Looked and looked at sample codes in VB but can't join the dots.

 

******** code snippet  START ********

                if (dev.DeviceName.Contains("OPN2002") & dev.Remembered == false)
                {
                    string pin = dev.DeviceName.Substring(8, dev.DeviceName.Length - 8);

                    BluetoothWin32Authentication mem = new BluetoothWin32Authentication(dev.DeviceAddress, pin);
                    bc.SetPin(pin);
                }

                //device.SetServiceState(InTheHand.Net.Bluetooth.BluetoothService.SerialPort, True)
                dev.SetServiceState(BluetoothService.SerialPort,true, true);
                Console.WriteLine(Convert.ToString(bc.GetRemoteMachineName(dev.DeviceAddress)));

******** code snippet  END ********

Developer
Aug 26, 2012 at 9:04 PM

I hate virtual COM ports for all these reasons. :-(

So OPTICON produce a scanner that uses Bluetooth, they also supply a library, but it won't use Bluetooth? So you need to create a Bluetooth virtual COM port to get the two bits to work?  That seems a bit rubbish on their part. Why don't they add the code to their software so that it can connect to Bluetooth devices, that's *so* much easier than COM ports??

First question. Can you manage it using the Windows UI and not any code. e.g. using Bluetooth Control Panel or Devices&Printers discover the device and pair to it -- and if that does not automatically create a COM port then create one manually. Does that work and does the software cope with it?

Aug 27, 2012 at 9:32 AM

Hi Alan,

I have to agree with you - Arrgh!!!!

Yup it'd be So much easier if they had a BT library like they do for the USB version.

The Library i'm using was for the OPN2001 (same scanner but no Bluetooth).

before starting I was able to connect via the BT control manager (win XP)  and then able to scan and read (using their app) barcodes scanned.

I then started looking for a .net library to allow me to get a BT link up and running, With your library I've been able to detect WHEN the scanner has been paired and now want to communicate with the scanner like I can when it's plugged in via usb.

I have tried searching the registry for the BT port and try to communicate with it with no luck, tried hard coding the port # in no luck.

Not tried win 7 as yet but was wondering if that OS would be better?

Opticon do have a SDK for the OPN2002 but that'd require me to know c or c++.

Developer
Aug 29, 2012 at 2:12 PM

Wait I've just realise that we're in the Widcomm forum. Is your PC using the Widcomm stack?  If so you could have a look at class WidcommSerialPort.

On MSFT+Win32 SetServiceState should be the correct function to call.

Aug 30, 2012 at 9:09 AM

Yes I am using the Widcomm stack, like to use teh MS stack but from reading this if your using a usb dongle (like i am then you need to use their stack) if your wanting to code with c# or VB.

Reason I'd like to use only the MS stack is because I don't know what teh end user might be using, push comes to shove I suppose i say YOU MUST use WIDCOMM based usb dongle for my app to work, but seems to be - i don't know manky??

regarding the WidcommSerialPort don't think I have.

Just had a quick play with this as below...

 

            foreach(BluetoothDeviceInfo dev in devices)
            {
                Console.WriteLine(Convert.ToString(dev.DeviceName));
                Console.WriteLine(dev.Connected);

                if (dev.DeviceName.Contains("OPN2002") & dev.Remembered == false)
                {
                    string pin = dev.DeviceName.Substring(8, dev.DeviceName.Length - 8);

                    BluetoothWin32Authentication mem = new BluetoothWin32Authentication(dev.DeviceAddress, pin);
                    bc.SetPin(pin);
                }

                //device.SetServiceState(InTheHand.Net.Bluetooth.BluetoothService.SerialPort, True)
                //dev.SetServiceState(BluetoothService.SerialPort,true, true);

               
                WidcommSerialPort wsp = WidcommSerialPort.CreateClient(dev.DeviceAddress);


                Console.WriteLine("port number is " + Convert.ToString(wsp.PortName));
                Console.WriteLine(Convert.ToString(bc.GetRemoteMachineName(dev.DeviceAddress)));

now what I got is this (from a console)....

32feet.NET's Widcomm SDK Version  : 6.1.0.1506
32feet.NET's Widcomm Stack Version: 5.6.0.6500
OPN2002_5193
True
SppClient_Destroy
SppClient_Destroy

Now I had the BT scanner already connected and the serial port connected (that was when i got the SppClient_Distroy).

Should i have the scanner connected but no port linked?

As an aside what do you think or know of windows compact embedded 7 as I'm thinking maybe this will get around the stack being used issue (showing my ignorance here too).

 

regards,

Dave

Developer
Aug 31, 2012 at 2:11 PM

99% of all USB dongle use the standard Bluetooth specification for USB connection and so can be used by any stack. So the Microsoft stack can use them. In short go to Device Manager, select the radio device, "Upgrade Driver", "Browse", "Let me pick" and choose "Generic Bluetooth Adapter" if offered. Some dongles have drivers with different names, see the list in the second section in "%windir%\inf\bth.inf"

 

If using Widcomm. It appears WidcommSerialPort keeps the COM port as long as the object and program stays alive. You want the port to last forever?

Sep 2, 2012 at 9:23 AM

I want to open / connect each time I loop round (infinite loop sleeping for 45 seconds every minute - this is what i do with the USB version and it works great).

 

Tonight I've had 1 step towards success in that i've had this output....

32feet.NET's Widcomm SDK Version  : 6.1.0.1506
32feet.NET's Widcomm Stack Version: 5.6.0.6500
OPN2002_5193
True
port number is InTheHand.Net.Bluetooth.Widcomm.WidcommSppClient  <<<< so I've managed to create a BT connection!!

So now that I've got a connection (as per previous posting of my code) can i then communicate via the com port?

eg wsp.portname dispalys comport15 on my machine so would my USB code work now using com port 15?

is their something I'm missing still?

 

dave.

 

 

Developer
Sep 5, 2012 at 9:00 AM

Does COM port 15 appear? Can you open it with another program, or e.g. System.IO.Ports.SerialPort, does it appear in System.IO.Ports.SerialPort.GetPortNames?

I don't have the time to investigate the Widcomm serial port stuff particularly as it is used by so few users. I would suggest you change to using the Microsoft stack and there SetServiceState should be usable.

Otherwise if you are keen to use the Widcomm support, then I would be glad to work with you on a commercial basis so we can get it to work for you. You can contact my via email yahoo.com name alanjmcf


Sep 6, 2012 at 10:09 AM

This is getting messier from my persective.

Long ago (and I mean going back to late 2011 early 2012) I played with widcomm.widsommSppClient only to hit this same problem of "getting a client created" but unable to do anything with the object - okay that I knew of).

from BT Device Control I click on BT Configuration and see 1 item called Formosa 1 which is MFG by Broadcom - so I suspect it's the usb BT dongle.

thus I have determined I don't have a MS BT stack installed.

So where do i get this from?

on another tangent - this link http://32feet.codeplex.com/releases/view/61443 points to a DLL you made that implies it supports Widcomms Serial port protocol.

I've D/L it and ran the exe but it pops up .... info implying it's found the library and that's all!

I would be most happy to go with a generic solution as I don't know and wont be able to control what dongles other users will use.

Should i suspend development on WINXP in favour of win7?

does win7 give better BT STACK support out of the box?

I'd only go down the Widcomm SerialPort as a last resort.

dave.

Developer
Sep 7, 2012 at 6:12 PM

I bet if you take that dongle to another machine and plug it in without every putting a Broadcom/Widcomm CD near it, then the Microsoft Bluetooth stack will be installed.

Sep 9, 2012 at 7:54 AM
Edited Sep 9, 2012 at 7:54 AM

tehehehe,

You'd be right....

 

some code here

 

 

         static void Test3()
            {
                try
                {
                    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());
                    Console.WriteLine("----------------------------------------");

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

 

the above works but I jumped rightly or wrongly to Widcomm for the serial ports as this is where I'm bogged down with.

Can you point me to something C# that'd be usable/instructional for me on how to get the com port to work?

Should I be using a compact framework if so which one? (Know i'm moving away from things Widcomm/Boardcom here).

Now I've changed the code a bit as follows...


                      

  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");
                            }

                        }

                        InTheHand.Net.BluetoothEndPoint  ep = new InTheHand.Net.BluetoothEndPoint(device.DeviceAddress, BluetoothService.SerialPort);
                                              Guid spguid = BluetoothService.RFCommProtocol;

                                              device.SetServiceState(spguid,true); <<<<< error occuring here.

 

 

Output is below.

32feet.NET's Widcomm SDK Version  : 6.1.0.1506
32feet.NET's Widcomm Stack Version: 5.6.0.6500
------------ My Information ------------
Radio Name: win-XP
Radio Mode: Discoverable
----------------------------------------
---------- Device Found -------------
Device Name: OPN2002_5193
Last Used: 1/01/0001 12:00:00 AM
oopsy...
The method or operation is not implemented.

 

 

I hope that I'm showing you that I am trying to work this out and not trying to put anyone into an asylm :)

As mentioned in previous postings I'm more than happy to create something (a fully working app) that can be posted here for other c# programmers who follow to read.

 

regards,

 

Dave

Sep 23, 2012 at 8:47 PM
Edited Sep 23, 2012 at 8:48 PM

Hello Dave,

I got it running, using RFCOMM protocol though. But you can always do it through Serial .

I used your own code.  Please have look:

The trick is to have the other machine runs on Microsoft.  I paired them using Windows 7 pairing software (Join a Personal A rea Network) I don't know if that would affect the success.

 

 

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

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

            //try
            //{
            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.Discoverable;


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

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

            BluetoothClient me = new BluetoothClient();
            BluetoothDeviceInfo[] devices = me.DiscoverDevices();
            foreach (BluetoothDeviceInfo device in devices)
            {
                Console.WriteLine("Device Name: {0}", device.DeviceName);
                Console.WriteLine("Last Used: {0}", device.LastUsed);
            }

            //}
            BluetoothRadio localBluetooth = BluetoothRadio.PrimaryRadio;

            BluetoothDeviceInfo ClientDeviceInfo = devices[0];

            BluetoothAddress localAddress = localBluetooth.LocalAddress;

            BluetoothDeviceInfo localDeviceInfo = new BluetoothDeviceInfo(localAddress);
            BluetoothClient localBTClient = new BluetoothClient();


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

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

            }
            Guid spguid = BluetoothService.RFCommProtocol;
            InTheHand.Net.BluetoothEndPoint ep = new InTheHand.Net.BluetoothEndPoint(ClientDeviceInfo.DeviceAddress, spguid);


            //     localDeviceInfo.SetServiceState(spguid, true);


            localBTClient.Connect(ep);

            Console.WriteLine("Connection worked");



            int rssi = localDeviceInfo.Rssi;


            Console.WriteLine("Local RSSI Level {0}", rssi.ToString());

            Console.WriteLine(" The remote Remote RSSI Level {0}", ClientDeviceInfo.Rssi.ToString());


            while (true)
            {
                Console.WriteLine(" The remote Remote RSSI Level {0}", ClientDeviceInfo.Rssi.ToString());

            }





            Console.ReadLine();
            //catch (Exception ex)
            //{

            //}


        }

    }
}

Sep 24, 2012 at 12:19 AM
I might just have to send you a *BIG* KISS (if this solves my problem).

For as you could see I don't know how many scanners I could be linking with so I went with a loop to catch them, connect to them, download data from them, having the app go to sleep for 45 seconds and then repeating the processes, Maybe I'll do something like looking at the last time the scanner was detected (i.e. if their is a new connection time then fall into the connect, download loop) first thing is first and that's being able to get a SPP Connection and being able to then pull barcodes down.

I'm at work at present so can't do much but as you can see from my postings I've been banging my head over this off and on for over 9 months.
which has been very annoying, Why No one hasn't posted some code like mine for SSP connections is a bit annoying, I Intend to do that in a new thread (or if you do one for RSSI then I'll add a reference to your posting in it).

you'll hear from me either way.


BIG THANKS for the reply and giving me some hope.

Dave.

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

From: engaso

Hello Dave,

I got running, using RFCOMM protocol though. But you can always do it through Serial .

I used your own code. Please have look:

The trick is to have the other machine runs on Microsoft. I paired them using Windows 7 pairing software (Join a Personal A rea Network) I don't know if that would affect the success.

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

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

            //try
            //{
            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.Discoverable;


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

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

            BluetoothClient me = new BluetoothClient();
            BluetoothDeviceInfo[] devices = me.DiscoverDevices();
            foreach (BluetoothDeviceInfo device in devices)
            {
                Console.WriteLine("Device Name: {0}", device.DeviceName);
                Console.WriteLine("Last Used: {0}", device.LastUsed);
            }

            //}
            BluetoothRadio localBluetooth = BluetoothRadio.PrimaryRadio;

            BluetoothDeviceInfo ClientDeviceInfo = devices[0];

            BluetoothAddress localAddress = localBluetooth.LocalAddress;

            BluetoothDeviceInfo localDeviceInfo = new BluetoothDeviceInfo(localAddress);
            BluetoothClient localBTClient = new BluetoothClient();


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

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

            }
            Guid spguid = BluetoothService.RFCommProtocol;
            InTheHand.Net.BluetoothEndPoint ep = new InTheHand.Net.BluetoothEndPoint(ClientDeviceInfo.DeviceAddress, spguid);


            //     localDeviceInfo.SetServiceState(spguid, true);


            localBTClient.Connect(ep);

            Console.WriteLine("Connection worked");



            int rssi = localDeviceInfo.Rssi;


            Console.WriteLine("Local RSSI Level {0}", rssi.ToString());

            Console.WriteLine(" The remote Remote RSSI Level {0}", ClientDeviceInfo.Rssi.ToString());


            while (true)
            {
                Console.WriteLine(" The remote Remote RSSI Level {0}", ClientDeviceInfo.Rssi.ToString());

            }





            Console.ReadLine();
            //catch (Exception ex)
            //{

            //}


        }

    }
}

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 24, 2012 at 1:57 AM
Edited Sep 24, 2012 at 1:58 AM

Of course buddy just try it and let me know, here is the server code:

Remember the server is running on MSFT stack, the client (Your code is running on Widcomm).

 

  localBluetooth = InTheHand.Net.Bluetooth.BluetoothRadio.PrimaryRadio;

            if (localBluetooth == null)
            {
                MessageBox.Show("No support Bluetooth radio/stack found.");
            }
            else if (localBluetooth.Mode != InTheHand.Net.Bluetooth.RadioMode.Discoverable)
            {

                localBluetooth.Mode = InTheHand.Net.Bluetooth.RadioMode.Discoverable;
            }


 BluetoothAddress localAddress = localBluetooth.LocalAddress;
           BluetoothDeviceInfo BTDI = new BluetoothDeviceInfo(localAddress);
            BluetoothClient BTCl = new BluetoothClient();

//Defining variables
        BluetoothListener m_serverListener;
        BluetoothClient m_serverCli;
        System.Net.Sockets.NetworkStream m_serverStrm;
        System.IO.StreamWriter m_serverWtr;
        System.Text.Encoding m_serverEncoding;

        bool m_serverAccepting;
        bool m_serverDisconnecting;
        ServiceClass m_selectedScs;


        private void NewBluetoothRFCOMMServer()
        {

      
            m_serverCli = new BluetoothClient();
  

            BTDI = new BluetoothDeviceInfo(localBluetooth.LocalAddress);

            Guid spguid = BluetoothService.RFCommProtocol;
            //BTDI.SetServiceState(spguid, true);
            m_serverListener = new BluetoothListener(spguid);
            m_serverListener.ServiceName = " Wecad Bluetooth Server";

           // m_serverEncoding = System.Text.Encoding.ASCII;//System.Text.Encoding.GetEncoding(ComboBoxServerEncoding.Text)
           // MessageBox.Show(localBluetooth.LocalAddress.ToString());
            m_serverListener.Start();
            m_serverCli = m_serverListener.AcceptBluetoothClient();


            bool IsCLientConnected = m_serverCli.Connected;


// The following lines are  not working yet, but the connection is there avialalbe.
m_serverStrm = m_serverCli.GetStream(); System.IO.StreamReader rdr = new System.IO.StreamReader(m_serverStrm, Encoding.ASCII); Char[] buff = new Char[99]; int numread = rdr.Read(buff, 0, buff.Length); String read = new string(buff, 0, numread); richTextBox1.Text = read; }

 

 

This is how the trace.log should look like:

32feet.NET: 'InTheHand.Net.Personal, Version=3.5.605.0, Culture=neutral, PublicKeyToken=ea38caa273134499'   versions: '3.5.605.0' and '3.5.0605.0'.IBtIf using WidcommStBtIf.IRfCommIf using WidcommStRfCommIf.WidcommRfcommPort.Create'd: BDFF30HandleDeviceRespondedHDR: "00-02-72-21-F5-16" "3E-01-0C" "57-45-43-41-44-2D-54-35-30-30-2D-31" Falseexit HDRHandleInquiryCompleteStopInquiryexit HandleInquiryCompleteIRfCommIf using WidcommStRfCommIf.WidcommRfcommPort.Create'd: BDEB80Calling CBtIf:Bond...Bond returned: FAIL = 0x4BeginFillInPortStateBeginServiceDiscovery gonna call StopInquiry.StopInquiryWidcommBtIf.StartDiscoveryHandleDiscoveryComplete_GetPorts, got 1 records.DoEndServiceDiscovery, got 1 records.FillInPort_ServiceDiscoveryCallback, got port: 10NativeMethods.RfcommPort_OpenClient ret: SUCCESS=0x00000000OpenClient ret: SUCCESS=0x0000000016:19:22.7944000 HandleEvent: 512=0x200=CONNECTED

 

 

 

Please feel free to ask me since it is working now. I have been working more that 12 hours  daily on this issue for the past 8 days. Your code helped me and I want to pay you back. 

Sep 25, 2012 at 10:25 AM
Nope....
I'm lost :(!
my problem is a bit different to your one (at least I think it is).
I have a barcode scanner that I want to have connect to the desktop pc it can connect as a master device or as a slave (the difference is which button you press).
Could you please have a look at my original code and see what i'm doing wrong?
and why I'm not getting a connection via SPP?
I'm almost sure it's got something to do with me not using the LOCAL RFCOMM side of things.
dave.

On 24 September 2012 13:57, engaso <notifications@codeplex.com> wrote:

From: engaso

Of course buddy just try it and let me know, here is the server code:

Remember the server is running on MSFT stack, the client (Your code is running on Widcomm).

  localBluetooth = InTheHand.Net.Bluetooth.BluetoothRadio.PrimaryRadio;

            if (localBluetooth == null)
            {
                MessageBox.Show("No support Bluetooth radio/stack found.");
            }
            else if (localBluetooth.Mode != InTheHand.Net.Bluetooth.RadioMode.Discoverable)
            {

                localBluetooth.Mode = InTheHand.Net.Bluetooth.RadioMode.Discoverable;
            }


 BluetoothAddress localAddress = localBluetooth.LocalAddress;
           BluetoothDeviceInfo BTDI = new BluetoothDeviceInfo(localAddress);
            BluetoothClient BTCl = new BluetoothClient();

//Defining variables
        BluetoothListener m_serverListener;
        BluetoothClient m_serverCli;
        System.Net.Sockets.NetworkStream m_serverStrm;
        System.IO.StreamWriter m_serverWtr;
        System.Text.Encoding m_serverEncoding;

        bool m_serverAccepting;
        bool m_serverDisconnecting;
        ServiceClass m_selectedScs;


        private void NewBluetoothRFCOMMServer()
        {

      
            m_serverCli = new BluetoothClient();
  

            BTDI = new BluetoothDeviceInfo(localBluetooth.LocalAddress);

            Guid spguid = BluetoothService.RFCommProtocol;
            //BTDI.SetServiceState(spguid, true);
            m_serverListener = new BluetoothListener(spguid);
            m_serverListener.ServiceName = " Wecad Bluetooth Server";

           // m_serverEncoding = System.Text.Encoding.ASCII;//System.Text.Encoding.GetEncoding(ComboBoxServerEncoding.Text)
           // MessageBox.Show(localBluetooth.LocalAddress.ToString());
            m_serverListener.Start();
            m_serverCli = m_serverListener.AcceptBluetoothClient();


            bool IsCLientConnected = m_serverCli.Connected;


// The following lines are  not working yet, but the connection is there avialalbe.
m_serverStrm = m_serverCli.GetStream(); System.IO.StreamReader rdr = new System.IO.StreamReader(m_serverStrm, Encoding.ASCII); Char[] buff = new Char[99]; int numread = rdr.Read(buff, 0, buff.Length); String read = new string(buff, 0, numread); richTextBox1.Text = read; }

This is how the trace.log should look like:

32feet.NET: 'InTheHand.Net.Personal, Version=3.5.605.0, Culture=neutral, PublicKeyToken=ea38caa273134499' versions: '3.5.605.0' and '3.5.0605.0'.IBtIf using WidcommStBtIf.IRfCommIf using WidcommStRfCommIf.WidcommRfcommPort.Create'd: BDFF30HandleDeviceRespondedHDR: "00-02-72-21-F5-16" "3E-01-0C" "57-45-43-41-44-2D-54-35-30-30-2D-31" Falseexit HDRHandleInquiryCompleteStopInquiryexit HandleInquiryCompleteIRfCommIf using WidcommStRfCommIf.WidcommRfcommPort.Create'd: BDEB80Calling CBtIf:Bond...Bond returned: FAIL = 0x4BeginFillInPortStateBeginServiceDiscovery gonna call StopInquiry.StopInquiryWidcommBtIf.StartDiscoveryHandleDiscoveryComplete_GetPorts, got 1 records.DoEndServiceDiscovery, got 1 records.FillInPort_ServiceDiscoveryCallback, got port: 10NativeMethods.RfcommPort_OpenClient ret: SUCCESS=0x00000000OpenClient ret: SUCCESS=0x0000000016:19:22.7944000 HandleEvent: 512=0x200=CONNECTED

Please feel free to ask me since it is working now. I have been working more that 12 hours on this library for the past 8 days. You code is the one that helped me and I want to pay you back.

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


May 30, 2014 at 6:55 AM
nice, I can scan and read (using their app) barcodes scanned. but I wonder how can I import the data that I got from barcode scanner into my data base for using.
something similar to this.
http://stackoverflow.com/questions/12497105/reading-usb-hid-barcode-scanner-input-barcode-reader
Jul 5, 2014 at 6:30 AM
Johnny,

how are you getting the barcodes down via a loop?

are you using a variable to store the number of barcodes found each time you connect and download?
then you can use that same variable for the pushing of barcodes into the database too.

I had mobile users and so wanted to ensure the barcodes were safe so did the following....

  1. had the barcodes saved to a textfile on the hard drive
  2. emailed that file to a email address
  3. made a internet connection to the server and uploaded the barcodes via DB specific calls to insert into a table.
  4. once the user came back to base the text files where uploaded and each file opened, read and barcodes check against the database, If something was missed then it was inserted into the database.

you could use memory variable or an array to store the barcodes just read in and then insert the barcode into the DB _OR_ use a 2nd loop and insert the barcodes into the DB then.

Either way you'll be using a one or more variables to store the needed info or if you're clever 1 multi array, 1 array item per barcode read in.

my barcodes had a structure like....

id, barcode, barcode type, date, time, other details I can't remember what else.

I manipulated the read structure so i had Barcode, date, time saved from the reading in of the barcode inside a loop.

Hope this helps.


If you want further help - holler.

Let me know more info regarding the DB you use (I used mysql)


Dave.