Quantcast
Channel: 32feet.NET
Viewing all 469 articles
Browse latest View live

New Post: CSR Harmony stack

$
0
0
Ahh yes. It doesn't appear as a BTH device. I remember finding an article how to switch its mode to standard. But I guess you've bought a new dongle by now. :-.)

Commented Unassigned: BluetoothListener problem with unknown GUID [35112]

$
0
0
Hi,

I'm hoping someone out there can help me.
I have a windows mobile 6 application that connects to a device via Bluetooth.
Everything is working fine. I can send commands to it and receive data.
That said I am using a service Guid for the BluetoothListener of:
BluetoothService.RFCommProtocol mainly because it works. The problem is the Bluetooth device I'm working with is a sealed unit with no programmable interface and thus I can't set the Guid on it.
I know this is a constant that Alan says will result is a random channel number, but it works.
I tried using a created Guid and the device received and sent nothing.

My problem is that the device comes with a key-fob which can be used to send a command to it.
I'm then expected on the mobile to receive that data it then sends.
The previous version of the application uses CFSerial.dll and thus used a Comm Port for its Bluetooth connection and this was able receive the data triggered by the key-fob. I suspect this has something to do with the Comm Port method being bound to a specific channel or service of some kind, but I'm guessing wildly.
On the application the user is given the choice whether to use the mobile or the keyfob to trigger the data. If they choose the mobile I'm fine, I have it working, but if they choose the keyfob I create a bluetoothlistener (using the Guid above) but it never gets any data.

Does anyone know if I can use Bluetooth SDP to get the channel number and then do something with that to listen for data?

Any help or pointers in the right direction would be very very helpful.
Comments: ** Comment from web user: alanjmcf **

On the first issue. Use the SDP lookup functions in the library to find what services are advertised by the two devices. Use SdpBrowser and do a "All Services (over L2CAP)" scan against each.

That will show the SDP records unless one is just using a fixed port... If that's the case then there are only tens of RFCOMM port numbers so one time do a loop until you find the one (or more) that connect and hard code that in your program.


On the second question. Is that being run on WM6 or desktop Windows? I would think that if the connect fails then the socket is not connected so there's no point in using it regardless of error code. What's the Socket Error Code? 10056? It could be that the error code is being re-purposed for some other Bluetooth error condition. The error numbers for the MSFT stack on desktop Windows are summarised at https://32feet.codeplex.com/wikipage?title=Errors but that one's not really defined well. http://msdn.microsoft.com/en-us/library/aa362901.aspx

New Comment on "BluetoothWin32Authentication"

$
0
0
Mehrad. I don't we ever got authentication to work on BlueSoleil. Download the sources and see the code in InTheHand.Net.Personal\InTheHand.Net.Personal\Net.Bluetooth.BlueSoleil\BluesoleilSecurity.cs Add some debug prints and see what happens. You could also try writing a simple Windows(Forms) program that uses the BlueSoleil API and see if you can get it to work there. Then make it work the same way in 32feet.NET. We can make changes if you get it working. Alan

New Comment on "BluetoothWin32Authentication"

$
0
0
Alan, Thanks again for getting back to us. I think I got a little bit confused by this part in this article saying "I've managed to test: NumericComparison, and PasskeyNotification, as well as Legacy of course. Starting my testing with BlueSoleil and Linux" and I was like how on earth I can't make this to work without considering the first thing you mentioned in this post about this method working only on Windows stack. I have spent a fair amount of time and whatever I did, I've been asked for the passcode while using BlueSoleil and no way to get around it so far. I also had lots of problem disconnecting from the device as well. Thanks again and I will keep you updated if I achieve something. Mehrad

New Comment on "BluetoothWin32Authentication"

$
0
0
Hi Mehrad. I'll change that sentence to remove the ambiguity! BlueSoleil is a quite different API... If you can any better way to interop with it let me know. :-) Alan

Updated Wiki: BluetoothWin32Authentication

$
0
0

BluetoothWin32Authentication

The class is used to respond to requests for authentication for Bluetooth devices.

It is supported only on the Microsoft stack on desktop Windows (MSFT+Win32 in my jargon). It should be possible to implement on BlueSoleil for instance, but I never managed to find the way to get their API to work -- it may need use of a message loop, similar to some stuff in Widcomm.

This class is generally used in a mode where a user supplied callback will be called when any device requires authentication. This is the mode that needs to be used for Bluetooth 2.1 Simple Secure Pairing (SSP). The callback will specify what type of pairing is required e.g. Legacy for tradional PIN pairing, or NumericComparison/JustWorks for v2.1 devices, and the user code in the callback method should response respectively, e.g by setting e.Pin or e.Confirm etc, see the full table of how to respond below. Also see the example code below.

(For traditional pairing (with a PIN code), it can also be used in a mode where an instance can be created specifying both the one device that is being connected to and the PIN string to use it will respond to that single device; it is used by BluetoothClient that way to support its Pin property.)

To confirm the pairing the callback method should do the following:
AuthenticationMethod etc Action
Legacy Then the pairing is using old-style PIN support, so the Pin property should be set
NumericComparison Then the Confirm propery needs to be set, but……
• If NumericComparisonandJustWorksNumericComparison• Then the user should be asked to confirm the pairing with a simple Yes/No.
• If NumericComparison, and notJustWorksNumericComparison• Then the user should be shown the NumberOrPasskey value and asked to confirm that the values displayed on both devices match.
OutOfBandConfirmOob should be called -- this is untested
It seems that Passkey is "please input the passkey as displayed on the other device", and PasskeyNotification is "here's the passkey to type on the remote device, confirm that"
PasskeyNotification Then the user need to be shown the NumberOrPasskey value which needs to be typed on the remote device, and the Confirm propery needs to be set
Passkey Presumably set ResponseNumberOrPasskey as well as Confirm -- this is untested

There are other properties on the BluetoothWin32AuthentionEventArgs for instance CallbackWithResult and PreviousNativeErrorCode. The reference documentation for this class is at http://docs.32feet.net/html/T_InTheHand_Net_Bluetooth_BluetoothWin32Authentication.htm

If you simply want to allow the pairing to go ahead when to SSP devices are connecting then handling the callback and setting e.Confirm=True will be enough -- but that is a little insecure...

If you want to initiate this pairing process then call BluetoothSecurity.PairRequest passing a null password.

Examples

If one wants to respond to PIN requests for one device with a known PIN then use the simple form which is initialized with an address and PIN.
BluetoothWin32Authentication authenticator
    = new BluetoothWin32Authentication(remoteEP.Address, m_pin);
// when the peer is expected to require pairing, perhaps do some work.
authenticator.Dispose();
If one wants to see the PIN request, perhaps to be able to check the type of the peer by its address then use the form here which requests callbacks. (Note that this code assumes that 'Legacy' PIN-based pairing is being used; setting the Pin property will presumably have no effect if the authentication method being used is one of the v2.1 SSP forms).

Using pairer AsNew BluetoothWin32Authentication(AddressOf HandlerWithSsp ) ' or AddressOf Win32AuthCallbackHandler
       Console.WriteLine("Hit Return to stop authenticating")
       Console.ReadLine()
   EndUsing
...

Sub Win32AuthCallbackHandler(ByVal sender AsObject, ByVal e As InTheHand.Net.Bluetooth.BluetoothWin32AuthenticationEventArgs)
    ' Note we assume here that 'Legacy' pairing is being used,' and thus we only set the Pin property!Dim address AsString = e.Device.DeviceAddress.ToString()
    Console.WriteLine("Received an authentication request from address " + address)
    '' compare the first 8 hex numbers, this is just a special case because in the' used scenario the model of the devices can be identified by the first 8 hex' numbers, the last 4 numbers being the device specific part.If address.Substring(0, 8).Equals("0099880D") OrElse _
            address.Substring(0, 8).Equals("0099880E") Then' send authentication response
        e.Pin = "5276"ElseIf (address.Substring(0, 8).Equals("00997788")) Then' send authentication response
        e.Pin = "ásdfghjkl"EndIfEndSub

' untested!Sub HandlerWithSsp(ByVal sender AsObject, ByVal e As InTheHand.Net.Bluetooth.BluetoothWin32AuthenticationEventArgs)
    If e.AuthenticationMethod = BluetoothAuthenticationMethod.Legacy Then' Call the old method above
        Win32AuthCallbackHandler(sender, e)


    ElseIf e.JustWorksNumericComparison = TrueThenDim rslt As DialogResult = MessageBox.Show("Allow device with address "& e.Device.DeviceAddress.ToString() & " to pair?")
        If rslt = DialogResult.Yes Then
            e.Confirm = TrueEndIfElseIf e.AuthenticationMethod = BluetoothAuthenticationMethod.NumericComparison ThenDim rslt As DialogResult = MessageBox.Show("Device with address "& e.Device.DeviceAddress.ToString() & " is wanting to pair."& _
              " Confirm that it is displaying this six-digit number on screen: "& e.NumberOrPasskeyAsString)
        If rslt = DialogResult.Yes Then
            e.Confirm = TrueEndIfElseIf e.AuthenticationMethod = BluetoothAuthenticationMethod.Passkey ThenDim line AsString = MyInputBox.Show("Device with address "& e.Device.DeviceAddress.ToString & " is wanting to pair."& _
              " Please enter the six digit number that it is displaying on screen.")
        If line IsNotNothingThenDim pk AsInteger = Integer.Parse(line)
            If pk >= 0 AndAlso pk < 1000000 Then
                e.ResponseNumberOrPasskey = pk
                e.Confirm = TrueEndIfEndIfElse' TODOEndIfEndSub

Secure Simple Pairing schemes

The pairing method used follows this pattern:
   if (either is pre-v2.1) then
      Legacy
   else if (Out-Of-Band channel) then
      OutOfBand
   else if (neither have "Man-in-the-Middle Protection Required") then
      (i.e. both have "Man-in-the-Middle Protection _Not_ Required")
      Just-Works
   else
      Depending on the two devices' "IO Capabilities", either NumericComparison or Passkey.
      Passkey is used when one device has KeyboardOnly -- and the peer device _isn't_ NoInputNoOutput.


TODO Add SSP forms descriptions.

Changes

As of February 2011 the callback mode supports Secure Simple Pairing on Windows 7 (and Vista SP2 etc). Various new properties have been added to the BluetoothWin32AuthentionEventArgs class: AuthenticationMethod, NumberOrPasskeyAsString, NumberOrPasskey, Confirm, JustWorksNumericComparison, ResponseNumberOrPasskey, etc. The AuthenticationMethod enum can have values: Legacy, OutOfBand, NumericComparison, Passkey, and PasskeyNotification.

Testing

I've managed to test: NumericComparison, and PasskeyNotification, as well as Legacy of course. When I first started testing I didn't have another Windows 7 box available with the MSFT stack so I tested with remote devices running BlueSoleil and Linux. (Note I have not managed to get authentication working with 32feet.NET on the BlueSoleil stack.) See the comments for one of our users who has: "tested SSP/NC between 2 Windows 7 PCs, a Windows 7 PC and an iPhone and a Windows 7 PC and a device we manufacture."

I have also tested the peer advertising each of the IO-Capabilities (using Linux BlueZ and its CreatePairedDevice API), and thus tested PasskeyNotification (when the peer advertised: 'KeyboardOnly').

I don't think it'll be possible to exercise the other methods: Passkey because that would need Windows to advertise KeyboardOnly and I can't find a way to do that. It also appears that Windows 7 might only have support for three I've tested, as MSDN for BluetoothSendAuthenticationResponseEx says: "Only the BLUETOOTH_AUTHENTICATION_METHOD_LEGACY, BLUETOOTH_AUTHENTICATION_METHOD_NUMERIC_COMPAIRISON and BLUETOOTH_AUTHENTICATION_METHOD_PASSKEY response types are valid." -- presumably there are two typos there: spelling "COMPAIRISON" and missing "..._NOTIFICATION" in the last.

New Post: Windows Embedded CE 7; Microsoft Socket; Client Connection

$
0
0
Dear sir or madam,

when i try to open a BT-Client on a Windows CE7 Device the creation of the client failed with the exception "32feet.NET does not support the Bluetooth stack on this device." When i look at the Radios theres only one radio on the device with the MS-Stack. Which should be supported according to the documentation.

The creation of the Socket failed with the MS-Error 10044 and 10047.
Has anyone has an idea to fix this?

New Post: how to circumvent Windows "A bluetooth device is trying to connect"

$
0
0
I'm attempting to use 32feet to open a serial connection to a bluetooth device. My code is very simple:
 using (BluetoothClient client = new BluetoothClient())
 {
                var address = new BluetoothAddress(0xecfe7e11c3af);
                BluetoothEndPoint endPoint = new BluetoothEndPoint(address, BluetoothService.SerialPort);
                client.Connect(endPoint);
                var stream = client.GetStream();
                System.Threading.Thread.Sleep(10000);
}
Whenever I hit the Connect line, windows pops up a bubble notification that "A bluetooth device is trying to connect -- click to allow this". If I click the notification, windows then brings up a wizard that ends up installing virtual COM ports on my system. Is there any way to disable this functionality through the 32feet library? I want the user experience completely contained within my application, and I do not want 2 COM ports installed each time I connect to a different device.

The client bluetooth chip is Bluetooth 4.0. I've previously connected to Bluetooth 2.0 modules where Windows did not interrupt the connection process.

New Post: Windows Embedded CE 7; Microsoft Socket; Client Connection

New Post: Windows Embedded CE 7; Microsoft Socket; Client Connection

$
0
0
I don't personally. Is the one radio returned by BluetoothRadio.PrimaryRadio?

New Post: how to circumvent Windows "A bluetooth device is trying to connect"

New Post: Windows Embedded CE 7; Microsoft Socket; Client Connection

$
0
0
yes it is. If i could use the BT-Serialport the problem where solved but when i try to create a BT-Serialport it failed with the windows error code 1060. So every try i've made to use the framework ends in an Windows-Error :/

New Comment on "Testing if a device is in range"

$
0
0
The library is good, but the following line in the above example is confusing: BluetoothDeviceInfo device = ... Can you please comment it or clarify what should be the RHS value?

New Comment on "General Bluetooth Data Connections"

$
0
0
IMPORTANT: The UUID you specify in the ServiceClass variable MUST be same on both sides of the connection. For example, I did this on C# .Net on a Windows 8 laptop with Microsoft BT Stack: string lgphone = "10:F9:6F:21:2E:2E"; // The MAC address of my phone, lets assume we know it BluetoothAddress addr = BluetoothAddress.Parse(lgphone); var btEndpoint = new BluetoothEndPoint(addr, MyConsts.MyServiceUuid); var btClient = new BluetoothClient(); btClient.Connect(btEndpoint); Stream peerStream = btClient.GetStream(); StreamWriter sw = new StreamWriter(peerStream); sw.WriteLine("Hello World"); sw.Flush(); sw.Close(); btClient.Close(); btClient.Dispose(); btEndpoint = null; Android: btServerSock = mBluetoothAdapter.listenUsingInsecureRfcommWithServiceRecord("LGP", java.util.UUID.fromString("00112233-4455-6677-8899-aabbccddeeff")); btSock = btServerSock.accept(); if(btSock != null){ Log.d(strX, "Null returned"); } InputStreamReader isr = new InputStreamReader(btSock.getInputStream()); int charRead = 0; while((charRead = isr.read()) != -1){ strOut += (char)charRead; } I hope this helps.

New Comment on "Supported Hardware and Software"

$
0
0
I am new for Bluetooth, I wonder whether your libraries support Bluetooth Low Energy (BLE 4.0)? I am trying to communicate with a BLE adapter by my C# code under .NET frame.

New Post: How to set sniffer mode on usb bluetooth?

$
0
0
Hi!


I'm using HCI sniffer tools on Linux, hcidump.

It is possible to achieve the same result using 32feel.net?

New Post: How to set sniffer mode on usb bluetooth?

New Post: How to listen to stream and read after x bytes?

$
0
0
Hi,
I am working on bluetooth for the first time, and I'm finding I have trouble with speed when I am reading an answer from the device after I send a question. I send a question and I expect 276 bytes to be sent back to me. At the moment I just use Read(buffer, 0, 276).
But the stream seem to take a while to fill, and I have to input a Thread.sleep(100), and since I might have to do this 65 000 times, it takes waaaaaay too long. How should I do this to make it effective??
I appreciate your help a lot!!

Best regards,
Elin

New Post: How to listen to stream and read after x bytes?

New Post: How to listen to stream and read after x bytes?

$
0
0
Thank you, I have tried this, but I didn't seem to change a whole lot, I think the problem might be the way we send data from the device.
Now trying to change it from ask-return-ask-return-ask-return to ask-return until stopped, I think this will improve it combined with the reading of smaller chunks for bytes.
But I've run into another question that might be able to ask while I'm at it?
I use a BluetooothClient and connect via that. Is there any way to set baud rate then??
Viewing all 469 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>