how to detect a bluetooth connection - Android Software Development

hello,
i search a solution to detect a bluetooth connection, device is equal.
all what i found is getBondedDevices() from BluetoothAdapter, but pairing this is not a connection...
thanks 4 help

Solved!
i use ACTION_ACL_CONNECTED and ACTION_ACL_DICONNECTED from class BluetoothDevice.
Code:
getApplicationContext().registerReceiver(receiver,
new IntentFilter(BluetoothDevice.ACTION_ACL_CONNECTED));
getApplicationContext().registerReceiver(receiver,
new IntentFilter(BluetoothDevice.ACTION_ACL_DISCONNECTED));

Android-Wireless
Helo Sir,
How to switch On Bluetooth and Wireless programatically? Even i can't switch on bluetooth and wireless manually in android.
Emulator shows error.

dineshsubramanian said:
Helo Sir,
How to switch On Bluetooth and Wireless programatically? Even i can't switch on bluetooth and wireless manually in android.
Emulator shows error.
Click to expand...
Click to collapse
Emulator actualy dosn't support Bluetooth, WLan and GPS!

CodeFlatter said:
i use ACTION_ACL_CONNECTED and ACTION_ACL_DICONNECTED from class BluetoothDevice.
Code:
getApplicationContext().registerReceiver(receiver,
new IntentFilter(BluetoothDevice.ACTION_ACL_CONNECTED));
getApplicationContext().registerReceiver(receiver,
new IntentFilter(BluetoothDevice.ACTION_ACL_DISCONNECTED));
Click to expand...
Click to collapse
This only works if the device isn't yet connected. If the device is ALREADY connected when your app starts, how do you detect that, without starting a discovery?
been searching for a few days for an answer to this. Anyone got one?
Thanks
Scott

No one has any ideas on this? A month of searching has so far proven futile, but I can't believe it's not possible...

On the Google android developers site there is a complete example (a bluetooth chat).
http://developer.android.com/intl/de/resources

Hi!
I'm trying to connect my phone (HTC desire running Opendesire last update or HTC stock 2.2) to a serial to bluetooth converter module.
It seems to me that BluetoothChat sample is a good point to start as this application sends bytes over bluetooth.
That's just what i want to do: send some bytes from phone, receive some bytes from the module
I tried to run the Bluetoothchat sample on my phone:
Discovering and pairing the module is ok, but I'm unable to open a connection.
Anyone ever tried (and get success) to do same things as me?
Thank you.

Delvorak said:
This only works if the device isn't yet connected. If the device is ALREADY connected when your app starts, how do you detect that, without starting a discovery?
been searching for a few days for an answer to this. Anyone got one?
Thanks
Scott
Click to expand...
Click to collapse
Take a look at my SpeakerProximity Project => http://code.google.com/p/speakerproximity/
I faced the same problem and the solution that fitted the best was using BT connect/disconnect receivers that always get triggered and update a shared preference.

Hi,
I'm still having some issue with the bluetoothchat sample from sdk and bluetooth to serial converter module.
Now it works fine with AOSP rom but i'm still unable to make connection with HTC stock rom.
I've tried with a friend to run the application on a galaxy spica and we had the same issue. First the application didn't even start on spica and we had to change permissions to avoid Force Close.
Somebody knows what's wrong with bluetooth and HTC or Samsung?
Thank you

detecting bluetooth STATE_ON
in your OnStart() use :
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter != null) //if null device does not support bluetooth
{
if (mBluetoothAdapter.getState()==BluetoothAdapter.STATE_ON) {
//do stuff
}
}
I use a bluetooth listener for the STATUS_CHANGED event to check if BT is switched on.
If so, i enable my scanning avtivities, else i disable them.
Greetz,
Mike

STATE_ON is not the same as connected, though. (I think).
Personally, I've be having trouble figuring out the disconnect event to listen for, but I think the ACL one is what I need. Will try to remember to post back if I get it working. Damn WiFi process always interupts my transfers epecially when email decides it's time to sync.
Anyways, one tip for those having trouble with the BluetoothChat example is that for some reason you dont want to be listening for a connection at the same time as trying to make one. If you try the BluetoothChat example it actually almost always fails to connect. But if you make sure only one device is using listenforRfcomm... and the other is connecting, you'll connect fine.
The Spica thing is some bug with that phone specifically, though I think some people have solved it with some type of strange method reflection. Check stackoverflow for spica/bluetooth.

Just an update for my problem the ACL braodcasts were just what I was looking for though the diconnect broadcast is sometimes very slow to trigger.

Related

PAN and Bluesoleil stack

I own 2 Magician devices (A and B), both Bluesoleil stack installed and working. Problems arise when i try to connect the two devices directly via pan. On Device A i initiate the PAN connection via "Bluetooth Manager->Device B->Scanning Services->PAN". Now Device A shows (status) an PANGN connection outgoing and B has an PANGN connection incoming. Device A starts IE and a getting IP dialog right after connection initiation.
So far so good. But both devices are on completely different subnets. While Dev. A is on sth. like 169.254.182.118, B's IP is completely different. Now if i try to fire up a game of snails for testing on A, i see the game open on B but joining leads to system hang. (Tried Warfare Inc., same results.)
As i am pretty new to this topic, maybe so. can tell me what went wrong... is it even possible to build up a PAN that way?!
Best Regards,
Regi[/b]
Very intresting.
I played Snails between Magician and Windows XP PC and all was good.
Try to join from device B to Device A, or try to disable DHCP service and setup IP manually...
thx for your reply. your answer triggered sth in my ol'rusty brain ... There ARE options to change ip/mask/gw etc. but they aren't to be found under bluesoleil settings
lol
thx again,
regi
I just noticed something weird: both of my Magicians have the same hw-address: 00:02:5B:00:A5:A5... that's why my PAN network (using Bluez stack and Debian) always keeps disconnecting one of the devices. it thinks it's the same device. any way to change this address?
I just noticed something weird: both of my Magicians have the same hw-address: 00:02:5B:00:A5:A5... that's why my PAN network (using Bluez stack and Debian) always keeps disconnecting one of the devices. it thinks it's the same device. any way to change this address?
i think that is also the reason why i am not able to play games ....
Maybe this address is hardwired in the BT stack. Chances are you find this string in the .CAB used for installation. If so: you can change it to your liking.
We have the same problem here, also opened a new topic about this.
A friend and I have a Magician, and like yours the same bluetooth adress
(00:02:5B:00:A5:A5)
The weird part is that when we just both installed bluesoleil, we were able to play warfare over the PAN.
But 2 days later, it stops working??? As you said, every time one tries to connect, it hangs. Have to reset every time.....
I tried to change the adress in the register, but no luck so far It changes back by itselves?
Does anybody know a solution? And can someone confirm that the problem is caused by the same device name?
thnx

TomTom - GPS receiver with short memory?

Hi,
I've trawled the forum and I've followed all the TomTom setup procedures. The Problem is they seem to be for people who can't get TomTom working at all. I can get it working, just awkwardly.
Once I pair with my GPS receiver and go into TomTom i can get a connection. However when i quit TomTom and turn off the GPS it seems to forget. Next time I turn it on I don't get a connection.
The way I understand TomTom is that it seems to wait for the GPS receiver to contact the phone. This seems odd as I would have thought the phone would be the one to initiate contact.
Anyway my GPS receiver just seems to forget what phone it was connected to. TomTom obviously isn't forgetting the port, windows obviously isn't forgetting the pairing. But Every time I use it I have to re-pair the receiver (thus reminding the receiver of the phone it's supposed to be bonded to). It's beginning to drive me a bit insane.
Anyone else have this issue? Perhaps it's to do with my incoming and outcoming ports? Hopefully someone has already solved this? Not seen any references to it anywhere.
Lewis
Hello,
Which version of Tomtom are you using ? The last one (5.21) ? If not, try to upgrade and try again.
Yep 5.2 latest release.
I was hoping upgrade would fix it but alas no.
Lewis
BigDamHero said:
Yep 5.2 latest release.
I was hoping upgrade would fix it but alas no.
Lewis
Click to expand...
Click to collapse
Don't mean to be picky, but 5.2 or 5.21?
I've held off installing TTN on my Wizard, as it works fine on my iPAQ 4700, I have a cradle for that, and according to ttcode, my current device is actually my old 3970, not the current iPAQ... Last week, I had a couple of hour drive to do, so I thought I'd give it a whirl. After an email exchange with TomTom support (who were more helpful than I'd originally given them credit for), I had a new activation code for the Wizard. Here's what I did, from a fairly recent hard reset with no previous TTN install whatsoever. Skip the mail if it doesn't look helpful, but I'll detail my steps in case it helps anyone else...
Although I believe the PC install is mended in 5.21 I copied the map and voice cab files from the CD to my SD card and installed them from there. The GPS drivers and main app I installed from the download I got from the TomTom support site by running the setup util on my PC. Once everything was installed, I moved the maps which seemed to finish up in a sub-directory on the card to the root of the card.
I paired the GPS (my old Emtac BT one) and selected serial port profile. I tried all the offered serial ports in the "Other BT GPS" list in TTN but none worked. Then I went to 'COM Ports' in Comm Manager/Bluetooth Settings and selected "New Outgoing Port". I picked the GPS from the list of paired SPP devices, and it created a new BT COM port on COM6. That definately hadn't been in TTN's list of BT com ports before, but is now there in the list with about half a dozen others. I selected that in the "Other BT GPS" list of BT ports, and TTN connects to the GPS each time.
As I said, I'd recently hard reset the device to try and prove a problem with my BT car-kit soit's quite possible the clean install was the secret, but try creating a new outgoing COM port against the GPS and see if TT remembers that...
Dox
BigDamHero said:
Hi,
I've trawled the forum and I've followed all the TomTom setup procedures.
Click to expand...
Click to collapse
Which?
There are 2 general ways to set it up, 1 works 100% (i use it so know it does ) 1 i dont use and have never tried so may well work in the reverse direction and be causing you errors.
The way i set up tomtom; pair the BT GPS. Open an OUTGOING port to the BT GPS, set my GPS as OTHER (wired/cable) NEMA device (NOT bluetooth) in TTN5. now my tomtom connects to the bluetooth, not the otherway round. This method has thrown up no errors for me at all.
If you have followed the reg edit/hack to show the GPS page in connections then i dont know how the settings differ and the possible results this could have on connection issues.
Let us know which way you are going
I have the exact problem as BigDamHero. Each time I wanna use TTN, I need to delete the previously paired BT GPS and then pair it again, otherwise the TTN will just say No GPS Device. I use TTN v5.21 and Wizard with Windows Mobile 5. I tried my BT GPS device on my brother's PDA which runs on Windows Mobile 3, and it connects like a gem every time. I am also looking if anyone has solved this issue, cos it is tedious re-pairing every time.
Had the same problem until 5 mins ago! Found an explanation in another thread, but only in Dutch..
Here's how to do it:
Turn on GPS
Activate bluetooth on device, go to BT parameters, delete previous pairing like you're used to
Create new pairing, choose GPS, enter passkey, check Serial port in services, go to COM ports and add outgoing port (e.g. COM6) like you're still used to :roll:
Add an incoming port too (e.g. COM7) <-- Here's the trick!
Set your GPS apps to use COM6 (the outgoing one)... and here you are! This time it will work, you can turn off GPS and device bluetooth, turn on again and it will connect by itself.
If you want a bit more you can activate GPS panel, set program port to COM8 (then you will have to use this in your apps) and COM6 as hardware port.
Everything works fine now!
hey man, wot a coincidence....i also just read that post which had the dutch explanation.....BUT however, it's not working for me.
toneslee said:
hey man, wot a coincidence....i also just read that post which had the dutch explanation.....BUT however, it's not working for me.
Click to expand...
Click to collapse
I did everything in the list except for creating the incoming port and it still works everytime (I know that's no consellation to you). I wonder if something else you've installed, or the way you installed the app is causing the problem? Is it worth a hard reset and trying the entire install on a clean wizard?
Dox
A friend didn't need the incoming port either. I believe it has something to do with the GPS, as he has a different brand than me.
With mine, before adding the incoming port if I started an app without erasing/redoing the pairing before I would get a notification saying "Navman GPS wants to connect" and asking me to pair. It would keep coming every 10 seconds whatever I did.
BigDamHero, what brand / model of GPS is it?
Maybe we can see if anybody here, or over on pocketgpsworld has been able to make the same combination work and if so, what they had to do to get it to fly...
Dox.
well, tomtom was the very first thing I installed when I got my new vario. it was only after I got tomtom fully working (but still need to re-pair everytime), then I installed a couple of simple Card games.
toneslee said:
well, tomtom was the very first thing I installed when I got my new vario. it was only after I got tomtom fully working (but still need to re-pair everytime), then I installed a couple of simple Card games.
Click to expand...
Click to collapse
A quick glance at pocketgps suggests others are having similar issues. There's a thread here that suggests leaving it a while, and I seem to remember other GPS issue threads saying power up the GPS and let it get a fix before starting TTN. A more detailed probe round the forum will probably show more of the same.
Dox
I've just flashed my Qtek 9100 to a new ROM, (the O2 one), and since then I've been getting this same problem. With my previous ROM everything worked fine. I was able to turn of either my PDA or GPS, and they would always auto-reconnect in a few seconds. Looks to me like something broke during one of the ROM changes. Which ROM versions does everyone with/without this problem have?
By the way, I have a BT77 GPS.
Hey sorry for the total lack of reply. Been snowed under with exams.
Ok I tried most of what you guys said but didn`t work. BT ports aren't available to select as hardware ports.
However I have managed to solve it. The key was to pair the GPS, and create an UNENCRYPTED OUTGOING port. That's all. Previously I had encrypted ports outgoing and incoming. My GPS applet in control pannel is set to none so it,s nothing to do with that.
I don't know what my GPS is. Its unbranded. One of the cheap common ones.
Hope this helps some people with the same problem.
Lewis

Can't connect Bluetooth GPS Receiver

Hello
unfortunatly the search didn't work for me to find a solution (maybe anybody can help me..)
i simply want to pair my Universal with my bluetooth gps receiver.
in settings/connections/bluetooth i added a new device.
it took a while, then it found my gps receiver and asked me for passkey. i used "1234" - but i am unsure, if that was the right key (i'm 80% sure..)
after that i got a new entry in the list of the avaible devices.
so far so good... BUT:
the gps receiver only appers as "disconnected". when i want to "connect" to it, it says "Your device did not connect with GP-700. The connection failed or the passcode is incorrect."
maybe the passcode is incorrect, ok. but i can't insert a new passkey, because it won't ask me for new entry after searching for new devices. i also can't delete the gps receiver entry.
I checked the box in "select services to use from this device. Serial Port". is that correct?
...hmmm it has to be so simple but i can't pair... gr......
please help me
nobody knows an answer...? ;((
hi, we maybe able to help but need more info as i would for sure. what rom are you using? and possibly what radio version? i use a bt gps with mine and passcode is 1234. not sure if thats the case for all though. depending on the rom im using mine shows as disconnected sometimes but i also have to create a valid com port to use with it. hope that helps.
Also what program are you using with you BT device? Mine pairs with '0000'.
If I use Route66, I don't even need to pair it.
When using iGo8, I do pair it.
When using Google Maps, I also need to add a COM port (I use 1 as some programs can't use 0 - eg, MemoryMaps).
Hey, thanks for answering my question.
i am using Tomal v8.90 (light). My radio version is (after unlocking) 0.00.00. Should i flash it back to 1.18? do i have disadvantages?
i wanted to use tomtom..
hope these information helps
I think there's your problem. I'd flash either 1.15 or 1.18 radio.
hm... anybody can help me..?
ThaMasterT said:
hm... anybody can help me..?
Click to expand...
Click to collapse
Flash an updated radio...1.15
i flashed to 1.15 succesfully.
i found out, that 1234 for my device is the right passkey.
i connected in connections/bluetooth to my device (like i wrote above) and it says "connection successful". after that my device is listed under "disconnected" again. furthermore i can't connect to it, when i click on "connect" in the settings. i can't connect to it in tomtom, too...
when i click on the device (listed under connection-settings in "disconnected") the partnership settings will be displayed. here i can select services to use from device. it provide me a list with one item to check: "serial port". but even if i check or if not, it wouldn't affect anything(?). i simply can't connect to my device...
hey,
i solved that problem. i choosed "the right" com port to use the receiver.
thats a little weird, cus i already choosed some random com ports before and it never worked for me. unfortunately i didn't get some useful error messages or something from tomtom or other programs. now i tried a different port again and suddenly it worked...
sorry for the trivial problem and thank you very much for helping me.
btw: the device is still listed as "disconnected" in settings. who the **** cares...
i have the tomtom gps mkii sirf III and i don't get it paired or manually connected either, but then, when i installed the tomtom software, i found out, that it does not need to be paired in the windows settings first. ok, you might say, this is a coincidence, because tomtom works fine with their own hardware, of course. but no! in my settings there is also an "external gps" point, and all you need to do is put in a proper port and speed and it'll work. the easiest test for that would be google maps. in the beginning i also worried about pairing and connecting, but i found that i didn't have to do that.

[Q] Bluetooth com port reset

Dear All,
I have a great problem with the Toshiba htc hd2 with the Bluetooth com port.
The question is so important that I can arrange to gift a new htc hd2 to the solver, I'm desperate and here is my story:
My company buy 10 htc hd2 with windows mobile 6.5 to use it for sending data grabbed from an external ecg/cardio measurement.
The software solution was to use the cardio device with the bluetooth. We developed the program that listen to the Bluetooth com port and
acquire signals from the cardio device using c#. With the visual studio mobile emulator everything works fine, we are able to use Bluetooth configured com port and
to acquire data from the device, using his proprietary protocol.
However when we move to the HTC HD2 we find the following problem. We are able to connect the HTC HD2 with the cardio device after doing the pairing. We write in a config file the name of the com port. We acquire data and everything is works great.
Unfortunately after this first step configuration when the Bluetooth connection is closed and we try to reopen it again it seems that the com port previously configure is not in the system so we need to
redo the pairing and to reconfigure the port name. This is a great problem because the system will be give to elderly people so it is impossible to teach them how to reconfigure the Bluetooth com port every time they do the measure.
Does anyone found a similar problem?
Again I can arrange to give to the solver a new htc hd2
HELP!!!!
Piero
Can you post the full name or a link to the cardio device you are using? This will be helpful to anyone that knows how to maybe fix or create a work around for your issue.
the problem is that the device is not a commercial one but a research project one
again I pointed out that with pc and other mobiles the connection remain stable it seems a HTC HD2 configuration issues.
paolgiacometti said:
the problem is that the device is not a commercial one but a research project one
again I pointed out that with pc and other mobiles the connection remain stable it seems a HTC HD2 configuration issues.
Click to expand...
Click to collapse
Oh I see then Is there any way you can post the bluetooth specs and protocols for the device in question as one will need to know this information to make a work around or a straight forward fix for your issue.

[Q] Bluetooth problem

Hi,
I'm sorry if this has been asked before. I'm having problem with my bluetooth. I'm running android version 2.3.4 on SD (HD2 Leo). I've got no problem running it on wm.
Despite setting it to discoverable, I can't detect other devices or pairing with them neither can others find me. I can't use my bluetooth headset and whenever I want to receive files from another party, I would need to switch the phone back to WM so that I can receive via bluetooth transfer
Appreciate your kind advice. thanks!
You need to make your phone to be discovered. Setinngs. Wireless. Bluetooth settings.
to receive files from other phones you need to have FTP connection enabled, in sense it's easily done. in none-sense I haven't been able to make it work manually, but some apps like "bluetooth file transfer" do it conveniently.
try that out
it would be better if you pair with the device you want to receive files from, that means set the other device to discoverable, do a search for devices, then pair with that device. it's not mandatory, but since you might be connecting with several OSs this way is 100% working.
thank you for the replies
"bluetooth file transfer" really does the job! Without it, I can't even pair with another device. My laptop is able to search for the HD2 but can never make any connection with it.
yes that's common,
enable FTP in the app settings just in case it isn't.
if you're using a sense build/rom then it won't work.. the workaround is to connect your phone to the laptop your phone can search and see the laptop's bluetooth, and you can access shared folders on it through BT file transfer app
unfortunately i'm using a sense rom i will try that method of connecting it to the laptop. thanks!
I like sense better than anything else, so I can live with that small issue

Categories

Resources