问题
Is it possible to connect the Bluetooth Chat sample with a PC? How can I receive the information to the PC? I thought that I can use the Serial Port Profile (SPP) from the Android device and open a regular COM Terminal on the PC. Actually my application requires sending the accelerometers and other sensors information to a PC in order to know the position of the smartphone. I hope you can help me.
回答1:
You've asked a general question, so the best I can do is give you a general answer. This is a two prong problem. It sounds like you know what you're doing on the android side of things, but we're you're stumbling is on the PC side. Right? As far as PC side goes, you're basically going to need to implement a "bluetooth server". You can use the bluecove library or the standard javax.bluetooth library.
回答2:
The library 32feet.NET that I maintain sounds like what you're looking for. Its for .NET and does Bluetooth, OBEX and IrDA. See for example a simple server example at http://32feet.codeplex.com/wikipage?title=Bluetooth%20Server-side
回答3:
It would be easier to connect the Android and PC to the same network (WiFi/Ethernet) then create a socket connection between the two units. In short:
- Join the Android to your network, probably using WiFi.
- Join your PC to the network (WiFi/Ethernet).
- Create an app on your PC which listens for a socket connection on a port. See Get Closer to the Wire with High-Performance Sockets in .NET.
- Open the port in your PC's antivirus firewall.
- Create an app on your Android which starts a socket connection to the PC (you will need the PC's internal IP address the port you opened on the PC's antivirus firewall). See Socket Communications.
It is a little complicated, but uses current tech and will give you more options and is easier to implement and maintain then a Bluetooth serial connection.
来源:https://stackoverflow.com/questions/8299779/bluetooth-chat-between-android-device-and-pc