Question

I a trying to connect my Nexus One with Android version 2.2.1 with my pc and use a terminal program such as windows terminal or hyper terminal to communicate. To do this I believe I need to set up an outgoing serial com port. I have paired the devices. When I go on my PC to Bluetooth -> settings -> "add com port" the android device does not display.

What am I missing?

Does android 2.2.1 support spp? The documentation says it does.

Do I need to root the android to add spp?

Has anyone succeeded in this?

My final goal is to write an android app that communicates with an old school bluetooth device that requires com ports? Getting the android to communicate with the pc is an interim step.

I have tried everything I can think of in my android app to connect to my pc and android device but have not been successful. My android app is essentially the same as Serial over Bluetooth submitted by xCaffeniated but with fewer comments. Any suggestions?

Était-ce utile?

La solution

Try beginning with the BluetoothChat sample application. You will then have to alter the UUID used to the generic SPP UUID,

00001101-0000-1000-8000-00805F9B34FB

From this point you pretty much have everything you need.

I have had issues pairing in the BluetoothChat program. So I was required to pair to my computer using the settings menu and then entering the BluetoothChat Program. In BTChat go to the menu and hit connect to a device, choose your computer. I can only speak for windows XP SP3 which is what I'm using. At this point on my machine I receive a task bar pop up asking me if I would like to allow my device to connect as a serial port. I allow it to. Now your phone is associated as the serial port profile on the computer, which you can associate with a specific com port.

Autres conseils

Based on bluetooth spec,

http://www.bluetooth.com/SiteCollectionDocuments/SPP_SPEC_V12.pdf,

2.3 User Requirement, "... Any legacy application may be run on either device, using the virtual serial port as if there were a real serial cable connecting the two devices (with RS232 control signalling)." In 4.3 Remote Port Negotiation, "...There is a requirement to do so if the API to the RFCOMM adaptation layer exposes to those settings (e.g. baud rate, parity)... RFCOMM as such will not artificially limit the throughput based on baud rate settings,..."

In my opinion, since Android (2.2) offers no APIs to set up and open a serial port, they may not be necessary as long as you can discover the remote BT device and make a connection to it. I have tried it and it seems working with:

...

sock = device.createRfcommSocketToServiceRecord(myUUID); sock.connect();

...

where final UUID myUUID= UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"); You may need to take care of Bluetooth Permission and Setup in your application as described in

http://developer.android.com/guide/topics/wireless/bluetooth.html

There might be some issues with the connect() call, i.e. Service is not available or connect is refused, which could be resolved by making sure:

  1. The remote BT device be discovered, and
  2. It must be set to use PIN code (for instance 0000), and
  3. It must be paired successfully with your Android device

These steps must be completed prior to running your application (which has connect call).

Hope this help.

George

There is definitely some funny business regarding how the AT set is implemented on the AOS. The problem is that it is hard to know if you're actually talking directly to Modem or through several abstraction layers (more likely). For a best up-to-date review of the AT Commands available on the AOS platform, plus HW, please see the post:

"How to talk to the Modem with AT commands" http://forum.xda-developers.com/showthread.php?t=1471241

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top