software you can take with you

Error 10051 from samsung and LG

Last post 08-05-2011 8:15 AM by alanjmcf. 11 replies.
Page 1 of 1 (12 items)
Sort Posts: Previous Next
  • 07-27-2011 2:40 AM

    Error 10051 from samsung and LG

    Hello Sir,
     
       I am developing a kiosk application (desktop application) for 64 bit machine (os - window 7) in .NET.  I have to implement blutooth functionality in that kiosk, that transfers images/songs to mobile via bluetooth.
     
       I used  InTheHand.Net.Personal dll to implement this functionality.
     
       But the dll supports to only nokia & HTC phones. When I tried to trnasfer content to samsung / LG mobile it asks me to match passkey. The key shown on mobile phone is different from the key that I am passing in the code. Further when I click on "Yes" button it gives Errror after long time. The error is about to socket connection.
     

    The error I got is "socket error 10051 network is unreachable". But the same dll is working fine with Nokia & HTC.
     
      I want to do the content transfer without any key.

     Please help me in this case.

    Thanks In advance.

  • 07-27-2011 4:24 PM In reply to

    Re: Error 10051 from samsung and LG

    Wierd error!  10051 = "Error other than time-out at L2CAP or Bluetooth radio level."

    What happens if you pair the devices first?  Just for troubleshooting.

  • 07-28-2011 1:12 AM In reply to

    Re: Error 10051 from samsung and LG

     Thank you sir foryoue reply.

    Once I paired the samsung / LG device directly using the machine (without using c# application), the next time  when I try to transfer the content to device ittransfers succesfully. The problem is only with the device pairing for first time. When I click on "Yes" in the popup of "Match Passkey" the application raises an error. The error is related to connection with device.

    "Connection failed". The internal error is "Unreachable network" 

    What should be the problem?

    Thanks in advance.

  • 07-28-2011 7:57 AM In reply to

    Re: Error 10051 from samsung and LG

    Hello Sir,

      One addition to the query. I am using dell machine (dell 64 bit). I tried with bluesoliel but it didnt worked. Now I am testing with Microsoft stack.

    Please suggest solution.

  • 07-28-2011 3:53 PM In reply to

    Re: Error 10051 from samsung and LG

    So even if you manually respond to the pairing prompt (and do it promptly) you get the error? But the works (with no pairing request) if you try the connect again? Anyway I'd use BluetoothWin32Authentication to handle the pairing automatically. http://32feet.codeplex.com/wikipage?title=BluetoothWin32Authentication&referringTitle=Bluetooth%20Security
  • 07-29-2011 1:48 AM In reply to

    Re: Error 10051 from samsung and LG

    Thank you for your reply. 

    when i tired to connect using c # application it fails so no transfer possible. And when i connnect it with using machine and paired it, I can able to transfer file using c# application.

    I also notice that the key I am passing using application & the key which prompts on device are different. Might be it should be the problem. 

     

    I read that i should use "BluetoothWin32Authentication". But i don't understand how to use it, because all my attempts don't work.
    This is how i try :

    //I retrieve a device from discovery
    BluetoothAddress deviceAddress = BluetoothDeviceInfo device;
    //Before sending datas i create a BluetoothWin32Authentication instance
    BluetoothWin32Authentication auth = new BluetoothWin32Authentication(deviceAddress, "0000");
    //Then i send file datas


    Uri uri = new Uri("obex-push" + "://" + deviceAddress+ "/fileTest.txt");
    OR

    Uri uri = new Uri("obex://" +deviceAddress+ "/fileTest.txt");


    ObexWebRequest request = new ObexWebRequest(uri);
    request.Timeout = 10000;
    Stream requestStream = request.GetRequestStream();
    //...write datas
    requestStream.Close();


    //Then, when i get response

    ObexWebResponse response = (ObexWebResponse)request.GetResponse();

    //I didnt get any InputBox on device to input  instead one messagebox comes which showing "Match Passkey?" and the key shown on device is not 0000, its different number (random number, automatically changes on every pass), when I clicked on yes "WebException" is thrown, and said : "Connect failed."

    Inner Exception: A socket operation was attempted to an unreachable network 8C77126410C6:0000110500001000800000805f9b34fb

    but it works fine with nokia / HTC devices but fails with samsung /LG / blackberry . Is this device specific?

    Also, i tried to create an instance from : "BluetoothWin32Authentication(EventHandler<BluetoothWin32AuthenticationEventArgs> handler)"
    But i don't know well how to write this sort of handler method and manage it. I didn't find clear example.

    Thanks.

     

  • 07-31-2011 3:07 PM In reply to

    Re: Error 10051 from samsung and LG

    It is likely the devices are using Bluetooth 2.1 and its new Secure Simple Pairing (SSP) feature.  It does NOT use PINs, thus e.g. "0000" won't work.  If a user is present he/she needs to compare that the numbers the two devices are displaying are equal. See e.g. "Bluetooth “Simple Secure Pairing”" at http://www.alanjmcf.me.uk/comms/bluetooth/Bluetooth%20in%20Windows%207.html#_Toc280003366

    Presumably the kiosk has a display and keyboard, if so you need to warn the user that a pop-up might appear and to follow the instructions there.

    It can be done programmatically on the PC see the example code at http://32feet.codeplex.com/wikipage?title=BluetoothWin32Authentication starting with the following converted to C#:

    Using pairer As New BluetoothWin32Authentication(AddressOf HandlerWithSsp ) ' or AddressOf Win32AuthCallbackHandler
        Console.WriteLine("Hit Return to stop authenticating")
        Console.ReadLine()
    End Using
    
    e.g.
        _pairer = new BluetoothWin32Authentication(HandlerWithSsp);
        ...
    }
    BluetoothWin32Authentication _pairer;
    void HandlerWithSsp(object sender, InTheHand.Net.Bluetooth.BluetoothWin32AuthenticationEventArgs e)
    { if (e.AuthenticationMethod == BluetoothAuthenticationMethod.Legacy) { // Call the old method above Win32AuthCallbackHandler(sender, e); else if (e.JustWorksNumericComparison) {
    var rslt = MessageBox.Show("Allow device with address " + e.Device.DeviceAddress.ToString() + " to pair?"); if (rslt == DialogResult.Yes) { e.Confirm = true; }
    ... ...

    In your case you probably just want to send e.Confirm=true with no other checks

     

    On other platforms you could configure the Bluetooth stack on the PC to specify that it has NO keyboard and/or NO display this would help in this case.  Unfortunately I don't know of any way to do that in Windows.

  • 08-01-2011 1:54 AM In reply to

    Re: Error 10051 from samsung and LG

    Thank you sir for response. I am on the way now.

    It worked for me for samsung device with

    _pairer = new BluetoothWin32Authentication(HandlerWithSsp);

    public static void HandlerWithSsp(object sender, InTheHand.Net.Bluetooth.BluetoothWin32AuthenticationEventArgs e)

    {

    e.Confirm =
    true;

    }

     

    But I have another LG device. Using code I can find that It paired with the system but it returns ObexStatusCode - Forbidden (195) the time of transfering dataI search that about the code, it says that "Server refuses to fulfill the request". I can able transfering file to same device using machine.  What is the reason behind it?

    And there are some another devices (e.g. Blackberry) to which I neither able to transfer using built in bluetooth functionality (i.e. using sytem) nor using code. Is there any way to achive this?

    Thanks in advance.

  • 08-01-2011 2:32 AM In reply to

    Re: Error 10051 from samsung and LG

    Hello Sir,

    I found the solution for LG device also. I replace the file transfer method with

    public static void PutFile(BluetoothAddress addr, String filepath)

    {

    BluetoothClient btCl = new BluetoothClient();

    _pairer = new BluetoothWin32Authentication(HandlerWithSsp);

    System.Net.Sockets.NetworkStream peerStream;

    BluetoothEndPoint ep = new BluetoothEndPoint(addr,

    InTheHand.Net.Bluetooth.BluetoothService.ObexObjectPush);

    try

    {

    btCl.Connect(ep);

    }

    catch

    { }

    peerStream = btCl.GetStream();

    ObexClientSession sess = new ObexClientSession(peerStream, UInt16.MaxValue);

    ObexHeaderCollection headers = new ObexHeaderCollection();

    headers.Add(ObexHeaderId.Count, 1);

    sess.Connect(headers);

    using (FileStream src = File.OpenRead(filepath))

    {

    long lengthInBits = src.Length * 8;

    String name = Path.GetFileName(filepath);

    Console.WriteLine("Filename: {0}", filepath);

    Console.WriteLine(" Length = {0}", src.Length);

    //

    DateTime start = DateTime.UtcNow;

    sess.PutFrom(src, name, null, src.Length);

    TimeSpan ts = DateTime.UtcNow - start;

    double bps = ((lengthInBits / ts.TotalMilliseconds) * 1000);

    Console.WriteLine(" PutFrom took {0}, at an average {1} bps.",

    ts, bps);

    }

    btCl.Close();

    btCl.Dispose();

    }

    That works for Samsung & LG. Do you want to suggest any change in above code?

    And the problem reamins same with Blackberry. Please suggest.

    Thanks.

     

  • 08-03-2011 5:55 AM In reply to

    Re: Error 10051 from samsung and LG

    Great stuff!  Code looks fine to me.

    What code do you have in HandlerWithSsp? Just "e.Confirm=true"?

  • 08-03-2011 6:11 AM In reply to

    Re: Error 10051 from samsung and LG

     Yes. e.Confirm=true is sufficient. 

    Just one question with

    sess.PutFrom(src, name, null, src.Length);

    Its taking to much time if I am transfering any lagre file. Is the any way to speed up the transfer.

    Because I have flash integration with my c# application. Due to long time in transfer it breaks the socket coonection with flash.

    File transfers succesfully but socket connection with flash breaks down.

     Thanks. 

     

  • 08-05-2011 8:15 AM In reply to

    Re: Error 10051 from samsung and LG

    On the previous Blackberry question.  The OBEX server has to be manually enabled. I've added a note to http://32feet.codeplex.com/wikipage?title=Behaviour%20From%20Servers

    As to the speed of transfer there's probably not much can be done.  What bit rate are you getting?  Traditional Bluetooth isn't that fast.

    I don't know why it interferes with your network comms.  Are the comms over WiFi or wired Ethernet?

Page 1 of 1 (12 items)
Copyright © 2001-2013 In The Hand Ltd. All rights reserved. Terms of Use and Privacy Policy. OrcsWeb's Windows Cloud Server Hosting