.NET Components for Mobility

How to get data from bluetooth Scanner

Last post 09-23-2008 3:29 PM by Andy Hume. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 09-23-2008 8:17 AM

    How to get data from bluetooth Scanner

    I got a hand-held scanner connected by the bluetooth and it is found by the BuletoothClient.DiscoverDevices in application.  The application needs to get the data read by the scanner and save the database. But I don't know how to invoke the event when the scanner is scan the barcode.

    I tried with ObexListener class to listen the event after the device has been connected. But it doesn't work. I tried to use the Brecham.Obex class by following code but it hangs the application. Am I in the right direction to go? Can anyone of you help me out how to get scan event from bluetooth scanner and which class should I use? Many thanks in advance.

     

    if (bc.Connected)
                                    {
                                        DateTime start = DateTime.UtcNow;
                                        L_ThreadEvent = new ManualResetEvent(false);
                                        Thread t = new Thread(new ThreadStart(Killer));
                                        t.Start();
                                        stream = p_BTClient.GetStream();
                                        ObexGetServer handler = new ObexGetServer();
                                        handler.CreateGetStream += new EventHandler<CreateGetStreamEventArgs>(handler_CreateGetStream);
                                        ObexHost = new AsyncObexServerHost(stream, 16 * 1024);
                                        ObexHost.Start();
                                        ObexHost.ExitWaitHandle.WaitOne();
                                        strHistory.AppendLine("Connection lasted on " + (DateTime.UtcNow - start));

     

  • 09-23-2008 3:29 PM In reply to

    Re: How to get data from bluetooth Scanner

    I'll pretty likely that the scanner doesn't use OBEX at all.  Its likely that it returning the data like a simple serial cable connection.

    I'd use the SdpBrowserDesktop sample from the32feet.NET library to start with, its flexible enough to play without writing any code.  Discover, select your device and do a <Lookup all records> queries, expect to see a record with "SerialPort".

    Then use the "Client" tab to connect to that service and hopefully when you use the scanner the data will appear in the textbox.  (The sample is missing a file in the 2.3 release BTW, so use 2.2, or http://32feet.net/files/folders/samples/entry6096.aspx)

    Andy 

Page 1 of 1 (2 items)
Copyright © 2001-2008 In The Hand Ltd. All rights reserved. Terms of Use and Privacy Policy.