Read bluetooth device battery - Java for Android App Development

Hey,
I already asked the question here but I thought I could not help to post it here anyway because maybe it's a bit better for a question which deals with custom ROM sources.
On my Tablet (with CyanogenMod 14.1) I can see the battery status of my connected bluetooth headset (no BLE device). On my phone (which runs on Stock 7.1) I can't see this information. Also iOS can display the battery status.
I would like to build an application which gives me this information also on my phone. For this I thought I could copy and modify the CM source code but I can't find anything where they read the battery status from connected bluetooth devices.
Has anyone found something like this in the massive source of CM and can give my the link to the source? Also a rooted solution or a system app which I have to flash would be okay.
Hope someone can help me here.
Greetings, Cilenco

If one device is correctly reading the battery data then the data is probably being sent over the connection. I would suggest reading the packets that are received from you headset. There is possibly a mic line, audio line, and battery/data line. your phone may only be reading the mic and audio.

Related

What's the problem with Hero based ROM's and BlueTooth?

Hello.
Before you tell me... I already searched the forum and I can see many posts about the problems with BlueTooth in the Hero based ROM's, but none of these posts I read (I could have missed some, of course) say what the problems are exactly, so I don't know if it can be a problem for me or not.
The only things that I need from BT are connection to the Parrot CK3000 handsfree on my car, and to send/receive files over BT. Ocassionally I will use the Magic as a 3G modem, but I can do it through USB if not working through BT.
Are these BT features affected by these BT problems on Hero based ROM's?
Thanks in advance.
Not sure if this applies to all hero roms but in the 'jacxheroskiv' rom the problem is a missing shared object (just a missing file in the filesystem)
http://forum.xda-developers.com/showpost.php?p=4479554&postcount=96
Hi There
At the moment Bluetooth is problematic on all hero roms for the sapphire or otherwise. Audio head sets (wireless headphones) seem to work ok but everything else doesn't. So unfortunately your car kit won't work. (I have the same one, it pairs but the audio is garbled) File sharing on the other hand is a problem for all the androids so far (There is an app on the market that provides the functionality but it's not as elegant as it could be) so don't expect that to work on hero roms. I haven't tried Bluetooth tethering because WiFi tether works so well. Perhaps someone else could comment.
Now for the difficult part...
So far as I can tell a willing developer, correct me if I'm wrong, could make the Bluetooth work if the source code for the hero was made available (should be available in a few months if the recent release of the sapphires source code is anything to go by) There seem to be quite a number of people who need this functionality so I'm sure one of the rom cookers will get to it but unfortunately there is no way to know exactly when. For this reason I've decided to stick to the ion roms for now. In any event, Touchflo/Sense UI will be made officially available for the magics in due course...for a price of course
On another note any support financial or otherwise is greatly appreciated by the developers so if you want to encourage a particular functionality a few bucks and a friendly message will go a long way. Please remember though that the developers do this kind of thing for the love of it and provide no explicit support for their roms. Any and all risk is taken upon yourself but in most cases caveats will have been picked up by someone before hand.
Sorry if I've mentioned some things you already knew but I thought to add some info applicable to other newcomers.
Enjoy hacking!!
Thanks both.
I guess I'll have to use a non-Hero ROM then. As for the BT file transfer, I've seen at least one Cupcake ROM with it enabled and available as an option in the BT menu. I don't know what ROM it was though, I think I saw it in a Youtube video.
P.S.: I noticed that this thread was moved to "Sapphire general", sorry for put it in "development", I did it for it was related to Hero ROM's. Thanks mods for move it.
A2DP works for my Sony Ericsson HBH-DS205 - music streams flawlessly.
However, the call feature does not work - is this another common bluetooth problem with the HEROs?

Nexus 7 as hands free bluetooth device?

I know that at the moment this isn't possible, but does anyone know if there is work being done on the Android bluetooth stack to enable a tablet to be used as a bluetooth hands-free device? A bit of searching shows that it is a regularly requested feature but I can't seem to find any info on any developers who are definitively working on this (except for one little questionable nugget that stated that the CM developers were playing with Bluetooth. Hardly enough to go on.).
I want to incorporate a Nexus 7 into my 370Z as a carpc but the lack of being able to integrate phone features is holding me back. Using data apps like grooveip are a no go for me as data connections around here aren't reliable enough for consistent daily use. Thanks in advance for any info.
I'm not to sure of what your asking, but if you wanna make calls from your tablet using BT this app allows you to do that as well as send SMS and MMS from it https://play.google.com/store/apps/details?id=com.apdroid.tabtalk hope that helps and is what you mean
Sent from my Nexus 7 using Tapatalk 2
I appreciate the suggestion but I don't think this will work. What I would like to do is mount my tablet in my car and use it as a front end for my phone to make/take calls the way an OEM bluetooth car system would normally work. My understanding is that your tablet must be paired as a hands free device, which android tablets currently don't do. I looked at Tablet Talk but when using that app from what I can gather when you accept a call on the tablet it actually activates the call on your handset. Ultimately I want to use the tablet as a hands free solution as I drive stick and holding my phone to my ear while driving is a no-no.
In the past I've used bt headsets but I lose them constantly and frankly I'm tired of replacing them. Oh well.
Well, good luck in your search! And you hit tablet talk spot on BTW lol. Oh and if you do find a solution, plz post it! This sounds like something I would love to use.
Sent from my Nexus 7 using Tapatalk 2
SpungeWorthy said:
Well, good luck in your search! And you hit tablet talk spot on BTW lol. Oh and if you do find a solution, plz post it! This sounds like something I would love to use.
Sent from my Nexus 7 using Tapatalk 2
Click to expand...
Click to collapse
Thanks. I'll thinking I'll probably go the route of a more traditional carpc for now, but if and when this becomes a feature you can take advantage of with android tablets I'll have to reevaluate the situation.
Nillaz said:
I know that at the moment this isn't possible, but does anyone know if there is work being done on the Android bluetooth stack to enable a tablet to be used as a bluetooth hands-free device?
Click to expand...
Click to collapse
This would be a great extension or compliment to the various apps that let you send/receive SMSs from your tablet via your phone. If I could at least receive/answer calls too, I could leave the phone elsewhere at home.
Just to let you know I've contacted parrot and garmin with regards to something like this.
I want a solution where I can make my nexus 7 a full media center with DAB radio and a good sat nav without needing a cellular link and hands free for my phone which includes the voice commands available through the tablet.
So hopefully they will get back to me and I'll post up here what they say.
Something I haven't solved yet either is getting all the antennae feeds into the nexus, I was thinking of getting a sharks fin antennae and wiring them into a raspberry pi to then blue toothing them into the nexus, I could also then attach a HDD to the pi to use it as a server to.
I want to do it this way so I can take the 7 otu and with me if I wish, rather than having it hard wired in. also if would allow for device upgrade.
Theres a nice thread on install and with references to the tasker app to get the tablet to work with the ignition and other functionality like that;
http://forum.xda-developers.com/showthread.php?t=1819175
b
BT app
There is an app under development for this I think. play.google.com/store/apps/details?id=com.funkyandroid.phonelink
I'm thinking of dropping a Nexus 7 in my car but the lack of hands free bluetooth is kind of a deal breaker.
Did anybody ever get this working? I have my Nexus installed in the car, and would love to be able to use it as a speakerphone. I don't need to actually be able to make the calls via the tablet, just need to be able to use it as a basic bluetooth speakerphone / headset type of thing.
It sounds like it should be something fairly simple, but I cannot seem to find much.
I have been wanting this for a long time, I'd love to be able to take my older Android phone and re-purpose it as a car GPS/Internet Radio/Handfree, etc.
I know the Samsung Galaxy player has this functionality, I wonder if any of their devs could help out.
if this work in linux so i think can work on android
Hi to all,
i been looking for this "bluetooth role" for long time. I have read a lot of forum and the entire XDA posts about this..
it seems that this is the definitive question like "what is the answer to life the universe and everything" simple 42
and it seems that is the paradise for all want to make a carputer/droid/tablet/**** car radio replacement... so... i'm one of you
this post is for some devs (i'm a dev too) i'm asking for help ....
the problem is: which android version do you want to use?
why this question? simple: from the android 4.2 google has decided to trash the bluetooth bluez stack and reimplement the wheel with bluedroid...
i read the documentation about bluedroid at this site:
https://source.android.com/devices/bluetooth.html
and there was written that there are some profiles actualy implemented but not the Bluetooth Hands-Free Profile server.
Ok it's not a problem, taking a look to the template of other profile i can implement it.
now the question is HOW DOES IT WORKS?
so i searched and bum this is how:
version 1.5
version 1.6
ok and now? and now i tried to find some similar implementations and...
after another night of search i found this....
HFP For Linux
where there is the downloadable source code.
now I think we have all the necessary to make this possible...
BUT there are some problem that i haven't resolved yet for a lack of knowledge of course.
it seems that the hfp override any other profiles on that example, it's not bad, in a system that i want to use i need only a HFP profile and AD2P togheter all the rest is useless
i think that this at the end is a fork of the standard android project and how I/we can put it into a rom or a patch and who want to add to a rom/kernel? how it can be done? is a patch better ? a new kernel like franco's or better to submit to google?
I hope to have intrigued someone with this post and I hope that somebody can link me to some documentation to understand how to put all the information I have together.
ps. i have tried to reply into this thread:
[Q] Android phone as bluetooth headset?
but of course i have to few posts to make my suggestion there
I may be out of line here but try reading about the gmate+ device.
I got one paired with my Nexus 7 32gb right now and currently using it as a phone. I believe there are other similar gadgets out there, as I've done some researches before I actually got mine to work. I have yet to try it with a bluetooth headset paired because I lost mine just on the day when I was about to try it out.
Anyway, one problem here is, the app for the device is currently not updated so there are a lot of things that need tweaking and one major issue for me is the ringtone. As I have posted here before, sine N7 does not have native ringtone, there's no alert tone for incoming calls. As for text messages, the notification alert tone works. I know there's also GPRS for it but haven't tried it out yet.
Try these options...
As far as an option for a Nexus 7 you may want to try a sip dialer like 3cx or linphone or zoiper and establish a free sip account at iptel.org or something. As long as you have wifi or a 3g connection which some tablet have you should be able to make and receive calls, or try ""Blue Fi" from the play store. it may work.
naiku said:
Did anybody ever get this working? I have my Nexus installed in the car, and would love to be able to use it as a speakerphone. I don't need to actually be able to make the calls via the tablet, just need to be able to use it as a basic bluetooth speakerphone / headset type of thing.
It sounds like it should be something fairly simple, but I cannot seem to find much.
Click to expand...
Click to collapse
golfnz34me said:
I have been wanting this for a long time, I'd love to be able to take my older Android phone and re-purpose it as a car GPS/Internet Radio/Handfree, etc.
I know the Samsung Galaxy player has this functionality, I wonder if any of their devs could help out.
Click to expand...
Click to collapse
I just got a new Nexus 7 for the same purpose of replacing my vehicles head unit with a tablet.
I am digging into the BT stack since I believe that I should be able to implement (or port) the profile on top of Android 4.3 assuming that the SCO data is available through the raw BT connection. There is an open source HFP implementation on sourceforge for Linux that migh be close enough to do the trick and save a bunch of coding time. It's going to take a while for me to get the time to dive too deeply into this one, but if I succeed or come to the conclusion it can't be done, I will let folks know.
Hello guys.
I am going to buy Nexus 7 for my car for the same purposes, - navigating, internet.
But mainly is for the Hands Free function.
Unfortunately, people saying nexus can't use it. But it's lol...I don't believe nexus7 doesn't support hands free.
Gentelman, tell me any way to make nexus 7 works hands free.
Thank you in advance.
P.S. if you ask wham am I mean when saying "hands free", so there is an example http://www.youtube.com/watch?v=ZEFjDKtlao8
Use some Motorola MotoActiv Bt code?
I have a Motorola MotoActiv running watch... Features gps tracking for running and biking, MP3 player and Bluetooth... The Bluetooth is mainly used for wireless headphones, but if you have a Motorola Phone, the watch can display text msgs from the phone and you can use the headphones/mic through the watch to take calls. (the idea being that you can leave the phone in a pocket or backpack while you're bike riding, I guess, and still take calls.)
The device runs Android (I'm sure someone's rooted it on here). Maybe that code can be dissected and repurposed for what were all looking for??
J
more on Motorola Watch
SmartNexus said:
I have a Motorola MotoActiv running watch... Features gps tracking for running and biking, MP3 player and Bluetooth... The Bluetooth is mainly used for wireless headphones, but if you have a Motorola Phone, the watch can display text msgs from the phone and you can use the headphones/mic through the watch to take calls. (the idea being that you can leave the phone in a pocket or backpack while you're bike riding, I guess, and still take calls.)
The device runs Android (I'm sure someone's rooted it on here). Maybe that code can be dissected and repurposed for what were all looking for??
J
Click to expand...
Click to collapse
Just an update on something I said in my previous post... I was looking at my MotoActiv watch today and it says you have to have an "Android phone" not a Motorola phone as I said in my previous post. So I'm wondering if the phone audio over Bt can be reverse engineered from the Motoactive watch for other android devices.
I actually decided to root my watch today just for the fun of it... it would really make the perfect "Car Head Unit" as it has Android OS, MP3 capabilities, FM Tuner, Bluetooth and Phone audio over Bluetooth built in... if only the screen was larger than 1.5".
Looks like the Nexus 4 and Nexus 7 2013 are getting some love in this area with a new custom stack:
http://www.bluez.org/bluez-for-android-status-update/
Looks like you need some compiling skills, but I think this is what you are looking for.
It must be work... Or not?
Hello guys!
I'm thinking on a same project for a while. It doesn't matter if not work for me, but would be great if yes.
I found something 2 days ago:
Parrot Asteroid Smart
This is an android base head unit/navigation, and the bluetooth handsfree is working on it. How it's possible? Any chance to port it into the Nexus 7?
solution
So i had an idea today and decided to call my carrier (Cricket). They told me it is possible to purchase an extra sim card and they will program the imei# to match my phone. This will enable me to make and receive calls on my tablet as well as my phone using the same number. Also i will have full access to my data.....problem solved with only 15 dollars. I hope this helps somebody.

[Q] Nexus 7 as a bluetooth headset?

Hey guys
I'm using my nexus 7 dashed in my car. (Kinda!)
And i'm using tablet talk to connect my phone with it.
Also i have a bluetooth keyboard connected to my tab.
When i have a text, i can answer it easily. But when someone calls me and i accept the call the sound doesn't come from my car audio and my sound doesnt go through my tablet's mic. They bouth go through my phone!
So i have to use my n7 as a bluetooth headset for my phone. Is it possible?
Can anyone guide me?
No one? nothing? no helps? no ideas? cool!!! :|
For God's sake!!!
guys, this will be great. pleeeaaaase, consider developing or sth.
Cool it, seriously. The forum hardly revolves around this one post.
Given the way the Bluetooth radios are set up, it's not really an easy hack and you'd probably have better luck using a dedicated app over Wi-Fi direct or something (of course, such an app would have to exist as well in the first place). I remember looking into this for the iPod Touch a while back and didn't see anything either, but hopefully you'll have better luck.
Rirere said:
Cool it, seriously. The forum hardly revolves around this one post.
Given the way the Bluetooth radios are set up, it's not really an easy hack and you'd probably have better luck using a dedicated app over Wi-Fi direct or something (of course, such an app would have to exist as well in the first place). I remember looking into this for the iPod Touch a while back and didn't see anything either, but hopefully you'll have better luck.
Click to expand...
Click to collapse
Well it WAS an easy hack, It's just a case of setting the configuration files up correctly. You get the N7 to advertize the Headset service and an Roberts your father brother as they say. I just about had it setup a couple of months back...... I want to control the full telephony service through the N7 show incoming calls and all the fun stuff.... As a first step I got the voice routing through the N7 Microphone through a handset and onto the caller. However I stopped there because that was using android 4.1.1 and I want to be using the latest build... Which is where your right out of luck because 4.2 onwards is a different beast,
Google decided to replace a tried and tested well documented fully implemented Bluetooth Stack with something that's not quite finished yet whose documentation is the source code. That's why there's no Low Energy stuff on Android yet..... It could and should have been implemented last year, anyway I digress. So the options are
1. Use a rom prior to 4.2 - In which case the Bluez is well documented and this sort of problem has been solved multiple times on the linux desktop and the same ideas can be applied to Android, Google is your Friend
2. put the old stack back in and work with that, There's patches that do that but they are all a bit brutal and would be a nightmare to maintain.,
3. Wait for the Missing Code to be added, which could be tomorrow but It could be never
4. write the code yourself..... Fine if you're an expert in that area but the learning curve is inclined shall we say.
or,
5. You could spam XDA daily with requests .
Personally I put this project to one side because my nexus 7 is out on loan to my brother after he decided to bathe his HTC OneX in Lucozade for an hour...
trevd said:
Well it WAS an easy hack, It's just a case of setting the configuration files up correctly. You get the N7 to advertize the Headset service and an Roberts your father brother as they say. I just about had it setup a couple of months back...... I want to control the full telephony service through the N7 show incoming calls and all the fun stuff.... As a first step I got the voice routing through the N7 Microphone through a handset and onto the caller. However I stopped there because that was using android 4.1.1 and I want to be using the latest build... Which is where your right out of luck because 4.2 onwards is a different beast,
Google decided to replace a tried and tested well documented fully implemented Bluetooth Stack with something that's not quite finished yet whose documentation is the source code. That's why there's no Low Energy stuff on Android yet..... It could and should have been implemented last year, anyway I digress. So the options are
1. Use a rom prior to 4.2 - In which case the Bluez is well documented and this sort of problem has been solved multiple times on the linux desktop and the same ideas can be applied to Android, Google is your Friend
2. put the old stack back in and work with that, There's patches that do that but they are all a bit brutal and would be a nightmare to maintain.,
3. Wait for the Missing Code to be added, which could be tomorrow but It could be never
4. write the code yourself..... Fine if you're an expert in that area but the learning curve is inclined shall we say.
or,
5. You could spam XDA daily with requests .
Personally I put this project to one side because my nexus 7 is out on loan to my brother after he decided to bathe his HTC OneX in Lucozade for an hour...
Click to expand...
Click to collapse
tnx for your answer.
but how can this be so hard?!
i used to do this with my laptop! :S

[Q] Android L preview for Nexus 4

Hello Everyone!
I could not post on the developer thread so putting it up here. I flashed the zip file that was shared on this thread (http://forum.xda-developers.com/showthread.php?t=2807178) and to be honest I just loved the visual improvements that google have done in the L version. However, I found some issues which I need to know whether are resolved or not. If it happens to be posted somewhere else, please direct me to the thread.
Bluetooth Connectivity: I drive a lot with my phone connected to the car all the time. After flashing the ROM, I found that there was no option for phone audio in the bluetooth connection settings. Therefore, I was able to control the music player (since media playback option was there) from the car console but I could not access any calling functions/phonebook/recent calls, etc. from there. Has this issue been fixed? If not then I might have to go back to stock KitKat with Xposed which I was using earlier.
Regards
Me Too
I have found the same problem. It would be great to know if there is a workaround!

My Continued Bluetooth Nightmare

OK,
So I'm trying to get some help regarding this issue. I will continue to try different ROM's and what not to see if it can be resolved. I'm simply at a loss to where the issue lies though, however as of today, every custom ROM has been giving me trouble. My plan for today is to flash a stock ROM via Odin and then if that works go for Imperium, however I'm hoping with your help I may be able to solve it on something like CM12 or what not because I prefer the flexibility of a proper custom ROM.
OK, so the issue I have:
I have a car head unit which has bluetooth built-in. Music plays fine through Bluetooth, no jitters or issues. However, when I try and call someone and I'm listening to the radio or something non-Bluetooth, the phone does not send the signal (?) to the head unit to switch to Bluetooth. This means the call will be made via the dialer app and while the audio IS being routed through the bluetooth channel, the head unit does not know about it because it hasn't received the signal to switch to Bluetooth. I can switch it manually to Bluetooth and make and receive calls, but this isn't convenient at all and probably quite dangerous when I'm driving a car. The same applies when receiving a call.
Here's the thing, if I go into Bluetooth, select CAR KIT and go configuration, if I disable Media Audio, then it works fine! The phone correctly sends the signal to switch to Bluetooth and the head unit does so. The call goes through and it all works fine. This is repeatable.
Therefore, the issue I'm having lies in the fact both Media and Phone Audio are enabled at the same time. Has anyone else had this issue and does anyone have a suggestion to fix it?
Before someone suggests "just disable media audio". My answer is no, this isn't convenient at all. I use Bluetooth media quite a lot, and simply disabling and re-enabling it everytime simply isn't an option.
So far, I've had this issue on:
CM12.1 Optimized
CM12.1 Nightly
Mokee ROM
DirtyUnicorns
CM12 Nightly
I'm yet to try a stock Lollipop ROM. I know for a fact however, that stock KitKat DOES work.
I really could do with some help here, so any suggestions would be awesome.
all the roms you have tried are aosp....aosp is not designed for the s4 as its not an officially supported device (its not a nexus) so things like bluetooth and the camera will always be broken as the required stuff needed is proprietary to samsung
go back to stock and your problem will be solved
DSA said:
all the roms you have tried are aosp....aosp is not designed for the s4 as its not an officially supported device (its not a nexus) so things like bluetooth and the camera will always be broken as the required stuff needed is proprietary to samsung
go back to stock and your problem will be solved
Click to expand...
Click to collapse
The Bluetooth itself is fine. Audio quality is fine. Call quality is fine. It just seems like a tiny little thing that's causing all these issues for me, because if it could trigger my car head unit to switch, I wouldn't even dream of stock. Also the camera seems fine to be fair?
I'm not keen on going back to stock.... at all, so I'm thinking Imperium. It's a shame though because apart from this BT issue, CM12 is fantastic on this device. Takes a 2 year old phone and makes it feel like a brand new phone.
I really hope someone can fix that Bluetooth bug in CM12.1. I may even look myself, it must be something pretty small from a coding perspective because as I said, the functionality is clearly there as evidenced by the fact it works with Media audio turned off.
Regardless, thanks anyway
Changing the modem did not solve my problem.
When did you try the Optimized and the nightlies? There have been a lot of fixes lately regarding bluetooth.

Categories

Resources