Turn on / off Bluetooth - Windows Mobile Development and Hacking General

Hello,
i want to turn on bluetooth on my Touch Pro 2.
I tried it with BthSetMode( BTH_CONNECTABLE ); but doesn't work. nothing happen.
The function returns (int) 1359:
ERROR_INTERNAL_ERROR --> An internal error occurred.
Is there another way to turn on bluetooth on my phone?
Thanks
MC-Bechtmann

ok, i found a solution myself. I have to use the widcomm SDK. Now, i can start Bluetooth with creating a new CBtIf Object. But how can i turn off Bluetooth?
I tried it with WIDCOMMSDK_Shutdown(), but it doesn't work. i close my application and bluetooth still turned on.
How can i turn it off?

MC-Bechtmann said:
ok, i found a solution myself. I have to use the widcomm SDK. Now, i can start Bluetooth with creating a new CBtIf Object. But how can i turn off Bluetooth?
I tried it with WIDCOMMSDK_Shutdown(), but it doesn't work. i close my application and bluetooth still turned on.
How can i turn it off?
Click to expand...
Click to collapse
I have tried the same thing with no luck. Has anyone found a solution to this?
thanks

uh.... why dont you just go into your com manager and turn the bluetooth on and off?

Related

Microsoft Bluetooth Driver??

I just upgrade my magician to 1.13 w/ BigStorage. And now I cannot activate my bluetooth. Everytime BT was enabled, warning message pops up says "Please turn off Flight Mode first!" and BT changed to disabled.
I've tried to instal Bluesoleil driver and it works perfectly. However, everytime I switched to Microsoft driver, the problem occurs again. And BCHS (bluetooth stack) for A2DP didnt work either since it's using ms driver.
I've also installed BTHUSB_PATCH_AKU26.cab and no change at all. Maybe I missed some cab files from extended rom? Anyone have the same problem. Thank you.
Have you used a 3rd party program to turn off the radio or switch on/off flight mode?
I did that and it confused the heck out of the Magician ... it'd think the phone's in flight mode when it isn't, and kept telling me turn off flight mode before turning on BT ... (now, I never understand why you have to turn radio on to turn on bluetooth ... that's just stupid)
Anyways, since I switched to PhoneAlarm and used that to turn BT on and off that problem's gone away.
Good luck
I used PocketZenPhone. It has a function to turn on/off Flight Mode.
So in this case, I have to hard reset and start from the beginning, right? . Uhhh...it will take times for me to do it since all my works depends on my magician.
Any other posibilities?

Zombie BA

hello every 1. I have a BA running windows mob 6.1 pro and everything is working fine except t e fact that when i put the device on standby, it is always turning itself on again. does this happen to anyone? thanks
hi
any test?what do mean?
Zero|Cool said:
hello every 1. I have a BA running windows mob 6.1 pro and everything is working fine except t e fact that when i put the device on standby, it is always turning itself on again. does this happen to anyone? thanks
Click to expand...
Click to collapse
which ROM do you have?
Do you happen to have BigMike bluetooth running?
standy..you mean you press the power button and the screen goes off, right? And then it turns on by itself? Did you check if your bluetooth is on? Because I experienced this too before, if I left the bluetooth on and I turn off (stand by) the BA after a while it will turn on itself. Hope this helps. Cheers.
Try going through your power management under settings.
You might have tick a few things there.
I was getting this trouble too!
As Resident evil... on nights my device wakes up and begins screaming STARS!!!!
I just call Claire redfield and Alice and they burn on its head! PUMMM!
jajajaj
Well... check out your settings if you have a program runing under... and it needs conections via BT, Wi-fi or GPRS... your device gonna wakes up trying to get conection all the ways it can... if nothing is runing behind maybe was a bad flash... reflash it...
Hope all we can help you...
We are like a squadron supporting forces... Huh im playing too much Acecombat 5....
It could either be Bluetooth running and also it could be some appointment/message turning your device on. Also, do you have your device cradled? ActiveSync (if connected to PC) will turn your device on to sync.
Hope this helps
red_hanks said:
standy..you mean you press the power button and the screen goes off, right? And then it turns on by itself? Did you check if your bluetooth is on? Because I experienced this too before, if I left the bluetooth on and I turn off (stand by) the BA after a while it will turn on itself. Hope this helps. Cheers.
Click to expand...
Click to collapse
It's exaclty that. I read somewhere it has something to do with the bluetooth stack, I turned off BT and it stopped lol However I need BT always on as I use an external sirf star 3 gps and I pair up the mobile phone with my car. Can anyone tell me how to fix this? Tks
Zero|Cool said:
It's exaclty that. I read somewhere it has something to do with the bluetooth stack, I turned off BT and it stopped lol However I need BT always on as I use an external sirf star 3 gps and I pair up the mobile phone with my car. Can anyone tell me how to fix this? Tks
Click to expand...
Click to collapse
There is no fix. Since WM5, the BT driver requires that it be turned on periodically or else it turns itself off. All ROM cookers (AFAIK) use the big mike fix driver to keep the BT alive.
motisu said:
There is no fix. Since WM5, the BT driver requires that it be turned on periodically or else it turns itself off. All ROM cookers (AFAIK) use the big mike fix driver to keep the BT alive.
Click to expand...
Click to collapse
I read somewhere that if you installed another BT stack that eventually it would solve the problem? Is this true?
ok there is fix but i do not advice you to use it if you use BT handsfree - because with original driver BT turns off when device get in standby and this one keeps it working
you can install S2U2 and set:
Lock when device wakes up: ON
Power Off in: 5s (this is the minimum).
this is not a solution, but more like a workaround...this works for me well...

Bluetooth On and Off, NOT Toggle

Hi all. I have seen many bluetooth toggle solutions and many of them work great. But I am looking for a simple solution to turn BT on, not to toggle it. This is why. I use profiles in Inesoft Phone a lot. But their BT on and off do not work due to the TP2 not using the WM stack. So say I am switching from one profile where BT is on to another where BT should stay on. Toggle does me no good because it will sometimes turn BT off when I really wanted it to stay on. There is a native app on my Tilt 2 in \Windows called TurnBTOff.exe. But there is not one to turn it on. I must have 5 different BT toggles on my phone but nothing to turn on only.
Any ideas for a TurnBTOn app? I am hoping for the typical small footprint cab utility and not another install of an app that does 20 other things besides BT on. I have found some 'on only' cabs, but not for the widcomm stack we have.
try this out. i am downloading it right now myself. it looks like it creates an actual exe shortcut that you can assign to your softkeys or certain hardware buttons to turn BT on and off. i know you mentioned you only need it to turn ON but having both might be good too...
Thanks for the info. But it looks like all of those are toggles, not an "on-only" BT exe. So I don't think it will solve my issue posted above.
Great fix for CHT 1.8 Bluetooth Issue
Thanks for the link! Installed that simple program, and now the Bluetooth toggle switch on my Cookie Home Tab works great on my TP2/Tilt2.

how to detect a bluetooth connection

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.

[Q] Cannot turn on bluetooth w/ HD2O's 1.23b ROM?

I flashed HD2O 1.23b1 ROM to my HD2. Almost everything is perfect (or at least has workaround) except bluetooth. I cannot turn it on. Actually when I turned it on, it will turn itself off automatically after few seconds.
Bluetooth is must-have feature for me coz I leverage it to use my phone in car. Can anybody with the same ROM has the similar issue? How to fix it? Any workaround?
After searching the forum I found a workaround for this.
Turn on Wi-Fi
Turn off Bluetooth
Reboot the phone
Now I can turn on Bluetooth.
However after while, I found its Bluetooth will turn off again automatically.
I don't have a chance to test the CAB mentioned in the following thread on this ROM yet. (Actually I cannot download it from office network.)
http://forum.xda-developers.com/showthread.php?t=1250869
Hopefully they could fix the issue.
Similar behaviour to me...
But I discovered that if I charge my HD2 (when I'm in the car) then the bluetooth is not turning off automatically any more...and I can use it.
abogdan said:
Similar behaviour to me...
But I discovered that if I charge my HD2 (when I'm in the car) then the bluetooth is not turning off automatically any more...and I can use it.
Click to expand...
Click to collapse
Really? How about Wi-Fi? Do you need to enable Wi-Fi to turn on Bluetooth?
If it works, at least we have a workaround before 1.23 final version released.
I just realized that I cannot send CAB to HD2O ROM. Pathetic~
larryexchange said:
Really? How about Wi-Fi? Do you need to enable Wi-Fi to turn on Bluetooth?
Click to expand...
Click to collapse
Yes, wi-fi should be ON in any case...if you want BT working.
abogdan said:
Yes, wi-fi should be ON in any case...if you want BT working.
Click to expand...
Click to collapse
I tested the solution. It works! Thanks you so much! At least we had a workaround. Hopefully HD2O could fix the bug in the next release.

Categories

Resources