蓝牙的Android到Windows 7 [英] Bluetooth Android to Windows 7
问题描述
我试图让从我的Android手机传输数据的字符串通过蓝牙运行Windows 7(反之亦然),我的笔记本电脑的应用程序。
I am trying to make an application that transfers Strings of data from my Android phone to my Laptop running Windows 7 (and Vice-Versa) over Bluetooth.
我想,我会打开在Windows计算机服务器套接字编程和Android应用程序启动客户端编程。但作为意识到Android的SDP(服务发现协议),并连接到一个UUID,创建一个地步,在我感到困惑。
I figured that I would open up a Server-Socket on the Windows Machine and program the Android app to start a Client-Socket. But being aware that Android SDP(Service Discovery Protocol) and connects By a UUID, created a point where in I am confused.
困惑,我应该如何启动在服务器端使用Windows API的服务器套接字。
我的问题是机器人是否会检测服务器插槽,如果我仅仅是开始与蓝牙接口
Confused on how I should start up a server socket on the Server Side Using the Windows API. MY Question is whether android will detect the server socket if I merely start a Bluetooth socket with
SOCKET sock_s, sock_c;
SOCKADDR_BTH add1,add2;
sock_s =socket( AF_BTH,SOCK_STREAM,BTHPROTO_RFCOMM );
if ( sock_s == INVALID_SOCKET )
return -2;
//Clearing the SOCKADDR_BTH variable
memset(&add1,0,sizeof(add1));
add1.addressFamily=AF_BTH;
add1.serviceClassId=my_Guid;
或者是有另一种方式来创建跟随在微软产品?
Or is there another way to create a server socket that follows the SDP protocol on the MICROSOFT stack?
推荐答案
你有使用本地code在Windows中?如果不使用我的图书馆( 32feet.NET )其做出这样的事情很容易例如蓝牙服务器端:
Do you have to use native code on the Windows box? If not use my library (32feet.NET) its make such things easy e.g. Bluetooth Server-side:
Class MyConsts
Shared ReadOnly MyServiceUuid As Guid _
= New Guid("{00112233-4455-6677-8899-aabbccddeeff}")
End Class
...
Dim lsnr As New BluetoothListener(MyConsts.MyServiceUuid)
lsnr.Start()
' Now accept new connections, perhaps using the thread pool to handle each
Dim conn As New BluetoothClient = lsnr.AcceptBluetoothClient()
Dim peerStream As Stream = conn.GetStream()
...
您甚至可以使用32feet.NET从C ++用C +++ / CLR。
You could even 32feet.NET use it from C++ with C+++/CLR.
或者IIRC有一个简单的方法来获得Windows WSASetService 中添加一个基本的SDP记录您的服务器插座(如果你没有自定义记录添加)。或者从Windows的插座(getsockname)的RFCOMM端口号,并告诉Android应用程序直接连接到该端口号 - 假设它可以做到这一点...
Or IIRC there is a simple way to get Windows WSASetService to add a basic SDP record for your server socket (if you don't have a custom record to add). Or get the RFCOMM port number from the Windows socket (getsockname) and tell the Android app to connect directly to that port number -- assuming it can do that...
这篇关于蓝牙的Android到Windows 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!