是蓝牙键盘还是远程客户端还是服务器
基本的蓝牙问题在这里。
蓝牙键盘、遥控器(wiimote、PS3 遥控器等)被视为客户端还是服务器?
我问这个问题的原因是我正在开发 Android 应用程序,但在连接到这些设备时遇到问题。
我假设这些设备是服务器,因为如果它们是客户端,则意味着它们正在启动连接和连接。我不知道他们会怎么做,特别是因为我的 Android 设备无法被发现。
谢谢
Basic bluetooth question here.
Is a blutetooth keyboard, remote(wiimote, PS3 remote, etc..) considered a client or a server?
The reason I ask is that I am developing an Android application and I am having trouble connecting to these devices.
I assumed the devices were servers because if they were clients that would mean they are initiating a connection & I don't see how they'd do that especially since my Android device is not discoverable.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这些是 HID 设备,HID 设备有 2 个角色 - 主机角色和设备角色,
通常,PC、手机、平板电脑等实现主机角色,允许键盘、鼠标等连接到它。
设备角色通常是键盘、鼠标等。
所以答案是 - 蓝牙键盘、遥控器(wiimote、PS3 遥控器等)实现蓝牙 HID 设备角色。
These are HID devices and HID devices have 2 roles - A host role and device role,
Typically PCs, Mobile Phones, Tablets etc implement the host role, allowing keyboards, mice etc to connect to it.
The devices roles are are typically in keyboards, mice etc.
So the answer is - bluetooth keyboard, remote(wiimote, PS3 remote, etc..) implement the Bluetooth HID device roles.
HID 使用 L2CAP 协议,该协议在蓝牙堆栈中的位置低于我们通常在应用程序中使用的协议(即 RFCOMM/SPP)。因此,您很可能需要更改在蓝牙 API 中使用的类/方法来尝试连接。
此外,它可能不适用于您的情况,但大多数操作系统都内置了对蓝牙 HID 的支持,因此应用程序不需要直接连接到 HID 服务,而是操作系统直接连接,然后使用操作系统的 HID API 来连接从设备获取数据。
至于建立连接的方向。答案是两者皆有。当用户将设备添加到 PC/游戏控制台时,PC/游戏控制台(主机)将连接到该设备。当设备正常连接到主机后,例如当设备进入睡眠状态并在用户按下按钮时唤醒时,它可以立即连接。否则,主机将不得不继续尝试连接,以防万一它被唤醒......
请注意,一旦设备知道远程设备的地址,则无需处于可发现模式。
HID uses the L2CAP protocol which is lower in the Bluetooth stack than the one we normally use in our applications (that's RFCOMM/SPP). So it may well be that you need to change the class/method you use in your Bluetooth API to try to connect.
Also it might not apply in your case, but most OSs have built-in support for Bluetooth HID so there is no need for an application to connect directly to the HID service, instead the OS connects directly and one then uses the OS's HID API to get the data from the device.
As to the direction connections are made. The answer is both. When the user adds the device to the PC/games-console the PC/console (host) will connect to the device. After the point normally the device connects to the host, for instance when it goes to sleep and wakes up when the user hits a button, it can connect immediately then. Otherwise the host would have to keep trying to connect just in case it had woken up...
Note that once a device knows a remote device's address there's no need for either to be in discoverable mode.
Bloototh 基本上是一种个人区域网络技术,因此配对过程中的两个设备都可以充当服务器或客户端。
我非常有信心 Wii 锁定了特定的配对代码,因此您无法像那样从 Android 连接到它。
您确定两台设备都开启了发现功能吗? (http://developer.android.com/guide/topics/wireless/bluetooth.html#FindingDevices)
Bloototh is basically a personal area networks technology, so both devices in a pairing procedure can act as server or a client.
I am pretty confident that Wii is locket to a specific pairing codes, so you cannot connect to it from Android just like that.
Are you sure both devices has discovery on? (http://developer.android.com/guide/topics/wireless/bluetooth.html#FindingDevices )
根据蓝牙 SIG 的定义,
蓝牙 HID 设备是提供人类或其他数据服务的设备
蓝牙 HID 主机的输入和输出。蓝牙 HID 示例
设备包括键盘、鼠标、操纵杆、游戏手柄、遥控器以及
电压表和温度传感器。
蓝牙 HID 主机是使用或请求蓝牙服务的设备
HID 设备。例如个人电脑、掌上电脑、游戏机
控制台、工业机器或数据记录设备。
由于键盘和鼠标提供服务,您可以将其称为服务器。
但不管你信不信,没有必要将其称为服务器,只需将其称为HID设备即可。
According to Bluetooth SIG,
A Bluetooth HID device is a device providing the service of human or other data
input and output to and from a Bluetooth HID Host. Examples of Bluetooth HID
devices are keyboards, mice, joysticks, gamepads, remote controls, and also
voltmeters and temperature sensors.
A Bluetooth HID Host is a device using or requesting the services of a Bluetooth
HID device. Examples would be a personal computer, handheld computer, gaming
console, industrial machine, or data-recording device.
Since keyboards and mice are providing the service you can call it as Server.
But believe it or not, there is no need to call it as Server simply call it as HID devices.