[Q] Most efficient/effective way to connect Bluetooth to embedded device - Java for Android App Development

I have: 1) An embedded device with a Bluetooth connector that I use with BlueZ, and 2) I have an Android phone that I am writing an application on.
Goal: I want to make sure that when these two devices are near each other, they quickly detect each other and establish communication. Unfortunately, I'm running in to complications of what is feasible on Android and power efficient.
Initial Design: Originally, I've been thinking and implementing the following
Embedded Device: Constantly in discoverable mode, creates a service with an RFCOMM server running to accept multiple connections.
Android Phone: Listen for Broadcast intents that would tell me when the embedded device (discoverable) is nearby, and then create an RFCOMM client socket to it.
The difficulty I am having with this design is that I do not get intents when I would expect them. Even if I turn the embedded device on and cycle the Android phone's Bluetooth adapter to off/on ... none of these Broadcast intents are received:
Code:
BluetoothDevice.ACTION_FOUND
BluetoothDevice.ACTION_ACL_CONNECTED
BluetoothDevice.ACTION_BOND_STATE_CHANGED
The only thing that seems to work is to periodically either have the phone try to connect to the Bluetooth device's RFCOMM socket, or to periodically trigger Bluetooth scans (both power inefficient). This will trigger ACTION_FOUND and ACTION_ACL_CONNECTED. If i shutdown the embedded device, I will receive ACTION_ACL_DISCONNECTED. The issue, again, is that none of these are received if I do not explicitly have the phone try to initiate a socket connection. This is bad for power efficiency on the phone.
-----
Do I have this logic backwards? Should the embedded device keep track of Bluetooth MAC addresses that it has paired with and be the RFCOMM client, whereas the Android application creates a service and is the RFCOMM server just hanging around and waiting for a connection? This seems logically backwards, though... I wouldn't think the Android phone would create a service or be the server to make this happen.
If I go in to my car, it almost immediately manages to establish a connection with my phone. So, I know this is possible!
The concrete questions I have are two-fold: 1) Is there something I am doing wrong with my "initial design" to make it more effective, and 2) Is the 2nd logic I propose what things like cars use to establish quick communication and poll frequently? (since the battery power of the car is not a concern...). I am thinking of putting a server on the Android app that the Embedded device just tries to keep connecting to, and when successful, it's used as a notification to the Android app to try and connect to the embedded device's server. That would keep most current structure in place.

Related

shot in the dark...

This is a shot in the dark, but has anyone heard of anyone who got the mogul to work as an access point? Basically, use the evdo radio to connect to the internet, and use the wireless connection, either as an adhoc connection, or preferably as a full on access point with wpa2 to share to a laptop, other devices, etc. To better describe this, you can kind of do it with a laptop:
1. connect phone via ics or dun to laptop.
2. in windows, enable ics and create ah-hoc network with encryption.
3. Other laptop connects to windows laptop, gets wireless connection and is effectively using the phone as an access point.
Even better
1. Connect phone via dun to linux laptop.
2. Linux laptop (using madwifi driver or other open source) broadcasts access point settiings and works as a full on access point.
Scenario:
I want to be able to connect my mogul to my n800. I can do that now with DUN, but what if I want to use my bluetooth headphones, or the bluetooth keyboard that I haven't bought yet? Bluetooth only allows one connection at a time, so I'm SOL. If I could get my stupid mogul to work as an access point, then I could share my connection with any wireless device (how sick would that be) and reserve bluetooth for what I wanted to really do with it, not just browsing the net. Don't get me wrong, I love that I can even sync via bluetooth, but am just looking to expand the possibilties. Unfortunately, since this is WM6, I have no idea how to really work the SDK to see if network bridging is possible. If this were a Linux phone I'd probably be done already. =(
search for socks proxy.
it doesn't work that well, but it does work..
-mark
jtlonthewestside said:
Scenario:
I want to be able to connect my mogul to my n800. I can do that now with DUN, but what if I want to use my bluetooth headphones, or the bluetooth keyboard that I haven't bought yet? Bluetooth only allows one connection at a time, so I'm SOL. If I could get my stupid mogul to work as an access point, then I could share my connection with any wireless device (how sick would that be) and reserve bluetooth for what I wanted to really do with it, not just browsing the net. Don't get me wrong, I love that I can even sync via bluetooth, but am just looking to expand the possibilties. Unfortunately, since this is WM6, I have no idea how to really work the SDK to see if network bridging is possible. If this were a Linux phone I'd probably be done already. =(
Click to expand...
Click to collapse
Ummm... I'm not sure what you are basing your Bluetooth information on, but the BT specification allows for up to 8 concurrent connections at once- one master devices and 7 slaves. Why do you think its only one at a time?
I use multiple connections all the time- Very often I have my phone connected to my bluetooth GPS receiver in the car, and at the same time I'm playing tunes from the same phone over my A2DP compatible car stereo... or, take a phone call on my BT headset, and all the while I'm still connected to the GPS who is still tracking my location using bluetooth. I can tell the person where I am in real-time.
I've also had someone send me a file while talking on the phone via BT headset.
You don't need such a complicated solution for your imagined problem! I don't see any reason you can't tether it and still connect to up to 7 more Bluetooth devices at the same time!
Still, using it as an access point might prove useful for other sorts of scenarios (teleconnected mobile Lan parties? WiFi on a Bus? The incredible moving hotspot?), but you don't need it... at least not for your described scenario!
Basides, you'll get better battery life out of your connected devices if just using BT instead of WiFi!

Utilizing home-based Voip provider through VNC?

Is it possible to utilize my existing home-based Voip provider (e.g., Vonage) via my Smart(dumb?)phone if I have a notebook connected to my Voip phone adapter and running a VNC server?
I have successfully used a VNC between my phone and computer and wonder what I would need to take it a step further and use this connection for phone services through my phone adapter and avoid an additional Voip account.
Would the notebook need to be connected via a standard telephone cord or is it possible to use the existing Ethernet connection through my router?
Note that I've yet to try using the notebook's telephony features in making a "Vonage" call with a connection similar to my handsets.
I would like to believe that it is possible to instruct my notebook (via a VNC) to make a call but would I then be able to listen to and push voice over this connection?
Thank you for any thoughts regarding the matter.
great idea, might work. but im not sure if vnc has microphone support. if not you may need to relay the microphone, but might cause undesirable delay :[.
ekw said:
great idea, might work. but im not sure if vnc has microphone support. if not you may need to relay the microphone, but might cause undesirable delay :[.
Click to expand...
Click to collapse
Thanks for chiming in.
Lag time and the tiny screen are the reasons why I rarely use a VNC now so, I suspect and as you have considered, delay time may kill the whole deal regarding this type of setup.
Have you used Skype with your phone and is there something of a delay with this?
How about the sound quality?
I just thought that while I was traveling away from home I could connect wirelessly (e.g., Vonage's V-Phone but without the extra hardware and a notebook) and utilize my account via my Smartphone.
Maybe they'll come up with a mini/microSD card and software to work with WM/other devices?

Bluetooth - Medieval & Ubuntu

I am trying to determine if you can send/receive files over bluetooth, between a Magic and a netbook running Ubuntu (9.10 specifically). Bluetooth works on both devices with my headset. Both devices can see eachother during discovery. Other than dealing with that absurdly short pairing timeout and the lovely 6 digit PIN I can get to the "Paired but not connected" state.
However all attempts to send or receive files, initialed from either side fail.
Does anyone have bluetooth file transfers working between the phone and a computer running Ubuntu (both directions), and if so how (what setup, what app, etc)?
I like ubuntu,too.
why don't try wi-fi.
I use the "FTPServer"(app download market). Send file to my G2 almost 1M/s
gtalk to me,talk about Ubuntu .
I notice that I cna't get bluetooth to conenct with my ubuntu netbook.
wifi tether won't obtain Ip address either.
Wifi works fine. It is somewhat the principle of the mattter, and somewhat if I am already using bluetooth to pair with my headset, why run another power draining radio to push or pull a small file to/from my netbook.
I have wifi FTP working. Also have Wifi Tether and use it all the time. I guess I am greedy... want bluetooth as well. It should be possible once I sort out what the issue is.
Status update
After installing gnome-user-share and allowing Personal File Sharing->Share Files over Bluetooth, and unpairing and repairing the handset yet again I now can push files from the netbook and the phone. I cannot browser either device remotely and pull files though.
So it is half working. Does anyone have both push and pull working?

[Q] Direct communication with other Android device?

I'm working to develop an application to use a rooted Nook STR as a handheld data input platform, which then sends the data to another Android device (tablet or phone; TBD) acting as a hub. From what I've been able to determine, the options for communications between the devices are:
Bluetooth
-Possibly available using a dongle, USB OTG cable, and enabling USB host mode as described here. This doesn't seem practical within the time/budget/scale of our application.
Wi-Fi
-Wi-Fi Direct would be ideal, but requires either Android 4.x or a patch/hack to enable it, which I haven't seen anyone working on (correct me if I'm wrong about this)
-Separate Wi-Fi hub to manage communications between the devices
Is there an alternative, implementable within reasonable time and cost, to facilitate device-to-device communications wirelessly and without additional separate hardware? My research hasn't turned up any solutions that aren't extremely awkward, but I'm relatively new to this, so hopefully someone has a better idea or knows of an obvious possibility that I'm missing.

[Q] Interface/Controlling Android remotely via USB Rx/Tx commands

Here's some context, skip below the asterisks*** to read my actual question:
I have an arduino project I am working on that combines the arduino with GPRS, relay, and camera attachments (shields) to act as a smart alarm for a car. Essentially extending the range of functionality (remote starting, lock/unlock/ alerts etc...) to my smartphone.
Since car alarm sirens are annoying and useless, I would rather be called if my car is being "violated". The GPRS and arduino could easily handle phone call or text message notifications. It could also receive texts and turn on relays etc...
One feature I think would be great would be the ability to send a MMS message with a picture of the inside of the car. This would be difficult and probably more expensive to do (needs stronger arduino board, good camera etc...)
Then I thought why not just hack up an "old" ($50 used android phone that can take really good pics etc...) They are just built a lot better and more compact than the hack job I would end up piecing together and cost a lot less. There is only one thing I can think of... see below.
************************************
1) Is there any way to interface or control an android phone through the serial communication connector (ie usb plug hole) using commands from a device such as a raspberry pi, or arduino or similar.
What I would want to do is have a trigger (arduino monitor the dome light voltage line) to signal the arduino to control the phone to do the following:
--Call me
--take picture inside car
--send said picture via mms to me
I would also like the arduino to be able to read the sms messages I send to the phone in my car to do things like roll windows up, remote start etc... (arduino can do this last part with the gprs) as long as the arduino can read the text message it can perform something.
I am not looking for a remote client (like VM whatever its called).
If this isn't the place for this, please let me know where to start looking.
There is a product called mimic USB from customgadz.com that makes me think that sending commands through USB must be doable, but they are expensive and I don't know enough about it to help you do it well.
My first instinct would be bluetooth. I am not especially versed in arduino, but I know you can get a bluetooth shield for about 20-30 bucks. If you could make your dome light "trigger" tell the arduino to turn ON its bluetooth or send the equivalent of a button-press from a bluetooth headset (if the shield is always on). Then use Tasker on the phone! Create a task that when the phone senses bluetooth (either the new connection or the button press) then it snaps the picture, texts you, and calls you etc.
AFTERTHOUGHT: tasker can also detect charge state, to change settings when phones are plugged in/unplugged... So if you got the arduino to flip a relay, when triggered, that turned the port that charges the cell phone off... Then tasker could read that change in charge state and activate the steps you wanted. Then after a preset delay, or once the dome light went back out, you could have the USB turn back on to keep the phone charged. It is a little more circuitous work-around, but it would effectively be a command from the USB, like you asked for

Categories

Resources