Bluetooth Service Name not shown by HTC Wildfire - android

I'm working on an app that needs to provide a Bluetooth ServerSocket to some other device.
The device I have to work with establishes the connection ignoring the uuid and only looking for devices with correct Service Name.
I open the BluetoothServerSocket with the following command:
UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
tmp = mBluetoothAdapter.listenUsingRfcommWithServiceRecord("PWAccesP", uuid);
My problem is, that the ServiceName is not published by the Android SDP. When I query the available services using sdptool, I get the following output:
...
Service RecHandle: 0x10008
Service Class ID List:
UUID 128: 00001101-0000-1000-8000-00805F9B34FB
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 6
So the Service is available, but the service name is not listed and so my device can't connect.
I'm working with an HTC Wildfire with Android 2.1.
My question now is, is this a problem of the HTC Bluetooth stack, is it a problem of the Wildfire or is it a problem of Android 2.1?
Unfortunately I have no other phones available to check so I ask the community to help me out here... Has anybody encountered this before or knows how to get the Service name to show up?
Btw:
I was able to verify that the BluetoothSocketServer connects using a different device that connects by uuid rather than by service name.
Thanks and regards,
Michael

After updating my Wildfire device to Android 2.2, the Bluetooth Service Name is now connected correct. If the fix came from the Bluetooth stack or Android 2.2 is not clear to me but doesn't matter since it's working...

Just tried to work some more with the PWAccessP devices on Wildfire with 2.2 (and service name correctly shown in sdptool). Unfortunately I also wasn't able to establish a connection to the device.
I have two different PWAccessP devices here and both are not connecting to the Wildfire.
Additionally I tried to connect them to my laptop using a server socket perl script I found somewhere. I was able to connect to my laptop using a third device, but the PWAccessP's didn't. I have a short activity shown by my BT-manager but I guess that's only the sdp part, but no pairing/connection is established.
However, I have a running app for Blackberry that successfully co-operates with the PWAccessP-devices, so it must somehow be possible. (I have the source code but it's not really helping for android...)
If somebody finds a solution to this problem, please, please let us know.
Regards,
Michael

And a final answer from my side (if somebody else is still working on this):
I tried it now on a Nexus S with Android 2.3.x and I finally was able to connect the PWAccessP devices. Took me some time to pair and the phone has to be visible all the time, but at least I got it working.
Regards,
Michael

I suspect that the problem lies in the particular hardware below Android, as there are at least some Android phones known to work with these devices (e.g. Motorola Droid).
Anybody tried giving up on the Android API and just using Java with JSR-82 (Bluetooth extensions) to receive data from these devices on Android? It may be true that this hooks in differently than the Android APIs, and might just work...

Related

How to use android as ANCS content provider?

I'm trying to demo android side service (content provider in ANCS lingo), that communicates with embedded device that supports Apple Notification Service (ANCS) notification consumer. Reason for this is, that the embedded device only supports ANCS. As the ANCS BLE side things are publiced by Apple, this should be possible and I've already added that service + associated characterics to android side gatt server. Embedded device is nordic nRF52 and SW is nordic ANCS demo. Demo works OK with iPhone and apparently with the desktop version of nRF control panel (if added with nordic supplied config and if you have windows machine, which I don't).
However I cannot seem to be able to bond the device with android, that's required before connection. The advertisement is in limited discovery mode (before bonding) so I cannot find it via regular scanning from settings. Also bonding from java code doesn't work. With mBluetoothDevice.createBond() I get ACTION_BOND_STATE_CHANGED callback with state 10 (BluetoothDevice.BOND_NONE) with old state 11(BluetoothDevice.BOND_BONDING). Apparently I would need to exchange keys here, but no idea how to do that.
Also dunno if anyone has done this same exercise before, but any other tips would also be appreciated! Thanks!
Problem was that the phone BLE stack was corrupted or in some invalid state. REboot and removing battery solved the issue with the bonding.

Bluetooth: Connecting without UUID

Yesterday i learned that i need to know the UUID of the Device which i want to connect with but that leaded to some questions i could not answer myself and i could not found it in the web either.
If i connect two devices which are running the same Software or App or anything else it is easy to hardcode those UUID's but what if it is not the same Software or the same App? For example if i transfer contact data from my Android Phone to a friends Apple iPhone, how could my Android Phone know the UUID of the iPhone?
Another example would be my Bluetooth-Headphones. I never installed any Software or any App on my Device but after the Bluetooth-Pairing my Headphones are working. How could my Headphones know the UUID of my Android phone?
Okay, got it: Service Discovery Protocol (SDP)
There are several fix UUID's that can be used for different services.
So what i have to do for my purpose is just to use my own UUID on
each device.

Bluetooth pairing without pin code

I am a newbie working on bluetooth, and I would like to get some advice regarding the pairing process. I have googled this but I did not find much information ...
My goal is simple: I want to do a pairing to a headset without entering a pin. I have an android (nexus S running Android 4.1.2) and an iphone (3GS running ios 6.1.3).
If I connect to a device like a Jabra BT3030 (bluetooth headset), the pairing is performed without asking me any pin code.
Now I want to do the same from an Ubuntu (with BlueZ 4.6), i.e. I fake a bluetooth headset by enable only the correct service and so on. I disabled the authentication.
When I pair my iphone to this device, no pin code is required (as expected), but when I connect from my Android device, it still asks me for a pin code, whereas I would expect to have the same behavior than with the Jabra.
Would you have any idea of what I am missing here?
Thanks in advance,
Best regards,
Guillaume
Android Uses UUID for pairing and connection for two devices...for two devices conneting, one device should send request and one should accept and for both UUID should be same...
Like also used bluetooth there I need to intall my android app to both the devices then only I can pair the two devices...because only that app is knowing the UUID. and for iPhone it may be different so if from the native code of iOS u can know the UUID ur android device can be paired through app...
The Standard password for a Jabra BT3030 is 0000. Many other bluetooth devices have a standard password. For the Case a system only accepts devices with passwords, and u cant enter a pasword on a device without keys :D
Maybe the solution is implementing the standard passwords for mutliple devices and use them instead f forcing a connection without password.

Adapting Android BluetoothChat example to single server, multiple clients

I'm attempting to adapt the BluetoothChat example that comes with the SDK to a single-server, multiple-client configuration. I'm having issues and hope someone can help.
I've created two distinct apps, a server and a client, rather than have a single app function as both server and client, as in the example. So the upon starting the app, the server creates a bluetooth service, which creates a new AcceptThread, which listens for incoming connections. I made a couple of modifications to the example code so that the AcceptThread continues to listen, even after the first connection is made (the example stops listening after the one connection is made, because it only needs to establish connections between two devices). I created an ArrayList to handle the multiple connections. Each time a new connection is attempted from a remote device, a new ConnectedThread is created and added to the list.
The first client connects just fine.
When the second client attempts to connect, the connection fails. The log output is:
D/BluetoothEventLoop( 140): Device property changed: <device address> property: Connected value: true
I/BluetoothService( 140): ACL connected, mAclLinkCount = 2
D/BluetoothEventLoop( 140): Device property changed: <device address> property: Connected value: false
I/BluetoothService( 140): ACL disconnected, mAclLinkCount = 1
So it looks like the second connection attempt is successful, but then it is immediately disconnected. This looks like it's happening at a low level, outside anything the code is handling. This happens with a number of different types of test devices, so I don't think it's due to a particular firmware or hardware issue.
Can anyone help with this?
Also, can anyone point to an example of a server->multiple client connection example using bluetooth with Android? I came across an Air Hockey example:
http://code.google.com/p/apps-for-android/source/browse/#svn%2Ftrunk%2FBTClickLinkCompete%2Fsrc%2Fnet%2Fclc%2Fbt
But this project is very glitchy on my test devices and the actual game won't display properly. Does anyone know if there is an example of BluetoothChat extended to handle multiple connections?
UPDATE:
In attempting to solve this issue, I believe I have successfully extended the official Android Bluetooth Chat example to work with a server connecting to multiple clients.
I've uploaded my modifications to github here.
One device acts as the server by selecting "Menu>Make discoverable". Each client then connects by selecting "Menu>Connect a device". I was successfully able to connect my Motorola Droid and HTC Eris as clients to my Samsung Galaxy Tab 10.1". Each message sent from a client displays only on the server. A message sent from the server displays on all clients.
This was a tedious process getting it to work at all. Connectivity with the HTC devices is sporadic, though. I've read elsewhere that bluetooth on HTC is buggy, so I'm chalking it up to that.
Hopefully someone else will find this example useful. If you have any questions, suggestions, or other feedback, please let me know.
I tested your code. As, you said connecting HTC as master was a problem. I made Samsung S3 as master and HTC as client. it worked. But i tried again with a Sony Ericsson phone. No other device could successfully act as master.
S3 has Blutooth version 4.0 other have earlier version. Do you think the problem is because of Bluetooth stack?
I need to use this concept in a project where the devices will be custom made. Trying to find out weather the problem is related to vendors ( HTC, Sony) or its related to bluetooth stack. and i don't know how to find out. This is not documented. :(
Has anyone faced this?

Android Bluetooth Cross Platform Interoperability

I have a Bluetooth service that I programmed for .Net on a Windows machine and I would like my Android 2.1 phone to connect to it. The server is listening for the same UUID which the Android is using to connect. But the connection is failing.
When I try to connect to devices that are not listening for that UUID, I get an exception with the message "Service discovery failed", but when I try to connect to the server that is listening for the right UUID a message box pops up saying:
"There was a problem pairing with bluetooth device."
And I get an exception with the message "Connection timed out." So it looks like the server and the Android are communicating, but there is some sort of failure during handshaking. I know that the Android requires that the server is paired with the phone and also encrypts the communication channel. Does anyone know which specifications are used to do this? I would love to get my server to respond properly to the connection attempt.
Thanks!
I figured out what was going wrong. The problem is that you have to pair the remote device with the Android before you try to make the connection because the pairing dialog does not always work. I am not sure if the bug is on the Android side or on the other device's side, but I was never shown the dialog that asks for the authentication code or that displays the authentication code on either device. So it looks like there are some compatibility issues out there. But if you explictly pair the devices beforehand, then the connection works.
You're right. I'm having the same issue here while trying to connect to an RS232 device with BluetoothChat sample program.
1- If not bonded, I get two errors in a row :
03-03 13:38:20.020: ERROR/BluetoothService.cpp(2077): stopDiscoveryNative: D-Bus error in StopDiscovery: org.bluez.Error.Failed (Invalid discovery session) // Probably because we're calling cancelDiscovery() as a "security" (it's already been cancelled at some point beforehand)
03-03 13:38:20.040: ERROR/BluetoothEventLoop.cpp(2077): onCreateDeviceResult: D-Bus error: org.bluez.Error.AlreadyExists (Device already exists) // This I don't understand
2- Once bonded through Bluetooth Settings, no problem. The connection is made perfectly and the program works.
I tried to check out the Android Source by myself but, given that I'm a newbie, it's kind of tough. If some experienced guy could work it out, it'd be great.
To answer Tomas - The SPP (Serial Port Profile) profile is broken on several HTC Android models, even 2.1 versions, but it is not consistent among the models.
HTC Desire - Does not work.
HTC Legend - Bad, but works for a while?
HTC Hero with custom ROMs - Some work well, some not at all and some badly when doing sound at the same time.
All the previous answers are on the mark; essentially, pairing is required before connect.
However, I was getting the error even after pairing. (I had first tried to connect without pairing).
The workaround was to reboot the phone once. And now it is able to connect to the paired device fine. Sounds simple, but I spent quite some time debugging it. Hopefully useful to someone out there.

Categories

Resources